How do I create a copy of my Xcode release scheme and apply a specific define for measuring release performance?

In the WWDC 15 video: Performance on iOS and watchOS, Ben Englert discusses Code Instrumentation using Swift and encourages developers to "profile the release configuration of your app...by creating a copy of your apps release scheme in xcode and define one addidtional 'define' so you can build a release version of your app with the performance instrumentation."


How do you acheive this? Also, how do you create 'defines' when creating swift only apps?


The snippet from the video below shows the usage of the 'define':


#if MEASURE_PERFORMANCE
     let startTime = CFAbsoluteTimeGetCurrent()
#endif
Accepted Answer

Ok, I think I've answered my own question.


Steps:


  1. Add a new build configuration at project level, duplicate 'Release' configuration, call it Release{XYX}
  2. Add a specified Swift Compiler - Custom Flags -> Other Swift Flags command line flag i.e. -DMEASURE_PERFORMANCE to the new release configuration in (1)
  3. Duplicate your app target(s) scheme and choose your new build configuration (1) under the Profile item list
  4. Add your Swift command line flag to your code where you specifically want code to be executed when profiling the new copy of your release build configuration

I hope this helps others whom may have the same questions.

How do I create a copy of my Xcode release scheme and apply a specific define for measuring release performance?
 
 
Q