Reputation: 141
I would like to implement configs dependent on environment in my iOS project and I'm thinking how should I do this. Things to cover that come to my mind:
I wouldn't want to change it every time I deploy to production.
So I found two ways:
Where to set environmental variables in iOS? But it's an old thread and kinda non-friendly.
https://collectiveidea.com/blog/archives/2014/10/01/simple-cocoa-configuration-using-swift-structures Which looks very clean to use inside the code project but I think it's not possible to implement this inside Info.plist, or is it? And is it possible to include struct dev extension file only in development environment (so it won't load on production)? I would like to have it in the git repository so I don't have to manually send it to other developers.
Also, where should I put the "environment switch"? Is there some fancy way to place it inside the project (but in the way that does not affect production) or I have to add add it to "Edit scheme > environment variables"?
Would appreciate any help with that :)
Upvotes: 2
Views: 1958
Reputation: 661
I think you want to create a separate development environment and production environment in Xcode. Set variables separately for both development environment and production environment.
You can manage this in Xcode elegantly by creating two separate targets, one for development and another for production.
I have not explained thoroughly in this answer, because app coda has a very nice tutorial on how to manage development and production build. Please go to this tutorial by App Coda, and follow the steps as mentioned in the turorial. Hope it helps.
Upvotes: 2