ios - What is the preprocessor macro to test whether an application extension is being built? -
this question based purely on publicly released documents regarding introduction of application extensions in ios.
with introduction of app extensions in ios 8, possible "extend custom functionality , content beyond app , make available users while they’re using other apps".
in implementation of extension, including classes actual app in extension (models, etc). problem these classes make calls uiapplication, not available in app extension, , compiler tells me so.
i thought easy solution enclose calls uiapplication in #if directive.
for example, if wanted include code if running on simulator, use:
#if target_iphone_simulator // code here #endif is there similar defined macro when target application extension?
you can define own macro.
in project settings use dropdown in topbar select extension target: 
then:
- click
build settings- find (or search)
preprocessor macrosunderapple llvm 6.0 - preprocessing- add
target_is_extensionor other name of choice in both debug , release sections.
then in code:
#ifndef target_is_extension // calls uiapplication #endif
Comments
Post a Comment