All of the company's projects using multiple target in a project code to generate multiple app-side, before the project has not been used, asked a few friends to hit the vest bag friends, also did not have more target to do, so their own test finishing the whole process of the next target generation, as far as possible, Daniel do not spray, Small white mutual encouragement.
1. Add multiple target
For example, in the project configuration targets, select the target target you want to copy, right-select duplicate, and a target named * copy name will appear.
Such as
Select Duplicate only, appear as Moretarget copy
Modify Moretarget copy for the name we need, I change it here to Moretarget flagship. Next, select the upper left corner as
Click Manage schemes go in to modify Moretargets copy for Moretargets Flagship, pay attention to modify the selected Moretargets copy, click on it, a little later click to edit the changes.
If you change your name, remember to check shared, then close.
Then, because we use cocopod in our project, we can use pods for two target, we add fields to the left podfile of the project.
Target ' moretargets flagship ' do
End
Command+s after saving, with terminal pod install.
The end result we click on Project--moretargets--info, as shown,
is equal to our new Target,moretarget flagship binding the corresponding debug and release environment. Please note that the new Moretargets flagship corresponding to the Plist file Moretargets copy-info.plist appears on the left frameworks of our project, and we click Modify for our moretargets flagship corresponding name, such as
Then we click Targets--moretargets Flagship--general--identify, click to select the Plist file we just modified, such as SELECT.
2. Next, we configure two target different app name, and different bundleidentifier. For example, we will change the Moretargets flagship Bundelid to Com.targetqijian.www.MoreTargets,
At this point, you choose to run a different targe, which will be installed on the simulator as two different apps.
3. Then we modify different target different appicon and lanuchimage, respectively, dragged into the corresponding picture, such as
After we click Run, desktop such as two apps, one is Moretargets application, one is moretargets flagship application, such as
Finally, after you add the file, according to your needs to add to the corresponding target can be. But how do you differentiate between two target in code? We can add a precompiled macro to resolve. Target->build Setting, search: Preprocessor Macros, set the pre-compiled macro content in debug and release, such as Qijian=1 for a target version (note = front and back cannot be right space, There are spaces to compile, however, in the program the different versions of the judgment, such as
Finally, finished. Two different target share the same code, the subsequent packaging can be configured according to the needs of different developer accounts.
Implement an iOS project by adding multiple target and making a waistcoat pack.