2011-06-30 12 views
4

xcode 4テンプレートを作成しようとしています。私は空のグループを作ることができないという事実を除いてすべてうまく動作します。Xcode 4テンプレート、空のグループを作成

私はこのプロジェクト構造を持っているしたいと思います: プロジェクト名 -Models -Controllers -Views -Services

<key>Definitions</key> 
<dict> 

    <key>Views/RootViewController.h</key> 
    <dict> 
     <key>Group</key> 
     <string>Controllers</string> 
     <key>Path</key> 
     <string>RootViewController.h</string> 
     <key>TargetIndices</key> 
     <array/> 
    </dict> 

    <key>Views/RootViewController.m</key> 
    <dict> 
     <key>Group</key> 
     <string>Controllers</string> 
     <key>Path</key> 
     <string>RootViewController.m</string> 
    </dict> 

    <key>en.lproj/RootViewController.xib</key> 
    <dict> 
     <key>Group</key> 
     <string>Views</string> 
     <key>Path</key> 
     <string>RootViewController.xib</string> 
    </dict> 

    <key>en.lproj/MainWindow.xib</key> 
    <dict> 
     <key>Group</key> 
     <string>Views</string> 
     <key>Path</key> 
     <string>MainWindow.xib</string> 
    </dict> 

    <key>Services</key> 
    <dict> 
     <key>Group</key> 
     <string>Services</string> 
     <key>Path</key> 
     <string>Services</string> 
     <key>TargetIndices</key> 
     <array/> 
    </dict> 
</dict> 

<key>Nodes</key> 
<array> 
    <string>en.lproj/MainWindow.xib</string> 
    <string>Views/RootViewController.h</string> 
    <string>Views/RootViewController.m</string> 
    <string>en.lproj/RootViewController.xib</string> 
    <string>Services</string> 
</array> 

ビュー・グループが作成される、ファイルがこのフォルダに追加されますので。

サービスグル​​ープも作成されますが、「サービス」というファイルがあります(拡張子なし)。

答えて

1

私はちょっと遅く到着したと思うが、私はちょうどそれを自分でテストして答えを得た。 ほとんどの場合、フォルダのグループキーを削除するだけで済みます。 XCodeは独自のグループを作成します。たとえば、サービスのみのコードは次のようになります。

<key>Definitions</key> 
<dict> 
    <key>Services</key> 
    <dict> 
     <key>Path</key> 
     <string>Services</string> 
    </dict> 
</dict> 

<key>Nodes</key> 
<array> 
    <string>Services</string> 
</array> 

これは、あなたや他の人に役立つことを望みます。

#!/bin/bash -e 

# Read the settings from the project 
read -p "Project's name: " project_name 
read -p "Class prefix: " class_prefix 

# Set variables 
date="$(date +%d-%m-%Y)" 
year="$(date +%Y)" 
username="PLACE_YOUR_NAME_HERE" 
organization="PLACE_YOUR_ORGANIZATION_NAME_HERE" 

# Copy the base project template to a new folder with the projects name 
cp -r ___PACKAGENAME___/ $project_name 

# Rename files and folders to match the project name 
cd $project_name 

# Match the project name 
for file in $(find . -depth -name '*___PACKAGENAME___*') 
do 
    dir="$(dirname "$file")" 
    old="$(basename "$file")" 
    new="$(echo "$old" | sed s/___PACKAGENAME___/"$project_name"/)" 

    if [ "$new" != "$old" ]; then 
     mv "$dir"/"$old" "$dir"/"$new" 
    fi 
done 

# Add the class prefix 
for file in $(find . -depth -name '*___VARIABLE_classPrefix___*') 
do 
    dir="$(dirname "$file")" 
    old="$(basename "$file")" 
    new="$(echo "$old" | sed s/___VARIABLE_classPrefix___/"$class_prefix"/)" 

    if [ "$new" != "$old" ]; then 
     mv "$dir"/"$old" "$dir"/"$new" 
    fi 
done 

# Modify the content of the files 
for file in $(find . -depth -type f ! -name .DS_Store ! -path "*Externals/*" ! -name "*.png" ! -name "*.xcuserstate") 
do 
    filename="$(basename "$file")" 
    if [ "$filename" != '*.DS_Store*' ]; then 
     echo $filename 
     sed -e "s/___PROJECTNAME___/${project_name}/g" $file > temp 
     sed -e "s/___FULLUSERNAME___/${username}/g" temp > $file 
     sed -e "s/___DATE___/${date}/g" $file > temp 
     sed -e "s/___ORGANIZATIONNAME___/${organization}/g" temp > $file 
     sed -e "s/___YEAR___/${year}/g" $file > temp 
     sed -e "s/___PACKAGENAME___/${project_name}/g" temp > $file 
     sed -e "s/___VARIABLE_classPrefix___/${class_prefix}/g" $file > temp 
     mv temp $file 
    fi 
done 

この場合、私は:誰もが私が使用していたbashスクリプトの下に取り付けた見つけ、他のオプションサンプルプロジェクトを作成し、すべてのファイル名と内容を名前変更を試してみたいだけの場合には

最初にサンプルプロジェクトを作成した後、私は___PACKAGENAME___と呼んでいます。そのあと、スクリプト内で日付を変更できるように、ファイル内の他のフィールドを変更しました。

このコードは、2013年4月に作成されたので、前回使用してからしばらく経っていますが、今はすべてを確認し、すべてが正常かどうかを確認する時間があまりありません。しかし、他の誰かが私がGithubにすべてをアップロードするためのギャップを見つけることができると思うこの仕事の仕方に興味があるなら。

+2

これは私のために完全に空白のフォーマットされていないファイルを作成します。 – Morkrom

+0

もっと明示できますか?何を作成しようとしていますか、ソースファイルなど – crisisGriega

+0

この場合、空のグループを作成するだけです。テンプレートフォルダ内の同じファイル構造でxmlをミラーリングすることになっていますか? – Morkrom

関連する問題