Xcode 8 Beta: aps-environment entitlement is missing

We are using the following xcodebuild command:

xcodebuild PROVISIONING_PROFILE_SPECIFIER='...' -workspace App.xcworkspace -scheme "App" -derivedDataPath "Output/iphoneos10" -sdk iphoneos -configuration Beta CODE_SIGN_IDENTITY="..." -archivePath "Output/iphoneos10/App.xcarchive" clean archive


It is almost the same as Xcode 7 one (PROVISIONING_PROFILE_SPECIFIER instead of PROVISIONING_PROFILE).


And we get the following entitlement:

⇒ codesign --display --entitlements :- ./Output/iphoneos10/App.xcarchive/Products/Applications/App.app

Executable=/Users/user/Workspace/app/Output/iphoneos10/App.xcarchive/Products/Applications/App.app/App
<?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>SOMEID.com.some.App</string>
        <key>beta-reports-active</key>
        <true/>
        <key>com.apple.developer.team-identifier</key>
        <string>TEAMID</string>
        <key>get-task-allow</key>
        <false/>
        <key>keychain-access-groups</key>
        <array>
                <string>SOMEID.com.some.App</string>
        </array>
</dict>
</plist>


See, that

        <key>aps-environment</key>
        <string>production</string>

is missing, even that it is present in provisioning profile.


The same for

Output/iphoneos10/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Beta-iphoneos/App.build/App.app.xcent

'aps-environment' is missing


For Xcode 7 'xcodebuild' it is Ok - both 'codesign --display --entitlements' and 'App.app.xcent' has 'aps-environment'.


I have compared the xcodebuild output and found the following difference:

Xcode 7:

ProcessProductPackaging /Applications/Xcode-7.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/Entitlements.plist Output/iphoneos/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Beta-iphoneos/App.build/App.app.xcent
...
builtin-productPackagingUtility /Applications/Xcode-7.3.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/Entitlements.plist -entitlements -format xml -o /Users/user/Workspace/app/Output/App/iphoneos/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Beta-iphoneos/App.build/App.app.xcent

Xcode 8:

ProcessProductPackaging "" Output/iphoneos10/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Beta-iphoneos/App.build/App.app.xcent
...
builtin-productPackagingUtility -entitlements -format xml -o /Users/user/Workspace/app/Output/App/iphoneos10/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Beta-iphoneos/App.build/App.app.xcent


Is anything changed? Should I use CODE_SIGN_ENTITLEMENTS parameter and specify

/Applications/Xcode-8.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/Entitlements.plist

?


PS Apple bug number is 28076333

Open radar is here: http://www.openradar.me/28076333

Accepted Reply

Here is Apple's reply:


Engineering has requested the following information in order to further investigate this issue:


You need to add the entitlement to your entitlements file. Xcode will no longer automatically merge it from the provisioning profile. You can enable the capability in the project editor to have Xcode do this automatically.


We are now closing this bug report.


If you have questions or comments about the resolution, please update your bug report with that information so we can respond.

Replies

Apple bug number is 28076333

Open radar is here: http://www.openradar.me/28076333

Here is Apple's reply:


Engineering has requested the following information in order to further investigate this issue:


You need to add the entitlement to your entitlements file. Xcode will no longer automatically merge it from the provisioning profile. You can enable the capability in the project editor to have Xcode do this automatically.


We are now closing this bug report.


If you have questions or comments about the resolution, please update your bug report with that information so we can respond.

How can we enable this capability in the project editor?

It should be on the Capabilities tab of your app's target. FWIW, this was mentioned in the Xcode 8 release notes:


Xcode 8 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. (28076333)

Could you tell me how to add aps-environment entitlement to my entitlements file?
I don't find which entitlements file I should add it to.

FYI, I have already make a ticket #178243.

I would like you to check the details.

https://forums.developer.apple.com/message/178243#178243


Also, I have another ticket #178241 related to Xcode 8.

If you find the solution, please tell it to me.

https://forums.developer.apple.com/message/178241#178241

I enabled push notification on my app (even though I am not using any push technology), and the issue was resolved.

I don't know if you've figured this out yet, but in case you haven't:


1. Click the top item on the left pane, where you have your .swift files. It should be your App name (project editor).

2. When the project editor pops up, to the left of the "Info" tab, you should see your App name with up and down arrow.

3. Click that and navigate to "Targets" with your App name.

4. Then click "Capabilities" tab and you turn on Push Notificiations.


Build your project and run, now that message should be gone.