I must cross compile libcurl
in order that I can use its API from inside an iOS app working on the Xcode iOS simulator. I’ve a easy app in swift that calls out to a C driver operate, which then comprises some calls into libcurl. I have already got the suitable bridging headers arrange so the C interoperability works, I simply must hyperlink in opposition to libcurl
now.
Sadly, after days of struggling I nonetheless cannot get the cross compilation of libcurl
right, such that my app can hyperlink in opposition to it.
Be aware: I’m compiling on an Macbook professional (m1 professional apple silicon) with MacOS Ventura 13.4
Darwin XXX-MacBook-Professional.native 22.5.0 Darwin Kernel Model 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000 arm64
I am configuring curl
with this name to ./configure
:
./configure --prefix /path/to/set up
--enable-static --disable-shared
--with-secure-transport
--host=arm64-apple-darwin
CFLAGS="-arch arm64 -target arm64-apple-ios-simulator -isysroot $(xcrun -sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=16.4"
make -j
make set up
Every little thing configures and builds tremendous, however after I drag the produced static library into my app’s xcode undertaking (which I confirmed does add libcurl.a
as a linked library) I get the next construct error in xcode:
In /Path/to/libcurl.a(libcurl_la-altsvc.o), constructing for iOS Simulator, however linking in object file constructed for macOS, file '/Path/to/libcurl.a' for structure arm64
- Why does xcode suppose this object file is constructed for macOS? The cross compilation choices handed to
./configure
by means ofCFLAGS
ought to imply it’s cross compiled to run on the iOS simulator - What are the bare-minimum compile choices (handed on to clang/gcc) required to cross compile something such that it may be pulled into xcode and run on the iOS simulator?
- What’s the applicable invocation to curve’s
./configure
such that I can create a static library forlibcurl
and import it into my xcode undertaking?