Question

I am developing an app for iPad which is using webservices. In current version I have a constant string which is the address of the server. Each time I want to check something I just change the address (from production, freezed version of app to preproduction, version that is equal to repository). The problem is I would like to have two versions of an app on iPad, but I think as long as the bundle identifier is the same it isn't possible. What is the proper way of doing so without creating another project? Can I have "two targets" which can distribute both versions of app with the only difference being the webservice address?

This problem will escalate when application will be delivered to the client, because whenever I will deploy test version the "freezed" version will be deleted.

Should I change the bundle identifier each time I change webservice address before deploy? Or maybe there is some "automated" way of doing so?

Thanks in advance

Was it helpful?

Solution

I wouldn't rely on the bundle identifier for your service call as you will end up with many version of your API in the server that you need to maintain. What you can do is to create a new target on your project and add a Pre processor macro to your Build settings and then you reference on that macro in your code to decide which URL use.

enter image description here

Then on your code:

- (NSURL *)url {
NSString *urlString = @"your://standars.url";

#if APITEST
urlString = @"your://test.url";
#endif

return [NSURL URLWithString:urlString];

}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top