'unsigned xcarchive aps environment missing

I want to share unsigned xcarchive. To make unsigned xcarchive. I set Provisional profile and Signing Certificate as None. I have crated Xcarchive with below commands one by one.

xcodebuild -scheme xxxx -workspace xxx.xcworkspace -configuration Release clean archive -archivePath "/Users/exxx/Desktop/PROD/xxx.xcarchive" CODE_SIGN_ENTITLEMENTS=/Users/exxx/Desktop/PROD/Cert/entitlements.plist CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO

& without passing CODE_SIGN_ENTITLEMENTS

xcodebuild -scheme xxxx -workspace xxx.xcworkspace -configuration Release clean archive -archivePath "/Users/exxx/Desktop/PROD/xxx.xcarchive" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO

when I upload that archive with Organizer then at final check it shows Entitlement summary where 'aps-environemt' key always missing. I have attached screen shot for reference. Both builds having same issue.

I also tried the same exported archive to codesign with entitlement but that also don't work. (With below command)

codesign --entitlements  /Users/xxx/Desktop/PROD/Cert/xxx.entitlements -f -s xxx /Users/xxx/Desktop/PROD/xxx.xcarchive

When My upload completed then getting an email from apple as,

Your app appears to register with the Apple Push Notification service, but the app signature's entitlements do not include the 'aps-environment' entitlement...

enter image description here



Solution 1:[1]

To add APS entitlement to your xcarchive you should sign your .app file with entitlements.plist that has aps-environment key (and other needed keys) e.g.:

entitlements.plist

<?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>aps-environment</key>
    <string>development</string>
</dict>
</plist>

Next sign embedded frameworks and your app file with the entitlements:

$ codesign -f -s "<codesiging identity>" -v /foo.xcarchive/Products/Application/foo.app/Frameworks/*
$ codesign -f -s "<codesiging identity>" --entitlements /pathToEntitlements/entitlements.plist /foo.xcarchive/Products/Application/foo.app

To get available codesign identities run next command:

security find-identity -vp codesigning

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 iUrii