我正在尝试创建一个 xcode 4 模板。除了我无法创建空组之外,一切工作正常。
我想要这个项目结构:
项目名
-楷模
-控制器
- 景观
-服务
<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>
视图组被创建,因为文件被添加到此文件夹中。
服务组也会被创建,但其中有一个名为“服务”的文件(没有扩展名)。
我想我来得有点晚了,但我刚刚得到了自己测试的答案。
您几乎是正确的,您只需要删除文件夹的组密钥即可。 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>
就是这样,我希望它能帮助你或其他人。
以防万一有人想尝试其他选项创建一个示例项目,然后重命名所有文件名和内容,请在我使用的 bash 脚本下面找到附件:
#!/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
在本例中,我首先创建了示例项目,并将其命名为___PACKAGENAME___
之后,我只是更改了文件中的一些其他字段(例如日期),以便能够使用脚本更改它们。
该代码是在 2013 年 4 月创建的,所以自从我上次使用它以来已经有一段时间了,现在我没有那么多时间来审查和检查是否一切正常。但如果其他人对这个工作原理感兴趣,我想我将能够找到一个缺口将所有内容上传到 Github。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)