Reputation: 1165
I'm working on an iPhone app which connects to several services via REST API.
There are some servers for each service(development, production, etc), and I want to switch these servers to connect by compiler flags WITHOUT modifying foo.xcodeproj/project.pbxproj.
I'm in a team of 6 developers and each person wants to connect to different servers combination, but it will be a mess if I include these configuration in project.pbxproj which is managed by git.
So I need to change compiler flags with a file which is not managed by git.
Ideally, I want local settings mechanism like in Django. Is there any ways to do this with Xcode?
Thanks! Any advice is highly appreciated.
Upvotes: 1
Views: 2668
Reputation: 4533
Having your compiler flags not under source control is a huge RED FLAG. How can you guarantee consistent building of your app. // End Soap Box
Answer
I would create a user defined build setting for the production and dev servers. And a run script to set the server to use in the application info.plist
# ---------------------------- IMPORTANT ----------------------------
# You must set RESTServer to something like 'Set by build script' in the file
# file '<Project Name>-Info.plist' in the 'Supporting Files' group
# -------------------------------------------------------------------
#
# determin server based on user name
#
SERVER=${REST_Server}
# Only use developer servers for debug never for release
if [ "$CONFIGURATION" != "Debug" ] ; then
exit
fi
if [ "$USER" == "gdunham" ] ; then
SERVER="gld.nextbigthing.com"
fi
if [ "$USER" == "jashmun" ] ; then
SERVER="jda.nextbigthing.com"
fi
echo $SERVER
#
# Set the server info in plist file in the build product not the source tree
#
/usr/libexec/PlistBuddy -c "Set :RESTServer $SERVER" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
For all the gory details see my demo project on GitHub https://github.com/GayleDDS/DemoMultiDeveloper
Upvotes: 2
Reputation: 2963
You can use the build configuration (.xcconfig)files to create different combinations of servers. Here is good explanation for how to configure this for your project: How can I use .xcconfig files in Xcode 4?
Each user can have their own .xcconfig file(s) and you can add these .xcconfig files to .gitignore
Upvotes: 1