Search code examples
iosxcodefirebasecocoapodsplist

How To Change The App's Bundle ID & App’s Name


I'm in the process of developing an iOS app in Swift. I already downloaded my Firebase Google Plist file and I'm currently using Firebase Auth and FireDatabase modules inside my app. I want to change the name of my app and bundleID from its current name in Firebase "Special Sauce" with the bundleID .com.specialsauce.Special Sauce to a new Firebase name being "Sauce" with a bundleID of .com.pizza.Sauce.

How can I achieve this with my current Firebase Google Plist file and all the Firebase pods (I used Cocoapods to install Firebase) that were initially installed?


Solution

  • I couldn't find a way to change the app's name in Firebase so I deleted the Firebase Google Plist file and started a new app with the preferred name I wanted. I also had to change the actual iOS app name and bundleID.

    Before you begin this make sure your doing this on a copy and you have a backup of the original because if anything goes wrong you'll be sol. You also want to make sure that you know which pods were initially included in your project before you changed the name because your going to delete them all in step 6 and add them back in step 8.

    To start the goal was to change my app's bundleID from com.specialsauce.Special Sauce to com.pizza.Sauce which automatically give me the name I wanted. Steps 1-4 changes the app's name and bundleID in Xcode only. If you want to change them in Firebase too then follow steps 5 and on...

    If my app's bundleID was com.specialsauce.Special Sauce and I wanted to change the last part (the actual name of the app) to com.specialsauce.Sauce this first step is how to change the last part: Special Sauce to just Sauce which would also give me a new app name.

    1. I followed these youtube directions which 100% works change app's name & last part of bundleID

    Now my app's bundleID is com.specialsauce.Sauce and the new name of the app in Xcode is "Sauce".

    If I wanted to change the middle part from com.specialsauce.Sauce to com.pizza.Sauce these second and third steps are how to change the middle part: specialsauce to pizza.

    1. I went to the main project folder the app was in, opened it, right clicked on the blue .xcodeproj file enter image description here

    (not the white .xcworkspace cocoapod file), choose Show Package Contents enter image description here

    then double clicked and opened the white project.pbxpoj file enter image description here

    enter image description here

    (not the project.xcworkspace file).

    1. Once in there I pressed 'command + f' to search for anything with the old name (specialsauce) and changed them to my new name (pizza). I saved (command+s) and closed the file once everything was changed.

    My app's new bundleID is now com.pizza.Sauce

    Assuming all your files are in the same path (eg. mainFolder/XcodeProjectName/allYourFiles) you shouldn't see any red project files. However your Pod files will be red because of the name change and you will have to delete them and reinstall which I explain in step 6.

    1. If you got an iOS Certificate (i.e. messaging certificate) from developers.apple.com you might see some red error files inside your project navigator. If you have a yourAppsName.entitlements certificate in your project then you will have to delete it because of the name change. Go to your project navigator > click the Blue Icon at the very top > to the left of the center console make sure your under Targets (not Project) > select Build Settings > in the search box enter code_signing and you'll see Code Signing Entitlements appear > go the the right side of it, click the whateverName/yourAppName.entitlements and then delete it. Before you delete it you can press the Code Signing Entitlements on the left side and you'll see a down arrow, pressing it will show a debug and Release with the same whateverName/yourAppName.entitlements to the right of them. Once you delete the first one all 3 should disappear.

    2. To change my app's name and bundleID in Firebase I opened my Xcode project, found the Firebase Google Plist file and deleted it from the project. I deleted it because it still had the old name. Step 7 you drag another one back in. Btw no need to build because once you delete the file you won't be able to connect to Firebase anymore.

    On a side note before you begin step 6 and you delete the pods from the Podfile, you need to copy and paste them somewhere because your going to have to add them again in step 8 after you generate a new Podfile. Also, which is very important, if you were working with old pod files from say Xcode 8.3.3 but your changing your bundleID in Xcode 9, your going to have to find and install the current Xcode 9 pods that relate to your project. I only say that because this ended up being a major headache for me trying to reinstall the old pods from Xcode 8.3.3 to Xcode 9.1.

    1. I had to delete all my pod files that still were tied to the original app's name/bundleID before I made the above changes. I opened terminal, navigated to the same folder my project was in, then I followed these steps in this specific order to delete all of the old cocoapod files. I'll put the links I used for these instructions below.

      $ sudo gem install cocoapods-deintegrate

      $ sudo gem install cocoapods-deintegrate cocoapods-clean

      $ rm -rf ~/Library/Developer/Xcode/DerivedData

      $ pod deintegrate

      $ pod clean

      $ rm Podfile

      $ pod cache clean --all

    Once all the commands were ran, cocapods was completely wiped from my system but every time I tried to build the project I kept getting these weird 3 crash logs. It turns out I had to reinstall all the cocoa pods I deleted.

    1. Before I did that I went to Firebase and started a new app with the new project name and new bundleID, downloaded the new .plist file, and dragged it back into the project.

    2. I then opened terminal, navigated to the folder with my app was in, did a 'pod init', opened the Podfile and pasted in all the pods I deleted from step 6, ran 'pod install' and then once it was finished and I pressed build everything was all good.

    I changed my iOS app's name and bundleID in Xcode and Firebase!

    Here are the links to the commands I ran above to wipe all cocoapod files from my app. Remember once they are gone you will still get build errors because you will have to reinstall the pods again with 'pod init' and 'pod install'

    cocoapods deintegrate

    how to remove cocoa pods from a project

    Inside the second link I used the answer by DevGangsta to remove the pod files. The first answer with the highest up votes didn't work for me.

    Update

    After you change the bundleId in the debugger you might see a weird name for some of your data models like yourAppName.-temp-caseinsensitive-rename. You're specifically looking for this exact phrase -temp-caseinsensitive-rename

    Follow this answer to fix it or this answer\

    Make sure you do a clean build (shift + cmmd + k) after this updated step. For some reason the assets folder periodically comes up as missing but once I do a clean build everything works fine