The auto generate asset download extension entitlements file prevents compilation

Apple this is dead easy and quick to reproduce.

Just create an app and then add a target of type background download.

Xcode automatically assigns a group id to the target and generates a corresponding entitlements file like so:

However the extension will not build, there is this error:

You can bugger about in the developer portal as long as you want, ensuring the group identifier exists, ensuring provisioning profiles have this group capability, etc. etc. nothing will make this error go away.

Now, what is unique about the download extension's entitlements file is the com.apple.developer.team-identifier key. This does not get generated for other extension - go ahead and see for yourself, create an action extension and give it a group, the result is its group appears in the entitlements file but not this com.apple.developer.team-identifier.

If you try to print out $(TeamIdentifierPrefix) (via echoing it in a build script), you get this

/Users/me/Library/Developer/Xcode/DerivedData/experiments-clpwbtcvdpqwuodxzwmsxwpztguo/Build/Intermediates.noindex/experiments.build/Debug-iphoneos/backgroundDownloadExtension.build/Script-243C9904292461BC001FDE14.sh: line 4: TeamIdentifierPrefix: command not found

Hmm, command not found, but if you change the echo to ${TeamIdentifierPrefix} guess what gets printed, yes the team identifier i.e. in my case MV8J9D3236.

Now if in the entitlements file I add the team identifier explicitly, like so

Then magically the error about automatic signing and the provisioning profile goes away. Change it back to $(TeamIdentifierPrefix) and the error appears, change it to be explicit and it goes away.

So by tweaking the entitlements file its possible to get the extension to build, however all is not well, now that it builds, if the extension is installed and run, the OS says:

"Event (1) dropped for client (com.company.experiments) failed because the app and extension do not share any application groups."

It says that despite the fact the app and extension both do have the same group capability.

This is driving me nuts - the auto generated entitlements file is stopping the extension from compiling, but if you fix the build, it can't run.

(Xcode 14.1, iOS 16.2)

If anyone else hits this, you may be able to resolve this error by changing com.apple.developer.team-identifier to $(DEVELOPMENT_TEAM). The issue is that $(TeamIdentifierPrefix) is not set in your Xcode project.

Where is this extension's entitlements documented? https://developer.apple.com/documentation/bundleresources/entitlements

The auto generate asset download extension entitlements file prevents compilation
 
 
Q