Ad

Our DNA is written in Swift
Jump

How to Rename an Appthe

Andreas asks:

I need to rename my app to something else because the original name is a trademark of a UK-based company. After I replaced all instances of the name where I found it the name of the product is still the same. Now if I build the products stay red and I get “No launchable executable present at path.” I have changed the name EVERYWHERE. How can I fix that?

Apart from the quick fix that I found googling I am going to see if I can fix this in XCode myself. I’ll show all the steps for guidance and the “pro fix” at the end.

Just right-clicking on “Rename” in the target’s context menu does not change the name of your product. Go inside the build settings of the target and change the bold “Product Name” to the new name. This updates the products section thus changing the name.

It leaves however the name of the project itself untouched and some files still have the old name:

  • the precompiled header in “other sources”
  • the info.plist
  • all files that where automatically generated by the project template with the project name

So you have to go in and change all those. Also you need to replace all instances of the one name with the other because the includes and class names will still be the old name. Usually XCode is smart enough that if you rename all the files most of the references will be correct as well. It worked for info.plist, but I still neded to update PCH prefix header in my build settings.

Building worked, but if you run the app it might crash. Looking at the console we see that there’s still old name stuff in the Xib files. MainWindow Xib had three references to the old name: in linked sub-Xib, as class name for the app delegate object and for the view controller object. In the main view controller Xib the class name also needed to be updated.

With these modifications my app built and went.

For most cases this will be sufficient, unless you want to go the extra mile and even rename the project folder itself and the project. For this you must exit XCode and in Finder first rename the folder and then the name of .xcodeproj file. Again, it worked fine for me as it’s supposed to.

If you have changed all the names, all the files, all the Xibs and still cannot build successfully then my friend it’s time for the “brute force pro fix” which I found on Tom’s Cocoa Blog.

  • Exit XCode and browse to the project directory.
  • “Show Package Contents” of the .xcodeproj which is really a bundle/directory
  • Edit the project.pbxproj and with your favorite text editor to replace all instances of the old name with the new one

Lobotomy

Even though I thought I had taken care of all replacements previous the text editor still showed 3 instances of the old name. Find&Replace All fixed that.

Think of this step as the total lobotomy. Dangerous, but it works if done with precision.


Categories: Q&A

Leave a Comment