Xcode 8 and preprocessor macros

Since the last update to XCode 8.1 (Build 8B62), I have had strange problems with syntax highlighting / code completion due to preprocessor macros.

They worked great with the Xcode 8 GM seeds that I used before the upgrade, but now Xcode does not recognize the correct target when choosing a schema. For example, I have a static controller library with two goals - one for iOS, the other for Apple Watch. In each I use a macro (APP / WATCH) for specific platform operations. But when I am in the target APP, the Xcode editor highlights the code as if it were the WATCH target, while the actual code for this purpose does not have highlighting or automatic completion. Xcode seems to accidentally detect macros from different targets. The compiler, on the other hand, always detects the correct code and works 100% perfectly, so there is nothing wrong with the code. This is just an editor.

Also, when I start Xcode, the code is highlighted for about a second, and then again gets all the white text. Deleting and reading all the schemes did not work, cleaning and deleting Derived Data also did not affect this. Anyone who has the same problem or even a solution to this?

EDIT: I played around a bit with goals and macros, and I found that Xcode only accepts macros from one target and discards all the others, no matter which target is selected. Any help?

+6
source share
2 answers

This was a real bug in Xcode 8. With Xcode 9 (today, September 2017 beta 6), it is finally resolved.

0
source

First try "Clear assembly" ... if that doesn't work, try

There are two subheadings in preprocessor macros not used in precompiled headers
Preprocessor macros not used in precompiled headers
debug +
release +

A plus appears next when you hover over them. Click on the plus for both of them, and you should get:
Preprocessor macros not used in precompiled headers
debug +
Any architecture | Any SDK
release +
Any architecture | Any SDK

You do not need to enter anything here after you click +. After you add these two additional entries, try another clean build.

0
source

Source: https://habr.com/ru/post/1012509/


All Articles