加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – Xcode 4模板,创建空组

发布时间:2020-12-14 17:20:38 所属栏目:百科 来源:网络整理
导读:我正在尝试创建一个 xcode 4模板.一切都很好,除了我不能创建一个空组. 我想有这个项目结构: 项目名 -楷模 -Controllers -views -服务 keyDefinitions/keydict keyViews/RootViewController.h/key dict keyGroup/key stringControllers/string keyPath/key s
我正在尝试创建一个 xcode 4模板.一切都很好,除了我不能创建一个空组.

我想有这个项目结构:
项目名
-楷模
-Controllers
-views
-服务

<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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读