Jakob Jakob - 1 year ago 96
iOS Question

Xcode TARGET_OS_IPHONE seems confused, bug or configuration error?

in an older project I'm using the TARGET_OS_IPHONE precompiler macro in several places to implement some iOS-specific things.

This used to work fine in the past, but currently Xcode seems to have this macro "inverted" in such way that code-completion doesn't work within

blocks, even though my build target is an iOS app. There's also no syntax-highlighting. It syntax-highlights and code-completes the things in the
block which should only happen on a macOS target. As far as I can tell, it builds correctly though, just the editor seems confused. This makes editing code quite irritating. I am using Xcode 8.1 GM.

Might this be an Xcode bug, or is there possibly some configuration in my project which got messed up? It seems Xcode is looking at the wrong headers for a reason. When I CMD-click on the
macro, it navigates to this file:

xcode nav bar

which has the macro values for macOS, not the ones for iOS:

#define TARGET_OS_OSX 1

Seems that it chooses the wrong SDK. Not sure where to look / change this back to normal. I've looked at the target build settings, and they look ok.


Answer Source

this seems to have been an Xcode 8.1 bug. Issue seems to have resolved itself in Xcode 8.2 beta.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download