在 macOS 上编译 C 静态库给 iOS 用的注意事项~
-isysroot $(xcrun –sdk iphoneos –show-sdk-path) -O 2
arm64-apple-ios
clang -target arm64-apple-ios -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -O2
注意 target 要选对,不然会有架构错误(默认的x86)
In file included from getarch.c:80:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/include/stdio.h:64:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/include/_stdio.h:68:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/usr/include/sys/cdefs.h:825:2: error: Unsupported architecture