Search code examples
iosconfigurationxcode6settings

In iOS - Production and staging server included in single build


I have an application having two servers STAGING and PRODUCTION. I used to release two builds with changing the servers in coding part. But now my client asked to provide a single build where we can provide an option in app settings or phone settings to chnage the URL.

I reserached a lot in stack overflow and came to know that at runtime when we select debug/release mode at the time of giving build, it can be possible but anyways it is also come under process of giving two builds.

I want to have a single build where the user can change the option of Staging/Producetion. Please help me. Is it possible. ?


Solution

  • You can just add a switch somewhere in your application to turn on staging mode (switch off = production). The state of this switch is saved in NSUserDefaults. Then, depending to this state, you choose the right URL of server in your code.