Add multiple target to project

Source: Internet
Author: User

In iOS development, we may encounter this situation: Some features, some SDK only when debugging, such as using Fbmoryprofiler for memory detection, using the third-party SDK to collect the crash log and so on. Integrating these functions and SDKs into the entire project can result in a bloated project or even a appstore audit. At this time, we can use multiple target, the user does not need the functional part of the target only for development purposes.

First, create multiple target (two ways)

Mode one: Copy a target exactly the same as the current target

Right-click the current target---Duplicate, which will generate a xxx copy of the Target,resource will also generate a XXX copy.plist properties file, this new target and the original target is exactly the same.

Way two: Create a brand new target

1, click on the "+" number below the target list, first will let you choose the target type, since I always refer to the program itself, then the natural Choice application (as for the others, interested in their own research, For example, we can extract parts of the program into a static Library).

2, Next, will let you enter a new target name, rather than the Copy method, the default generation xxxxx copy such as the target name.

3. However, the target generated is almost empty. Copy Bundle Resources, Compile Sources, Link Binary with libraries there is nothing inside. The compilation settings are also in the completely original state.

4. You can complete the target configuration by dragging and dropping the contents to these target settings and adjusting the compilation options.

 

II. Custom Conditional Compilation macros

When the new target is created, we tend to want to compile the different target differently, then we need to use conditional editing.

1. Add custom conditional compilation macros

Select new target---build setting. Preprocessor Macros found under Apple llvm7.1-preprocessing, double-click to add a custom variable (such as: DEVELOPER)

  

You can use conditional compilation at this time:

  

#ifdef     DEVELOPER    code#endif

Third, add the SDK and source files that need to be used in the new target into the new target.

When you add a third-party framework using Cocoapods, you may have a compile-time link error due to configuration changes, just select None in the configuration, and then restart the pod install

Add multiple target to 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.