Using Xcode (to develop on iOS) I want to create a second project that it is the same as a first project but some classes are differents.
使用Xcode(在iOS上开发)我想创建第二个项目,它与第一个项目相同,但有些类是不同的。
Exactly, I'm creating an IPhone App and I want to offer a free version and a premium version. Actually, the code of the projects are identical but changes some classes.
确切地说,我正在创建一个iPhone应用程序,我想提供免费版和高级版。实际上,项目的代码是相同的,但改变了一些类。
The problem is I don't want support two projects. If I modify a class, then I have to modify the same change on the other project. It is very redundant.
问题是我不想支持两个项目。如果我修改了一个类,那么我必须在另一个项目上修改相同的更改。这是非常多余的。
Besides, the project are pushed to a remote GIT respository.
此外,该项目被推送到远程GIT存储库。
And one last note, an iOS App is identify using an ID associated with the project.
最后一点,iOS应用程序使用与项目关联的ID进行识别。
So, I need two differents projects?
那么,我需要两个不同的项目?
Which is the best solution to create two iOS App projects in Xcode sharing the classes, but changing two o three classes?
哪个是在Xcode*享类的两个iOS App项目的最佳解决方案,但改变两个三类?
Thanks
3 个解决方案
#1
17
I want to offer a free version and a premium version.
我想提供免费版和高级版。
In this case, you do not need to create two apps in two projects: all you need is a second target for your premium version. Here is a link that explains how to create and manage multiple targets in Xcode.
在这种情况下,您不需要在两个项目中创建两个应用程序:您需要的只是高级版本的第二个目标。这是一个链接,解释了如何在Xcode中创建和管理多个目标。
The process boils down to adding a target to the project, defining a separate properties plist for it, optionally setting up a preprocessor symbol for conditional compile, and using that symbol to #ifdef
portions of your classes not needed in the free version.
该过程归结为向项目添加目标,为其定义单独的属性plist,可选地为条件编译设置预处理器符号,并使用该符号#ifdef免费版本中不需要的类的部分。
Another common approach to managing free vs. premium offering is to provide a single version for free, and let users upgrade it to premium through an in-app purchase.
管理免费和高级产品的另一种常见方法是免费提供单个版本,并允许用户通过应用内购买将其升级到高级版。
#2
6
You just have to create two targets. So you'll only modify a single code base, perfect!
你只需要创建两个目标。因此,您只需修改一个代码库,完美!
This tutorial will walk you through (and even uses lite/paid versions as it's example).
本教程将引导您完成(甚至使用lite /付费版本作为示例)。
#3
0
-
duplicate target of paid version and name it free version
付费版本的重复目标,并将其命名为免费版本
-
define macro name
PaidApp=1
in paid target, then put this line of code in starting of applicationDidfinishLaunching.在付费目标中定义宏名称PaidApp = 1,然后将此行代码放在applicationDidfinishLaunching的开头。
#ifdef PaidApp [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"adDisabled"]; #endif
-
when free app running target, if someone purchase paid app feature then set value of @"adDisabled" to 1 (by default value of @"adDisabled" will be 0)
当免费应用程序运行目标时,如果有人购买付费应用程序功能,则将@“adDisabled”的值设置为1(默认值为@“adDisabled”将为0)
#1
17
I want to offer a free version and a premium version.
我想提供免费版和高级版。
In this case, you do not need to create two apps in two projects: all you need is a second target for your premium version. Here is a link that explains how to create and manage multiple targets in Xcode.
在这种情况下,您不需要在两个项目中创建两个应用程序:您需要的只是高级版本的第二个目标。这是一个链接,解释了如何在Xcode中创建和管理多个目标。
The process boils down to adding a target to the project, defining a separate properties plist for it, optionally setting up a preprocessor symbol for conditional compile, and using that symbol to #ifdef
portions of your classes not needed in the free version.
该过程归结为向项目添加目标,为其定义单独的属性plist,可选地为条件编译设置预处理器符号,并使用该符号#ifdef免费版本中不需要的类的部分。
Another common approach to managing free vs. premium offering is to provide a single version for free, and let users upgrade it to premium through an in-app purchase.
管理免费和高级产品的另一种常见方法是免费提供单个版本,并允许用户通过应用内购买将其升级到高级版。
#2
6
You just have to create two targets. So you'll only modify a single code base, perfect!
你只需要创建两个目标。因此,您只需修改一个代码库,完美!
This tutorial will walk you through (and even uses lite/paid versions as it's example).
本教程将引导您完成(甚至使用lite /付费版本作为示例)。
#3
0
-
duplicate target of paid version and name it free version
付费版本的重复目标,并将其命名为免费版本
-
define macro name
PaidApp=1
in paid target, then put this line of code in starting of applicationDidfinishLaunching.在付费目标中定义宏名称PaidApp = 1,然后将此行代码放在applicationDidfinishLaunching的开头。
#ifdef PaidApp [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"adDisabled"]; #endif
-
when free app running target, if someone purchase paid app feature then set value of @"adDisabled" to 1 (by default value of @"adDisabled" will be 0)
当免费应用程序运行目标时,如果有人购买付费应用程序功能,则将@“adDisabled”的值设置为1(默认值为@“adDisabled”将为0)