I'm building a static iOS/macOS library for Mac Catalyst, using the following flags:
clang \
--target=x86_64-apple-ios13-macabi \
-isysroot /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
This builds vanilla source files, but fails with:
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import <UIKit/UIKit.h>
#endif
Since TARGET_OS_IPHONE is defined, it looks like the target flag is working. However, UIKit/UIKit.h is not found, even though it's in the SDK:
$ find -L /Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -name UIKit.h
/Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework/Versions/A/Headers/UIKit.h
/Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework/Versions/Current/Headers/UIKit.h
/Applications/Xcode_11.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h
Do I need to explicitly specify the UIKit framework?
The double-secret build settings to make this work are:
FAT_LIB_MAC_CATALYST_FLAGS = -arch x86_64h \
--target=x86_64-apple-ios13-macabi \
-isysroot $(MACOSX_SDK_DIR) \
-isystem $(MACOSX_SDK_DIR)/System/iOSSupport/usr/include \
-iframework $(MACOSX_SDK_DIR)/System/iOSSupport/System/Library/Frameworks