> On Jan 16, 2011, at 7:59 AM, Ken Thomases wrote: >> I've got an Xcode project that compiles and works fine. >> >> The short question now is: what is the proper way to change the bundle's >> name from the command line? > > Assuming your project is set up like normal (e.g. with Info.plist values > based on build settings), it may be as simple as: > > xcodebuild -target Foo -configuration Release build PRODUCT_NAME=Foo2
Thanks a lot for your response. Unfortunately, it doesn't seem to be quite as simple as that. The executable I am working on is a screen saver. My Info.plist looks like this: <key>CFBundleName</key> <string>${PRODUCT_NAME}</string> <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleIdentifier</key> <string>de.zach.${PRODUCT_NAME:rfc1034identifier}</string> In the final packages, the variables are correctly replaced by the correct executable names, i.e., "Foo" and "Foo2". However, when I run the screen savers (in System Preferences), the name of my screen saver, i.e., the value of CFBundleName is the same, whichever screen saver I use. It happens to be the one of the screen saver that got started first in SystemPreferences. And since I base the name of the preferences file on the bundle name, both screensavers Foo and Foo2 use the same preferences file. Here is how I load the bundle and determine the name of the screen saver running: NSBundle * bundle = [NSBundle bundleForClass:[self class]]; exec_name_ = [[bundle infoDictionary] objectForKey:@"CFBundleName"]; I tried NSBundle * bundle = [NSBundle mainBundle]; but that loads the bundle of SystemPreferences! I was considering to use [NSBundle bundleWithIdentifier: @"de.zach.Foo"] but I can't hard-code the identifier, since I don't know which screensaver it will be. Is there something like preprocessor macro expansion in Obj-C? Something like @"de.zach." ## PRODUCT_NAME (that is C++ syntax, where PRODUCT_NAME is a preprocessor token, which can be set on the command line of gcc). Does anyone know how to do this properly? Thanks a lot in advance. Best regards, Gabriel.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com