0

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

patryk
  • 642
  • 1
  • 9
  • 18

1 Answers1

1

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];

}

cescofry
  • 3,706
  • 3
  • 26
  • 22
  • thanks for reply, but i'm not aware if this is the right choice for me. Can user have two versions on a device at one moment? – patryk Aug 19 '13 at 11:11
  • 1
    not, for that you definitely need to change the bundle id, and in order to set that you may want to go with adding a different target. Keep in mind thought that it could become cumbersome keep the 2 versions in sync. – cescofry Aug 19 '13 at 11:57
  • I'm accepting your answer but I need to add that I duplicated target, changed the bundle id, set proper bundle name and used your preprocessor macros to set appropriate server address :-) now I'm having two apps in simulator/device. Keeping the versions of preproduction and production app isn't that hard because I use git repositories to track code changes (and also, the backend have that same model, two servers). – patryk Aug 22 '13 at 08:03