GCM in Swift Bundle ID Error
Asked Answered
M

1

2

I am having trouble in executing Google Cloud Messaging in Swift. Using GCMExample for objective C I am getting the Registration token but when I am trying to run GCMExampleSwift which is for Swift I am getting an error. I am using the the same 'GoogleService-Info.plist' for both Objective C and Swift.

2015-10-26 17:31:59.834 GcmExampleSwift[360:51727] The configuration file 'GoogleService-Info.plist' is for another bundle identifier ('com.XXXXXX.mobility.appfactory.dev1.social'). Using this file the services may not be configured correctly. To continue with this configuration file, you may change your app's bundle identifier to 'com.XXXXXX.mobility.appfactory.dev1.social'. Or you can download a new configuration file that matches your bundle identifier from https:/ 2015-10-26 17:31:59.836 GcmExampleSwift[360:] App measurement v.1100000 started 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Successfully configured [CloudMessaging]. 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Failed to configure []. 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Subspecs not present, so not configured [Analytics, AdMob, SignIn, AppInvite, Maps]. 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Subspecs expected to be present [CloudMessaging, Measurement]. 2015-10-26 17:31:59.936 GcmExampleSwift[360:] Network status has changed. code, status: 2, Connected 2015-10-26 17:31:59.977: GGLInstanceID | Unable to find token in cache Error Domain=com.google.iid Code=-25300 "(null)" Registration to GCM failed with error: The operation couldn’t be completed. (com.google.HTTPStatus error 401.) 2015-10-26 17:32:01.053 GcmExampleSwift[360:51727] - changing property masksToBounds in transform-only layer, will have no effect 2015-10-26 17:32:01.053 GcmExampleSwift[360:51727] - changing property masksToBounds in transform-only layer, will have no effect 2015-10-26 17:32:01.053 GcmExampleSwift[360:51727] - changing property masksToBounds in transform-only layer, will have no effect

Moreau answered 27/10, 2015 at 6:35 Comment(2)
Seems like the error is complaining about different bundle IDs, are your two projects (Swift and Obj C) using the same bundle ID?Barn
Thanks for your reply Arthur. The steps provided by ztan worked for me. Made mistake by not changing the individual Bundle ID of the target.Moreau
R
8

Seems the Bundle ID in your GoogleService-Info.plist does not match the bundle ID in your target.

First you need to add the GoogleService-Info.plist file to a correct target, if you are trying the GcmExampleSwift, you should select that as the target:

enter image description here

Then in your GoogleService-Info.plist file, if you want to use com.XXXXXX.mobility.appfactory.dev1.social as your bundle ID, make sure you spell it correctly in for the BUNDLE_ID key:

enter image description here

Finally, in your targets, make sure you select the GcmExampleSwift first (NOT the GcmExample which is the Objective - C target), then make the the Bundle Identifier matches the BUNDLE_ID in your GoogleService-Info.plist file:

enter image description here

Reinaldo answered 27/10, 2015 at 22:14 Comment(2)
Thank a lot ztan for your answer, it worked. The mistake I was making was changing the Bundle ID for the project but not for the individual target. After changing the Bundle ID for the GCMExampleSwift target it worked.Moreau
The last picture in the answer was my mistake. I didn't select GcmExampleSwift in the TARGETS section (firstly, I wasn't aware if a section like that even existed!). Thank you so much.Brumby

© 2022 - 2024 — McMap. All rights reserved.