I am building a share extension in iOS that allows users to share a URL (e.g., from Instagram) to my app. My extension works perfectly when I use:
<key>NSExtensionActivationRule</key>
<string>TRUEPREDICATE</string>
However, this gets rejected by Apple when I try to upload the build to TestFlight with the following error:
Invalid Info.plist value. The value for the key 'NSExtensionActivationRule' in bundle ... is invalid.
To comply with Apple's guidelines, I am trying to use a specific activation rule for URLs. My current Info.plist
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>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
ANY NSExtensionItems.attachments.contentTypeUTI == "public.url"
</string>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
</dict>
</plist>
However, with this rule:
The share extension does not appear in the share sheet when I try to share a URL.
Debugging logs confirm that the attachment type is public.url
Attachment Type Identifiers: ["public.url"]
<key>NSExtensionActivationSupportsAttachmentsWithMatchingTypeIdentifiers</key>
<array>
<string>public.url</string>
</array>
Result: The extension still doesn't show up.
If I use:
<key>NSExtensionActivationRule</key>
<string>TRUEPREDICATE</string>
The extension appears correctly in the share sheet and works as expected, but Apple rejects it during validation (when I try to upload my app to TestFlight).
Why doesn't my share extension appear in the share sheet when targeting public.url
with a proper NSExtensionActivationRule
?
What is the correct and Apple-compliant way to configure NSExtensionActivationRule
so the extension appears for URLs and passes TestFlight validation?
After much trial and error, I finally got the app to show up in the share menu when sharing URLs from apps like Instagram and TikTok. The solution involved adding the NSExtensionActivationSupportsWebURLWithMaxCount
key, which I initially overlooked.
Apple’s documentation on NSExtensionActivationSupportsWebURLWithMaxCount
is subtle and not always clear about how it complements NSExtensionActivationSupportsAttachmentsWithMatchingTypeIdentifiers
.
I had assumed (wrongly) that public.url
alone would suffice in all cases since it’s a universal UTI. However, the behavior of host apps like Instagram treating URLs differently exposed the flaw in that assumption. Adding NSExtensionActivationSupportsWebURLWithMaxCount
explicitly to the Info.plist made all the difference.
Here’s the full Info.plist
that finally worked:
<?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>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsAttachmentsWithMatchingTypeIdentifiers</key>
<array>
<string>public.url</string>
</array>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
</dict>
</plist>