Home > Development > Multiple developers, one iPhone app

Multiple developers, one iPhone app

February 10th, 2010

I am working on an iPhone project with seven other iPhone developers, and we all have individual development certficates (the project did not require a group certificate, and we all had ours already).

Since one has to sign code to run outside the simulator, we all edited the Info.plist’s Bundle Identifier to match our certificates (mine was com.casgrain, as you can guess).

This leads to a permanently-modified file in your local copy of the source repository, one that you have to ensure you do not commit. It’s not very neat, and it is error-prone. And if you want to genuinely modifiy the plist, you must discard your changes, do the modification, commit and re-do your changes. Not pleasant.

I wanted to use plist pre-processing to solve this issue, since it will replace environemnt variables in the plist before using it, for instance to sign code.

The goal is to replace this:

	CFBundleIdentifier
	com.myCompany.${PRODUCT_NAME:rfc1034identifier}

with this:

	CFBundleIdentifier
	${DEVELOPER_DOMAIN}.${PRODUCT_NAME:rfc1034identifier}

Pre-processing supports environment variables, but not any environment variable. If you define a variable in ~/.profile (if you use bash or a bash-compatible shell), this does not work.
You have to define the variable in ~/.MacOSX/environment.plist, a special plist that is read at login time.

To define this variable, follow these three simple tasks in Terminal. You only need to do them once.

  1. Create the `/MacOSX folder if it does not exist. If it is already present, this is harmless
    	mkdir ~/.MacOSX
    
  2. Add the environment variable
    	defaults write ~/.MacOSX/environment DEVELOPER_DOMAIN -string "com.yourdomain"
    
  3. Ensure that the plist is human-readable and not compressed XML, in case you want to edit it later with a text editor
    	plutil -convert xml1 ~/.MacOSX/environment.plist
    

You will need to log out and back in for those changes to take effect.

Now, do the repkacement above in your Info.plist, substituting “${DEVELOPER_DOMAIN}” for “com.myCompany” or whatever the reverse-domain was for your project.

With this modification, you should now be able to build for the device without changing the plist every time.

Categories: Development Tags:
  1. February 10th, 2010 at 09:29 | #1

    Or, you could use RCEnvironment: http://www.rubicode.com/Software/RCEnvironment/

  2. February 10th, 2010 at 20:02 | #2

    Nice, but that only solves the problem of editing environment.plist. And is “defaults write” (or “defaults read”) so hard?

    The main point of this post is to show how to get arbitrary environment variables in the Xcode build process.

Comments are closed.