Thursday, February 3, 2011

Xcode — Rename Project and Application, Change Copyright and Version Number

fter reading the first 6 chapters in Aarons book, I couldn’t wait any longer and had to start writing my own program. I will share a first taste of it here soon. One key problem I soon faced was how to manage multiple versions, i.e., how to save old versions of my program when making major changes. Xcode has no rename functionality, and since an Xcode project comprises many files, the answer is not straightforward. A related problem is that I first started to call my Cocoa Application project by appending the version number. The problem with that is that the Cocoa application by default has the same name and that was awkward. For instance, my current project, a fractal generator, is called “FracGen 0p3″, but I wanted the application to be called only “FracGen” and have the version number appear when selecting the “About” menu item.
To rename an Xcode 2.5 project, do the following:
  1. Close the project in Xcode
  2. Duplicate the project directory in the Finder by pressing Command-D.
  3. Rename the folder
  4. Open the folder and rename the “.xcodeproject” file
  5. Delete the “Build” sub folder, if there is one
  6. Open the renamed .xcodeproject file
  7. On the left in the “Groups&Files” list, expand the “Targets” group, double click on the target that still has your old project filename. Rename it under the “General”-tab in the window that opens.
  8. Select “Clean all targets” from the “Build” menu, keep the boxes checked, and click “Clean”.
  9. Build and run your project.
Now about the second problem:
  1. In Xcode, on the left in the “Groups&Files” list, expand the “Resources” group, and click on “Info.plist”. In the editor on the right you’ll see a lot of entries of this plist file.
  2. Go down to the “CFBundleVersion”-entry and enter your version number, e.g., “0.3″
  3. Next, on the left select “InfoPlist.strings”. In the editor on the right, you’ll see an entry for “NSHumanReadableCopyright”. Enter your information between the quotes, e.g., “(c) Toby Junker, 2008″
  4. Finally, double-click your target (the one you renamed above), select the “Build”-tab in the window that opens, and scroll down until you find “Product Name”. This will have the original name of your “Xcode Project” (before you renamed it). Choose a name w/o version number, e.g., “FracGen”. You will not have to change this again.
These steps sound rather daunting, but are actually very quick to do. I have not yet switched to Leopard, so I don’t know if they work in Xcode 3.0, of if Xcode 3.0 finally has a rename function. The steps given to rename a project have to be executed every time you want to create a new version of your project. The application name and copyright info has to be changed only once. if you want the version to show up correctly in the application’s “About” box, you’ll have to change the plist as explained above.

Source: http://drjunker.org/2008/04/10/xcode-rename-project-and-application-change-copyright-and-version-number/

No comments:

Post a Comment