What is the preprocessor macro to test whether an application extension is being built?

前端 未结 3 1599
日久生厌
日久生厌 2021-02-04 06:18

This question is based purely on publicly released documents regarding the introduction of application extensions in iOS.

With the introduction of app extensions in iOS

3条回答
  •  佛祖请我去吃肉
    2021-02-04 06:38

    You can define your own macro.

    In the project settings use the dropdown in the topbar to select your 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 any other name of your choice in both the debug and release sections.

    Then in your code:

    #ifndef TARGET_IS_EXTENSION
        // Do your calls to UIApplication
    #endif
    

提交回复
热议问题