Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically use different constant for development

Tags:

xcode

ios

My iOS App uses a specific server for production: http://mydomain.com/serverapi. While developing I would like to change this to http://localhost/serverapi. What is an elegant way to tell XCode to use the local URL by default.

Obviously it's very important, that a production release contains the production URL (Archiving in XCode.

Another use case would be to change the icon or app identifier while in development, to be able to tell the app apart from the version which might already be installed on the device.

like image 286
Besi Avatar asked Dec 27 '22 14:12

Besi


1 Answers

I use macros for this (as Pablo suggested), but if you have a separate Info.plist file for different build configurations (as I do), then you could have a custom entry in your Info.plist and access it like so:

 [[[NSBundle mainBundle] infoDictionary] objectForKey:@"MyAppURL"]

However, macros are likely faster at runtime as they are compiled in. This is just another option.

Below is an image of the project setting.

enter image description here

like image 185
Ben Mosher Avatar answered Feb 16 '23 12:02

Ben Mosher