How to build library for iOS in command line

Hello,

I try to build c++ library and swift library, based on c++ library and then include it in iOS application. But I can't find a way to build it from command line. SPM always target MacOSX. I try to use full path to sdk:

swift build --target cxxLibn --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk

But just get warning:

clang: warning: using sysroot for 'iPhoneOS' but targeting 'MacOSX' [-Wincompatible-sysroot]

It would be good to have options to build at least static libraries from command line.

2 Likes

I try to build swift package for iOS with following:

swift build --triple aarch64-apple-ios-sim --sdk "`xcrun --sdk iphonesimulator --show-sdk-path`"

But I get a bunch of errors like

<unknown>:0: error: unable to load standard library for target 'aarch64-apple-ios12.0-sim'

So I am also looking of a way to build swift package for iOS.

1 Like