Set APPLICATION_EXTENSION_API_ONLY on a SPM package

As stated in the Xcode 13 beta 3 release notes:

  • Linking Swift packages from application extension targets or watchOS applications no longer emits unresolvable warnings about linking to libraries not safe for use in application extensions. This means that code referencing APIs annotated as unavailable for use in app extensions must now themselves be annotated as unavailable for use in application extensions, in order to allow that code to be used in both apps and app extensions. (66928265)

You can add the:

@available(iOSApplicationExtension, unavailable)

attribute to declarations using app extension unavailable APIs in order to get them to compile in a way that works for both apps and app extensions.

1 Like