简体   繁体   中英

Xcode 8 and Preprocessor Macros

Since the latest XCode update 8.1 (Build 8B62) I'm having strange problems with syntax highlighting/code completion in connection with preprocessor macros.

They worked just fine with the XCode 8 GM seed which I have been using before the update, but now XCode does not recognize the correct target when selecting a scheme. For example, I'm having a controller static library with 2 targets - one for iOS, the other for Apple Watch. In each I use a macro (APP / WATCH) for platform specific operations. But when I'm in the APP target, Xcode editor highlights code as if it is the WATCH target whereas the actual code for this target has no highlighting nor auto completion. Xcode seems to randomly detect macros from different targets. The compiler on the other hand always detects the right code and works 100% fine, so there's nothing wrong with the code. It's just the editor.

Also when I start up Xcode the code gets highlighted for about a second and then gets all white text again. Removing and readding all schemes didn't work, cleaning and deleting Derived Data also has no effect on this. Anyone having the same problem or even a solution for this?

EDIT: I played around with targets and macros a little and I found that Xcode takes only macro from one target and discards all others, no matter what target is selected. Any help?

Try "Clean build" first... if that doesn't work then try

In the Preprocessor Macros Not Used in Precompiled Headers there are two subheadings

Preprocessor Macros Not Used in Precompiled Headers
debug +
release +

With a plus appearing beside when you hover over them. Press the plus on both of these and you should get:

Preprocessor Macros Not Used in Precompiled Headers
debug +
Any Architecture | Any SDK
release +
Any Architecture | Any SDK

You don't need to enter anything here after you have pressed +. Once you have added these two extra entries, try another clean build.

这是XCode 8中的一个实际错误。使用XCode 9(截至今天,2017年9月测试版6),它终于得到了解决。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM