Xcode 4模板,创建空组 [英] Xcode 4 template, create empty group

查看:118
本文介绍了Xcode 4模板,创建空组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个xcode 4模板。一切正常,除了我不能创建一个空组。

I'm trying to create a xcode 4 template. Everything works fine except for the fact that I can't create an empty group.

我想有这个项目结构:
ProjectName
-Models
-Controllers
-Views
-Services

I would like to have this project structure: ProjectName -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>

视图组已创建,因为文件已添加到此文件夹中。

The Views group gets created, because files get added to this folder.

服务组也已创建,但其中有一个名为服务的文件(没有扩展名)。

The Services group also gets created but there is a file called 'Services' in it (without an extension).

推荐答案

我想我迟到了,但我得到的答案是我自己测试的。
你几乎是正确的,你只需要删除文件夹的组密钥。 XCode将自己创建组。例如,仅服务的代码将如下所示:

I suppose I arrive a little bit late but I just got the answer testing it on my own. You have it almost correct, you only need to delete the group key for the folders. XCode will create the groups on its own. For example the code for only Services will be like this:

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

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

就是这样,我希望它会帮助你或其他任何人。

That's it, I hope it will help you or anybody else.

万一有人想尝试创建示例项目的另一个选项然后重命名所有文件名和内容,请在我正在使用的bash脚本下面找到附件:

Just in case anybody wants to try the other option creating a sample project and then renaming all the file names and content, find attached below the bash script I was using:

#!/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

在此case,我首先创建了示例项目,然后我将其称为 ___ PACKAGENAME ___ 之后,我刚刚更改了文件中的一些其他字段,如日期,以便能够更改它们脚本。

In this case, I created first the sample project and I call it ___PACKAGENAME___ after that I just changed some other fields inside the files like the date in order to be able to change them with the script.

此代码创建于2013年4月,因为自上次使用它以来已经有一段时间了,现在我没有那么多时间来审核检查一切是否正常。但是,如果其他人对这项工作感兴趣,我想我将能够找到差距将所有内容上传到Github。

This code was created at April 2013 so it's been a while since the last time I used it and right now I don't have so much time to review and check if everything is ok. But if anybody else is interested in how this work I guess I will be able to find a gap to upload everything to Github.

这篇关于Xcode 4模板,创建空组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆