Changing bundle ID for Firebase
Asked Answered
V

3

27

Early on in this project I made the error of not having the prefix com in the bundle identifier. Now I am ready to test flight and I have an invalid bundle identifier.

Currently, my bundle identifier is mycompany.myProject but I want it to be com.mycompany.myproject. I have no problem switching to the desired bundle id for archiving the app and uploading to the app store.

The steps I took to switch the app to the appropriate bundle identifier:

  1. Create new app in firebase console with correct bundle ID.
  2. Download Google-Info.plist of this new app and place in projects root and drag into Xcode project.
  3. Change bundle identifier on Facebook
  4. Change bundle identifier in project settings

However, the app crashes fatally with this error.

*** Terminating app due to uncaught exception 'InvalidPathValidation', reason: '(child:) Must be a non-empty string and not contain '.' '#' '$' '[' or ']''

The point at which this error arises is when a Firebase method is called

- (NSString *) getUid {
return [FIRAuth auth].currentUser.uid;
}

This method returns nil which feeds a method for retrieving data from Firebase. This method's nil return causes the InvalidPathValidation error.

I am authenticating with Facebook. I thought maybe the reason this is returning nil is that the app doesn't know who is logged in, because I was never prompted to login (my app checks if your logged in through Facebook in viewWillAppear on the opening ViewController). However this doesn't make sense because the only change I made was changing the bundle ID. I have been stuck on this problem for almost a week.

I am specifically wondering what do I need to change for Firebase to accept the bundle identifier changes.

Verlaverlee answered 3/10, 2016 at 22:31 Comment(2)
Did you delete the old GoogleService-Info.plist? Just want to make sure there aren't two in there, and its getting the wrong one.Cycad
I replaced the old GoogleService-Info.plist with the updated one. There is only one file in my root.Verlaverlee
V
39

The solution was to create a new app within the same firebase project

Verlaverlee answered 29/12, 2016 at 13:4 Comment(5)
wow, is there really no way to change the bundle ID in Firebase?Chatav
There really isn't Phil. You can add different projects to the same project, which for some reason was not working on this project. However, doing another project later I was able to add multiple apps to the same project, no problemVerlaverlee
Like @KyleGriffith said in his comment, I was able to fix the issue by creating a new app in the same project. I had to replace the GoogleService file and update the information for the crash reporting (create and download a new crash reporting JSON file and update the build phase to reference the new file and the new GoogleService Id).Yugoslavia
Just opt for the APN method and generate .p8 file instead. So much easier.Seacock
Yeh, this really sucks. Still can't update bundle ID without creating a new app 😢Saviour
H
4

The above answer may have been correct at the time of publication but what helped me was changing the bundle identifier in the Signing and Capabilities settings of the Target. Then, I went to the GoogleService-Info.plist file and I changed the value for BUNDLE_ID. Then, I hit Command +B to build the app and I ran the app. It worked just fine for me and I didn't get any errors.

Headword answered 17/6, 2020 at 2:58 Comment(6)
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From ReviewAnorthite
@Anorthite I am not critiquing or requesting clarification. I am simply providing an answer as I found that the accepted one not worth it to create a new Firebase project just to change a Bundle ID. Please read carefully.Headword
This might work in some cases, but would not be enough in many others, e.g. when using Firebase Auth. It does not answer the question.Third
@NikolaySuvandzhiev This works in all cases. In fact, I myself used this technique when I was trying to fix some issues I has with OAuth. It does answer the question.Headword
When you perform the steps you suggested, is the new bundle ID set in the Firebase console's project settings? For me it's not. As a result Firebase Auth with "Sign-in with Apple" didn't work. And in any case having to remember to change the GoogleService-Info.plist is not great. The correct way is to create a new app in the same project as mentioned by the other answer.Third
@NikolaySuvandzhiev In that case you may be doing it incorrectly. Sign In With Apple and Microsoft OAuth were the reasons I needed to change the bundle ID and my solution worked correctly for me. I was able to get the same result multiple times.Headword
C
4

If you're logged into the Firebase CLI and have the flutterfire cli installed, you can update the BUNDLE ID in the GoogleService-Info.plist file and then use the flutterfire configure command within your project to sync the apps registered to your Firebase project.

If you changed the name correctly, it should say that a project with the new name for iOS isn't registered and will register it for you. In your Firebase console, you'll then be able to see the old app and a newly registered app with the new name. You can delete one there.

Cabbageworm answered 18/8, 2023 at 3:30 Comment(1)
This solution worked for meConium

© 2022 - 2024 — McMap. All rights reserved.