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: enter image description here

then:

  1. click build settings
  2. find (or search) preprocessor macros under apple llvm 6.0 - preprocessing
  3. add target_is_extension or other name of choice in both debug , release sections.

then in code:

#ifndef target_is_extension     // calls uiapplication #endif 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -