IOS same project, create multiple target, package different versions of the project

Source: Internet
Author: User

There are two ways to create a new target:

First: By creating a new Target (file--> new-->target)

1. Xcode creates a new project Targetdemo:

2. Create a new target:file--> New-->target:

The targetdemotwo folder appears when you are finished creating:

3, if two target uses the same appdelegate words, can put targetdemotwo appdelegate Delete, if not use the same appdelegate, You can change the name or modify the name to inherit the first target of the appdelegate, if you inherit the target appdelegate, you need to select the first target APPDELEGATE.M, in the right column to select two target,

4. Two target associated:

For example, two target uses the same viewcontroller, but the view background color is different in two target;

First remove the ViewController.h and. M and Main.storyboard in the Targetdemotwo folder

Then select APPDELEGATE.M and VIEWCONTROLLER.M in the first target, and in the right column, select two target in target membership as shown:

Then distinguish between two target, check targetdemotwo, check build Setting, search macro, set the label.

Select a different target, in the Viewcontroller code settings to differentiate, run Targetdemotwo as shown:

The second type: by duplicate the original target, copy a

1. Select the target you want to copy, right-click on duplicate, Targetdemo copy and plist:

Modify Targetdemo Copy name, directly select Targetdemo Copy to modify the name, the target name of the running window is not modified successfully, select the window running target, check the Manage schemes, check Enter to modify the name, as shown in:

2, after the successful modification, modify the corresponding plist file, modify the Targetdemothree-info.plist, select the corresponding target, select General, click Choose Info.plist File ..., Select the corresponding targetdemothree-info.plist, and configure the plist file as shown in:

3. Modify the representation of this target as shown in the following example:

4, the associated file with the first method, code differences, run Targetdemothree, as shown:

Pictures and other resource files some third party libraries can also be associated with the same method, and if the target version does not require resources or a third-party library can be unrelated, the packaged IPA will also be relatively reduced;

Three target run results, such as:

Reference resources: http://blog.csdn.net/asong_ge/article/details/54931874

IOS same project, create multiple target, package different versions of the project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.