ios – Active target for Xcode syntax highlighting


In my project, I have several binary targets and a few files which are included in multiple binaries.

Consider a file containing:

        #if TARGET_APP
        eventParameters["app_container"] = "app" // grayed out
        #elseif TARGET_AUTOFILL
        eventParameters["app_container"] = "autofill" // highlighted
        #endif

Which is a member of both the App and the App-AutoFill binary targets. The targets have build settings where SWIFT_ACTIVE_COMPILATION_CONDITIONS is set to either TARGET_APP or TARGET_AUTOFILL respectively.
This allows me to bundle slightly different run-time code in the app vs. the auto-fill extension binary.

What eludes me is how I can make Xcode index/highlight the above accurately. Of course, it will depend on which target the editor is highlighting for. It seems that my Xcode is highlighting for the App-AutoFill target, not the App target, causing the first condition to gray out and the second to be evaluated for syntax and indexing.

How do I tell Xcode to switch highlighting to use a different target?
I would prefer my App target to be the principal for syntax highlighting as that one contains the bulk of my code, or ideally even be able to choose the active one. This is especially cumbersome for grayed out code that defines types used frequently by the app.

My selected scheme builds the App target which embeds the App-AutoFill product using an Embed Foundation Extensions build phase.
App binary target with App-AutoFill dependency in the scheme selector

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img