1

I need to use one of two different URLs depending on the build target. If I build on the simulator I need to use URLA, on a device URLB.

In Objective C, I used Preprocessor Macros in the .pch file for Debug mode (one for iOS simulator SDK, another for iOS SDK). But now, I use Xcode 6 and I develop in Swift.

How can I change a constant in swift based on the build target?

Kevin
  • 53,822
  • 15
  • 101
  • 132
cmii
  • 3,556
  • 8
  • 38
  • 69
  • The class prefix mentioned in that link is referring to the letters at the beginning of identifiers - e.g. the NS in NSString; AF in the AFNetworking library, etc. Nothing to do with precompiled headers, which are irrelevant to your actual problem. – Kevin Dec 03 '14 at 21:32
  • It might be easiest (possibly even necessary) to do it in the bridging header. – Kevin Dec 03 '14 at 21:36
  • I found another solution, in Builds Settings / Swift Compiler - Custom Flags / Other Swift Flags / Debug, I add -DSimulator for "Any iOS Simulator SDK", and -DDevice for "Any iOS SDK". I create Constants.swift with `#if Device ... #endif'. And it works. – cmii Dec 03 '14 at 22:02

0 Answers0