tags:

views:

17

answers:

1

I want to have preprocessor definitions for each machine with Xcode, so no matter what project I open certain definitions will be there. Say in first office I want to have

#define SERVER_IP 10.20.10.20

in other office

#define SERVER_IP 192.168.10.20

etc...

So the projects are exactly same, just Xcode environment would provide those definitions to the project. Is there such possibility in Xcode?

A: 

You could just define a prefix header file and set the name of that file in the Xcode project. The contents of the prefix header file could then be different for different offices. Note however that this kind of thing is usually not a good idea - you shouldn't be embedding settings in your code - use preferences for this kind of thing.

Paul R
@Paul R: This is solely for development stage. You mean to have some header with my definitions which is not part of the Xcode project, residing somewhere in filesystem of each office and import it in `<projectname>_Prefix.pch` ?
Michael
You can put the prefix header file anywhere you like, either in the source hierarchy or outside it, whichever works better for you. It's just a normal header though, e.g. `my_local_prefix_header.h`, not a `.pch` file. You then just add `my_local_prefix_header.h` to the project and set it as the prefix header for the project (or `#include` it in a more general prefix header if you need common #defines too).
Paul R