Change API host using Bundle

We can change the API Host depending on develop and release environment using bundle.

Set API Host value to Build Setting

Select Build setting tab and Add APIHost to User-Defined Setting.

This is an image

Make Info.plist to referable to Build Setting

Configure the value that refers to the API Host.

This is an image

Retrieve value from Info.plist

Retrieve value of APIHost according to the environment.

 let apiHost = Bundle.main.object(forInfoDictionaryKey: "APIHost") as! String
  • このエントリーをはてなブックマークに追加