Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

ios - xcodebuild Unsigned IPA - Missing Push Notification Entitlement (Work when signing directly the App in XCode)

Context : XCODE 12.0.1

I'm using Push Notifications in Ionic. The configuration is OK. I added the Push Notification Capability in Signing and Capabilities . I build my app and I do npx cap open ios, and I do Product > Archive and then it asks me to sign the app, I sign it, and OK. When I test Notifications, everything works well.

Problem : I need to generate unsigned IPA with xcodebuild for my client. He wants to sign it himself. But when I generate the xcarchive (unsigned IPA), then he tells me that after signing it, Notifications don't work, and he received this message when he tried to upload it on App Store :

Missing Push Notification Entitlement - Your app appears to register with the Apple Push Notification service, but the app signature's entitlements do not include the 'aps-environment' entitlement. If your app uses the Apple Push Notification service, make sure your App ID is enabled for Push Notification in the Provisioning Portal, and resubmit after signing your app with a Distribution provisioning profile that includes the 'aps-environment' entitlement. Xcode does not automatically copy the aps-environment entitlement from provisioning profiles at build time. This behavior is intentional. To use this entitlement, either enable Push Notifications in the project editor's Capabilities pane, or manually add the entitlement to your entitlements file. For more information, see https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/HandlingRemoteNotifications.html#//apple_ref/doc/uid/TP40008194-CH6-SW1.

How I generate the xcarchive : xcodebuild -workspace ios/App/App.xcworkspace -allowProvisioningUpdates -scheme App -sdk iphoneos -configuration Release -destination generic/platform=iOS -archivePath output/ios/App.xcarchive archive CODE_SIGNING_REQUIRED="NO" CODE_SIGNING_ALLOWED="NO"

Signing manually or automatically don't solve the problem.

Do you know why I get these errors when using xcodebuild (App Store Error, Push Notification Error) ?

It looks a little bit like this problem : Missing Push Notification Entitlement: While Resigining ipa

Do you know if i'm using xcodebuild the wrong way?

EDIT 1 : If I use this software https://github.com/maciekish/iReSign , to resign my xcarchive, it works... But clients won't agree to use some mystical softwares. I tried to compare my "normally XCODE signed" .ipa with the .ipa signed by this software. The only thing that differs is that there is an entitlements.plist file in the folder in the second case. enter image description here And this file looks like this :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>application-identifier</key>
    <string>**TEAMID*.*APP-ID*</string>
    <key>aps-environment</key>
    <string>production</string>
    <key>com.apple.developer.applesignin</key>
    <array>
        <string>Default</string>
    </array>
    <key>com.apple.developer.team-identifier</key>
    <string>**TEAM ID**</string>
    <key>get-task-allow</key>
    <false/>
    <key>keychain-access-groups</key>
    <array>
        <string>TeamID.*</string>
        <string>com.apple.token</string>
    </array>
</dict>
</plist>

But I can find this in the "normally signed" ipa on the embedded.mobileprovision file, there is the entitlements section containing these lines... I can't understand why this tool made it work


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I finally solved my problem. The command line I used for generating the xcarchive was wrong. I just had luck by testing this line without the "SIGNING" parameters :

xcodebuild -workspace ios/App/App.xcworkspace -allowProvisioningUpdates -scheme App -sdk iphoneos -configuration Release -destination generic/platform=iOS -archivePath output/ios/App.xcarchive archive

I found these parameters in some Medium page, and I don't know why I was using them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...