• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to change the product name with command line builds?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to change the product name with command line builds?


  • Subject: How to change the product name with command line builds?
  • From: Gabriel Zachmann <email@hidden>
  • Date: Fri, 14 Jan 2011 14:55:25 +0100

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?
(and, at the same time, its executable name)

A little bit of background information might be in order.
I am writing a screensaver.
Now some users would like to run two different instances (i.e., executables) of it concurrently, because they've got two monitors, and, in addition, they want to set different preferences for each instance.

So, my idea was to just compile the program twice, once under the name Foo and once under the name Foo2.
In the code, I always refer to
  [[bundle infoDictionary] objectForKey:@"CFBundleName"]
and I save the preferences basically like this:
  [ScreenSaverDefaults defaultsForModuleWithName: bundle_name]

My idea was to write a shell script that compiles the program, then changes the bundle name to Foo2 in Info.plist, and then compiles it again.

But: is that the proper way of doing it? Am I missing anything?

I suppose it's not the right way, because I tried it and SystemPreferences says that "You cannot use the Foo2 screen saver on this computer".
(Yes, Foo2 does contain the "right" Info.plist - the relevant lines look like this:
    <string>Foo2</string>
    <key>CFBundleIdentifier</key>
    <string>de.zach.Foo2</string>
    <key>CFBundleName</key>
    <string>Foo2</string>
)

BTW: this is the shell script I used to build the two different screen savers:

------ [snip]
cp Info.plist Info.plist.org

sed -E 's/[[:<:]]Foo[[:>:]]/Foo2/' Info.plist.org > Info.plist

xcodebuild -alltargets clean
xcodebuild -target Foo -configuration Release build

mv ~/"Library/Screen Savers/Foo.saver" ~/"Library/Screen Savers/Foo2.saver"

mv Info.plist.org Info.plist

xcodebuild -alltargets clean
xcodebuild -target Foo -configuration Release build
------ [snip]


I also considered creating a second target in Xcode, and assigning two different Info.plist files to them.
However, I see two problems with this approach:
1. I would have two Info.plist files that are almost identical, which is error prone;
2. In the single target that I have currently, Info.plist is not a member of the set of files that are assigned to this target
   (which seems funny to me, but I have no idea whether this is fine or not)

Any advice, insights, or pointers will be highly appreciated!

Best regards,
Gabriel.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to change the product name with command line builds?
      • From: Uli Kusterer <email@hidden>
    • Re: How to change the product name with command line builds?
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: Image Type for Button
  • Next by Date: iPhoto "external editor"
  • Previous by thread: Re: Image Type for Button
  • Next by thread: Re: How to change the product name with command line builds?
  • Index(es):
    • Date
    • Thread