xcode 如何使用具有不同应用程序名称和 info.plist 的相同源创建两个项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5661167/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I create two projects, using the same source with a different App Name and info.plist?
提问by ingham
Actually, my iOS App contains multiples version in the same project, changed with a #define
in a Static
Class.
实际上,我的 iOS 应用程序在同一个项目中包含多个版本,#define
在一个Static
类中更改了一个。
Example:
例子:
#import "AppVersion.h"
//...
if (MYAPP_VERSION == kMyAppVersionFree) {
//Limited features
}
else if (MYAPP_VERSION == kMyAppVersionFull) {
//No limit !
}
Each time I want to compile, I have to edit my code to change the #define
MYAPP_VERSION
, and change the project name, to be able to release a MyApp
and "MyApp Free" executables...
每次我想编译时,我都必须编辑我的代码来更改#define
MYAPP_VERSION
,并更改项目名称,以便能够发布一个MyApp
和“MyApp Free”的可执行文件......
Is it possible to define this as a "compilation variable"? I don't want to have to edit my code each time I want to compile 2 versions
是否可以将其定义为“编译变量”?我不想每次要编译 2 个版本时都必须编辑我的代码
How can I create 2 projects, using exactly the same source (many classes) but with a different App Name and a different info.plist
(and, relative to previous question, different "compilation variables")?
如何创建 2 个项目,使用完全相同的源(许多类)但具有不同的应用程序名称和不同的info.plist
(并且,相对于上一个问题,不同的“编译变量”)?
I'm asking for a different info.plist
because my "Free version" doesn't support iTunes file sharing, but my "Full version" does...
我要求不同,info.plist
因为我的“免费版”不支持 iTunes 文件共享,但我的“完整版”支持...
Any idea? How do you manage versions in your projects?
任何的想法?您如何管理项目中的版本?
回答by RedBlueThing
You need to define targets for your various versions.
您需要为各种版本定义目标。
Click on the root of your project (the blue xcode icon). You will see your project settings in a table. On the left hand side you will see a "TARGETS" heading, with one child, the name of your project.
单击项目的根目录(蓝色 xcode 图标)。您将在表格中看到您的项目设置。在左侧,您将看到一个“TARGETS”标题,其中有一个孩子,是您的项目名称。
You can right click the target and duplicate it. Once you have a duplicate, you can rename it and then configure it's settings separately. One of the project settings are the GCC Preprocessor values. You can define LITE or FULL variables based on your target and then use #ifdefs in your code to do conditional compilation.
您可以右键单击目标并复制它。一旦你有一个副本,你可以重命名它,然后单独配置它的设置。项目设置之一是 GCC 预处理器值。您可以根据目标定义 LITE 或 FULL 变量,然后在代码中使用 #ifdefs 进行条件编译。
You can add different pList files for different targets. Just right click on the pList files and include or exclude the files for each target.
您可以为不同的目标添加不同的 pList 文件。只需右键单击 pList 文件并包含或排除每个目标的文件。