• Requirement: one set of code can be made into multiple apps, with different ICONS, startup pictures, names, etc. Or a project may have different environments, different environments install different dependency libraries or access different servers, or execute different code logic, etc.

General process:

1. Create a Target or copy a Target from the current project Target. Modify Target and Scheme configurations. 3. Configure info.plist. 5. Assets. Xcassets (app picture, launch page)

1. Create Target(Command + D)

2. A new target is generated based on the original target and a new plist file is generated. The location of the plist file is in the project’s home directory. If it doesn’t fit, you can move it to a folder and import it into the project.

3. Change the target and Scheme names.

4. Change the path of the plist file referenced by target.

5. Add the project configuration

6. The definition (Build Setting — >Preprocessor Macros) is mainly used to distinguish the different styles or logic displayed in different environments or apps. Global macros are valid in all/entire project code. There are several targets set and several macro definitions used in code to distinguish the currently selected target from the project or environment.

  • Introduce different headers or handle different logic depending on the target macro

7. Create a resource file for the target.

  • Select the target to which you want to add the resource file. After creating a good directly in the inside to add icon start diagram, can be used normally.

  • The target selected in the initial resource file is changed to the first one. After a new target is created, the initial resource file will be selected by default. If a target is selected in the initial resource file, the Settings in the new resource file will not be displayed correctly.

  • Icon display is normal

Other: If you only want to differentiate environments, you can directly add configurations as follows. Setting macros to differentiate environments is easier.