Friday, March 2, 2018

Xcode project templates with schemes

Leave a Comment

I would like to create a project template for Xcode 9 which have predefined schemes and build configurations?

I would like to have a template with the following schemes and corresponding build configurations:

  • "Dev" scheme with "Dev Debug" & "Dev Release" build configuration
  • "Integration" scheme with "Integration Debug" & "Integration Release" build configuration
  • "Production" scheme with "Production Debug" & "Production Release" build configuration

Is something like this possible? Anyone has had success with this? There is a good article about creating Xcode templates, but It does not describe how to create templates with predefined schemes: https://www.telerik.com/blogs/how-to-create-custom-project-templates-in-xcode-7

Any help would be appreciated, Thx :)

2 Answers

Answers 1

Why dont you create different schemes and have separate config files ,

Got to your xcode -> your Project -> info tab as shown in the below screenshot

enter image description here

Click on the plus button as shown in the image you would get a pop up asking

enter image description here

select Duplicate Debug Configuration and name yours as Staging.

Now go to your "TARGETS" -> Select your App (DemoApp) -> BuildSettings click on the small plus icon on top rightish corner as below

enter image description here

and click "ADD USER-DEFINED Setting"

Here you can define your custom different variables that you may need to differ eg: BASE_URL like below

enter image description here

Now you can just create a new Scheme "Staging" and use the configuration in the Run -> Info -> Build Configuration as shown below

enter image description here

In a similar manner you can have the different schemes and different configuration files that you need.

Answers 2

You need to specify next key in template:

<key>Targets</key> <array>     <dict>         <key>Name</key>         <string>Dev</string>         <key>Configurations</key>         <dict>             <key>Debug</key>             <dict/>             <key>Release</key>             <dict/>         </dict>     </dict>     <dict>         <key>Name</key>         <string>Integration</string>         <key>Configurations</key>         <dict>             <key>Debug</key>             <dict/>             <key>Release</key>             <dict/>         </dict>     </dict>     <dict>         <key>Name</key>         <string>Production</string>         <key>Configurations</key>         <dict>             <key>Debug</key>             <dict/>             <key>Release</key>             <dict/>         </dict>     </dict> </array> 

Refer to this documentation for further details.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment