iOS: Simple way to manage REST end points

后端 未结 4 1153
既然无缘
既然无缘 2021-01-24 07:28

Our REST based application can be used for testing on multiple internal environments each with a different REST end point. Is there a simple way to set up environment level co

4条回答
  •  情歌与酒
    2021-01-24 08:04

    As Zac Kwan suggested, you can use different schemes to accomplish this, but you don't necessarily have to create a different configuration as well. Each scheme can specify unique environment variables. Then, access them from Swift:

    let prodURL = "http://api.com"
    let baseURL = ProcessInfo.processInfo.environment["BASE_URL"] ?? prodURL
    

提交回复
热议问题