2

I'm trying to add push notifications to my chat app following this tutorial: https://www.appcoda.com/firebase-push-notifications/

I've toggled Push Notifications to On in "Capabilities":

enter image description here

My provisioning profile is set up for push notifications:

enter image description here

I downloaded it, and double clicked it to install.

For Code Signing, in Target -> Code Signing:

enter image description here

And Project -> Code Signing:

enter image description here

Entitlements file:

enter image description here

When I ran the project it succeeded, then said "The executable was signed with invalid entitlements". Full error The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016).

Thanks for reading.. Any help on this will be hugely appreciated!

EDIT: Additional Information

Using Xcode 8.2.1

  • In my App ID in the developers portal, Game Center, In-App Purchases, and Push Notifications are enabled. It's my understanding that Game Center and IAP are enabled by default.
  • I've tried turning GC and IAP On, and then Off again. Restart Xcode, clean, build. No luck
  • I've tried turning GC and IAP On, then regenerating my provisioning profiles, installing them, cleaning and building. No luck.
  • My Bundle ID matches everywhere.
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
KingTim
  • 1,281
  • 4
  • 21
  • 29
  • Did you add the entitlement file to the project? – Praveen Kumar Jun 07 '17 at 12:41
  • Possible duplicate of [Entitlements file do not match those specified in your provisioning profile.(0xE8008016)](https://stackoverflow.com/questions/22625785/entitlements-file-do-not-match-those-specified-in-your-provisioning-profile-0xe) – Ahmad F Jun 07 '17 at 12:41
  • @AhmadF I looked through that thread and I've double checked that my bundle identifier is the same everywhere (plist, Target, Project). – KingTim Jun 07 '17 at 12:45
  • @PraveenKumar Yes, I included a screenshot of Target -> Code Signing, there is the entitlements file there. It's not in Project -> Code Signing, but if I do copy/paste it there, I get the same issue – KingTim Jun 07 '17 at 12:46
  • try to clean and try again – Er. Khatri Jun 07 '17 at 12:53
  • clean and build – Praveen Kumar Jun 07 '17 at 12:54
  • Tried it, same error – KingTim Jun 07 '17 at 12:57
  • try to redownload the latest cert and profile from app store, – Er. Khatri Jun 07 '17 at 13:02
  • although it should not make a issue – Er. Khatri Jun 07 '17 at 13:03
  • @KingTim, can you share your entitlements file as well, redacting the sensitive information in there – HeadOnn Jun 07 '17 at 13:53
  • Also I am not sure if the the number before your bundle id should appear, as the name of app id appears before bundle id usually. You can go and check in "App ID" section of developer account. And verify if the provisioning profile is using the same App ID – HeadOnn Jun 07 '17 at 14:06
  • I added some more screenshots at the bottom of my question. In my developer account, my App ID prefix is the same as the number as the development provisioning profile I downloaded. However in the "Identities in Keychain" section of the dropdown menu, it shows that number next to Distribution, not Developer. Not sure what that's about, but I included screenshots for all of it to show what I mean. On a side note, I got the app to run by simply deleting the entitlements file. However I'm not sure if this is a permanent solution. – KingTim Jun 07 '17 at 14:13
  • On this [page](https://stackoverflow.com/questions/19581225/the-executable-gets-signed-with-invalid-entitlements-in-xcode) Go and open the **Linked** pages. They are on the right side of the page. Maybe you'll find something different. I'm assuming people had similar problems like you – mfaani Jun 07 '17 at 16:07
  • @Honey Thanks, I have taken a look but I've looked through every single one of them at this point over the last 5 hours and tried every single suggestion. I don't know what's so different about my project, it's incredibly frustrating. – KingTim Jun 07 '17 at 17:10
  • I'm out of tricks. Just spitballing: Could you developer account on your Apple.com be different from Xcode? Did you chose the right teams for signing... If none of that help I suggest you forget this issue for a couple hours and then come back to again. If doing that didn't work then just stop...find another iOS devleoper that can sit next to you and solve it together. Maybe you can go to a meetup or do some screen sharing idk – mfaani Jun 07 '17 at 17:22
  • I actually just made an edit to my question, I'm not sure if this is an issue. But my App ID prefix matches my iOS Developer profile number, but not my iOS Developer profile number, that's different. I'm using automatic code signing and just selecting the generic "iOS Developer" as you can see in my other screens. – KingTim Jun 07 '17 at 17:25
  • Also another thing to be considerate of is: Do you have **multiple targets**? e.g. APP-QA, APP-Stage, APP-Prod. Make sure your developer portal is matching your app – mfaani Jun 07 '17 at 17:38

3 Answers3

2

Delete any unknown entries in entitlements file, which are not added by you.

Example: you can delete keychainAccessGroup entry from your entitlements file, if that is not added by you intentionally.

Have a look at your test target, the Team identifier should be same for both Test and Main target. Courtesy: https://stackoverflow.com/a/40464055/2959346

HeadOnn
  • 1,480
  • 14
  • 21
  • I think I need "keychainAccessGroup" - I have that capability checked, as it's necessary for Firebase to work properly. – KingTim Jun 08 '17 at 17:55
  • Also, I have a screenshot of my entitlements file in my question - I know nothing about entitlements files, but is that what it should look like after implementing push notifications? There's nothing on there about notifications. – KingTim Jun 08 '17 at 17:56
  • In you entitlements file, the "APS Environment" (Apple Push Services) key tells about push notification embedded in here. For keychain-access-group, refer this info https://bencoding.com/2016/12/31/simplifying-using-keychain-access-groups/ – HeadOnn Jun 10 '17 at 04:21
  • Also I am updating my answer, I found some useful post on stack overflow. Please try that as well. – HeadOnn Jun 10 '17 at 04:22
1

As your given information your app has enabled services for Game Centre, In-App Purchase and Notification.

and according to your entitlements settings that your app in Xcode doesn't have Game Centre as enabled. Check you entitlements setting once and try again, after enabling Game Centre there shouldn't be any problem.

bestiosdeveloper
  • 2,339
  • 1
  • 11
  • 28
  • I actually don't need Game Centre at all, not sure how that found its way in there. But what do I need to do? Turn "Game Centre" to "on" in capabilities? – KingTim Jun 07 '17 at 12:49
  • Yes, enable Game Centre in your Xcode entitlements and try, it should work. It worked for me as well. – bestiosdeveloper Jun 07 '17 at 12:52
  • What do you mean by Xcode entitlements? Sorry it's my first time dealing with entitlements.. And also, I don't need to do anything with In-App purchase? I don't need that for my app either, but it's in my provisioning profile enabled services somehow anyway. – KingTim Jun 07 '17 at 12:54
  • Nothing much just enable all the services as your app have in development certificate (in second image), make them same in Xcode entitlements (in first image) as well. – bestiosdeveloper Jun 07 '17 at 12:59
  • @KingTime- Don't worry. Game Centre and In-App Purchases are enabled by default in your provisioning profile by Apple. So it should not need be turned on in Capabilities Tab. The basis of this answer is not correct – HeadOnn Jun 07 '17 at 12:59
  • @HeadOnn Ok that makes a bit more sense. But I'm pretty confused now, if this answer is wrong. Do you have any suggestions? – KingTim Jun 07 '17 at 13:01
  • @HeadOnn, I'm saying the same thing check all the services and enable the same in xcode entitlements also. – bestiosdeveloper Jun 07 '17 at 13:02
  • 1
    Anyway I went ahead and toggled Game Center and In-App Purchases to On, re-downloaded the provisioning profiles just to be sure, installed them, restarted Xcode, cleaned, then built. Still getting the error. – KingTim Jun 07 '17 at 15:56
0

From your project settings, go to general then check the checkbox Automatically manage signing then select your team from below field! that's it!

You can refer the below screen shot,

enter image description here

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Yes, I have that option selected. – KingTim Jun 07 '17 at 13:35
  • from build settings change provisioning profile to automatic, and make sure that development team is same as you have set in general! after that from `capabilities` turn of `push notification` and then start again! – Ketan Parmar Jun 07 '17 at 13:38
  • Provisioning profile is set to automatic, as seen in the screenshots in my question. And I have tried toggling push notifications off then on again in capabilities, then re-downloading my provisioning profile and installing it. I still get the error. – KingTim Jun 07 '17 at 13:40
  • Make sure that your certificate is not expired! – Ketan Parmar Jun 07 '17 at 16:16
  • I just created the certificates this morning as part of the tutorial. I was using another certificate before that (non-push notification). But I installed the new push one to keychain. How can I make sure I'm using the correct certificate? The push one in this case? – KingTim Jun 07 '17 at 16:26
  • @KingTim look at the expiration dates of the certificates. The one that has a closer expiration date was created before and must be deleted – mfaani Jun 07 '17 at 19:25
  • Well in my case, after generating the 2 push certificates (development and production), I had 4. Those two, plus my iOS Development & iOS Distribution ones, none of them expired. The development one expires in a month, but it's still good. – KingTim Jun 07 '17 at 19:41