I have a Swift iOS project that connects to a server using HTTP. There are two servers, one for development and one for production. When I edit and test my app in Xcode, I want it to connect to the development server. Then when the code is ready, I use the following commands to build the IPA for release:
xcodebuild archive -scheme MyApp -archivePath ~/Archive/MyApp
xcodebuild -exportArchive -archivePath ~/Archive/MyApp.xcarchive -exportPath ~/IPA/MyApp -exportFormat ipa -exportProvisioningProfile "My Provisioning Profile"
and I want this release IPA to connect to the production server. So what's the best way to do this?
Swift Compiler - Custom Flags > Other Swift Flags
sectionDebug
this entry: -D DEBUGThen write this in your code
#if DEBUG
let server = "http://www.yourserver.com/debug/"
#else
let server = "http://www.yourserver.com/production/"
#endif