From Xcode 12.5 start Apple force Action target must set
APPLICATION_EXTENSION_API_ONLY to true. If you didn’t set it, you will get an error “
Application extensions and any libraries they link to must be built with the `APPLICATION_EXTENSION_API_ONLY` build setting set to YES.“.
But normally we share a lot of codes between App targets and Action targets. So codes in Action target will contain some codes that don’t obey extension-only API requests. Like
UIApplication.shared.keyWindow and so on.
So we can warp these codes using
#if !ACTION_EXTENSION, like this:
#if !ACTION_EXTENSION //codes that don't obey extension-only API requests #else //normal codes #endif