You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using PureLayout in an App Extension, you must define the preprocessor macro PURELAYOUT_APP_EXTENSIONS to prevent usage of unavailable APIs.
If you do not do this, you will see an error such as:
'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
To fix this:
If you're using CocoaPods
You probably don't want to modify the Pods project (and the Pods-PureLayout target it contains) by hand because it is regenerated every time you run pod install. Instead, you should use a post_install hook to have the preprocessor macro automatically added every time you run pod install.
At the end of your Podfile, add the following post_install hook:
post_installdo |installer|
# NOTE: If you are using a CocoaPods version prior to 0.38, replace `pods_project` with `project` on the below lineinstaller.pods_project.targets.eachdo |target|
iftarget.name.end_with?"PureLayout"target.build_configurations.eachdo |build_configuration|
ifbuild_configuration.build_settings['APPLICATION_EXTENSION_API_ONLY'] == 'YES'build_configuration.build_settings['GCC_PREPROCESSOR_DEFINITIONS']=['$(inherited)','PURELAYOUT_APP_EXTENSIONS=1']endendendendend
The above post_install hook will define the macro PURELAYOUT_APP_EXTENSIONS=1 for every build configuration on all PureLayout targets in the generated Pods project that are used by App Extensions.
If you've integrated the source code directly into your project
In Xcode, click on your Project
Click on the Target for your App Extension
Click Build Settings
Find (or search) Preprocessor Macros under Apple LLVM 6.0 - Preprocessing
For all build configurations (Debug & Release) add the macro: PURELAYOUT_APP_EXTENSIONS=1
Now, when your App Extension target is selected, PureLayout will not use unavailable APIs.