Ios Xcode 4模板,创建空组
我正在尝试创建一个xcode 4模板。除了我不能创建一个空组之外,一切都正常 我希望该项目结构: 项目名称 -模型 -控制器 -观点 -服务Ios Xcode 4模板,创建空组,ios,xcode,templates,xcode-template,Ios,Xcode,Templates,Xcode Template,我正在尝试创建一个xcode 4模板。除了我不能创建一个空组之外,一切都正常 我希望该项目结构: 项目名称 -模型 -控制器 -观点 -服务 <key>Definitions</key> <dict> <key>Views/RootViewController.h</key> <dict> <key>Group</key> <string>
<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>
定义
视图/RootViewController.h
团体
控制器
路径
RootViewController.h
目标骰子
Views/RootViewController.m
团体
控制器
路径
RootViewController.m
en.lproj/RootViewController.xib
团体
意见
路径
RootViewController.xib
en.lproj/MainWindow.xib
团体
意见
路径
MainWindow.xib
服务
团体
服务
路径
服务
目标骰子
节点
en.lproj/MainWindow.xib
视图/RootViewController.h
Views/RootViewController.m
en.lproj/RootViewController.xib
服务
视图组已创建,因为文件已添加到此文件夹
服务组也会被创建,但其中有一个名为“服务”的文件(没有扩展名)。我想我到得晚了一点,但我只是自己测试了一下。 您几乎正确无误,只需删除文件夹的组密钥。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>
在本例中,我首先创建了示例项目,并将其称为\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu PACKAGENAME
,之后我只是更改了文件中的一些其他字段,如日期,以便能够使用脚本更改它们
这段代码是在2013年4月创建的,所以我上次使用它已经有一段时间了,现在我没有那么多时间来检查和检查是否一切正常。但是,如果其他人对这项工作感兴趣,我想我将能够找到一个缺口,将所有内容上传到Github。您能更明确一点吗?您试图创建什么、源文件等。在本例中,只是创建一个空组。我们应该在模板文件夹中镜像具有相同文件结构的xml吗?我已经做了一些测试,似乎这种方法在XCode 5中不再有效,我也得到了一个空文件。但除此之外,您始终可以创建一个包含如下所述文件的组:我也看到您在那里发表了评论,但它确实有效(刚刚测试)。最后,由于其他一些限制,我停止使用模板,按照我想要的方式创建了一个示例项目,我复制了它,然后传递了一些脚本来更改变量的名称,如项目名称和文件夹。我会再给它一次,谢谢你的想法。@Vive我刚刚用我使用的脚本更新了我的评论。我希望你会觉得它有用
#!/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