Xcode项目模板与方案

问题描述 投票:6回答:2

我想为Xcode 9创建一个具有预定义方案和构建配置的项目模板?

我想有一个模板,其中包含以下方案和相应的构建配置:

  • 具有“Dev Debug”和“Dev Release”构建配置的“Dev”方案
  • “集成”方案与“集成调试”和“集成发布”构建配置
  • 具有“生产调试”和“生产发布”构建配置的“生产”方案

这样的事情可能吗?任何人都有这个成功吗?有一篇关于创建Xcode模板的好文章,但它没有描述如何使用预定义的方案创建模板:https://www.telerik.com/blogs/how-to-create-custom-project-templates-in-xcode-7

任何帮助将不胜感激,Thx :)

ios xcode templates
2个回答
0
投票

您需要在模板中指定下一个键:

<key>Targets</key>
<array>
    <dict>
        <key>Name</key>
        <string>Dev</string>
        <key>Configurations</key>
        <dict>
            <key>Debug</key>
            <dict/>
            <key>Release</key>
            <dict/>
        </dict>
    </dict>
    <dict>
        <key>Name</key>
        <string>Integration</string>
        <key>Configurations</key>
        <dict>
            <key>Debug</key>
            <dict/>
            <key>Release</key>
            <dict/>
        </dict>
    </dict>
    <dict>
        <key>Name</key>
        <string>Production</string>
        <key>Configurations</key>
        <dict>
            <key>Debug</key>
            <dict/>
            <key>Release</key>
            <dict/>
        </dict>
    </dict>
</array>

有关更多详细信息,请参阅this文档。


0
投票

为什么不创建不同的方案并具有单独的配置文件,

得到你的xcode - >你的项目 - >信息标签,如下面的截图所示

enter image description here

单击加号按钮,如图所示,您将弹出一个问题

enter image description here

选择“重复调试配置”并将其命名为“暂存”。

现在转到您的“TARGETS” - >选择您的应用程序(DemoApp) - > BuildSettings点击右上角的小加号图标如下

enter image description here

并单击“添加用户自定义设置”

在这里,您可以定义您可能需要区别的自定义不同变量,例如:BASE_URL,如下所示

enter image description here

现在您可以创建一个新的Scheme“Staging”并使用Run - > Info - > Build Configuration中的配置,如下所示

enter image description here

以类似的方式,您可以拥有所需的不同方案和不同的配置文件。

© www.soinside.com 2019 - 2024. All rights reserved.