ios - Xcode building different environments for the same app -


i have app talks server. have 2 versions of server: production 1 , testing one. means i'd need have production ios app , testing ios app. logic same both versions of app, except need use configurations depending on server connects to. right now, solution use plist file contains informations 2 versions need. plist contain bunch of key-value pairs like:

url: test-server.domain.com username: test-subject password: test-password 

i have 2 git branches: production branch , testing branch each of ios app version. content of said plist file different on each branch.

question is: there more elegant way solve this? preferably i'd have 1 branch. i've looked using xcode's environment variables, don't stick when archive/build apps.

i use preprocessor macros this.

define variable debug debug , nothing in release.

enter image description here

and use like

enum appconfig {     case debug     case testflight     case appstore      var host: string {         switch self {             case .debug: return "test host"             default: return "production host"         }     }      static var current: appconfiguration {         #if debug             return .debug         #else             if bundle.main.appstorereceipturl?.lastpathcomponent == "sandboxreceipt" {                 return .testflight             } else {                 return .appstore             }         #endif     } } 

wherever want use host, can use appconfig.current.host. thing need create scheme debug , release.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -