building for iOS, but linking in object file built for macOS, file 'btfs.a' for architecture arm64

Hello there, I'm struggling with the following issue since Xcode 15 arrived and haven't been able to solve it.

I have a go library c-archive library which I'm using in a iOS app and build were OK until Sonoma updated came last year. I updated all my go libraries and go runtime to latest version and still facing issues:

my make script as follows:

ios-arm64: CGO_ENABLED=1
GOOS=ios
GOARCH=arm64
SDK=iphoneos
SDK_PATH=xcrun --sdk iphoneos --show-sdk-path
CARCH="arm64"
CC=$(PWD)/clangwrap.sh
CGO_CFLAGS="-fembed-bitcode"
go build -v -buildmode=c-archive -ldflags="-s -w" -gcflags=all="-l -B" -tags ios -o $(IOS_OUT)/btfs.a .

If there is anything else you need I can share more details. Thanks!

Replies

I recommend you have a read of An Apple Library Primer. It explains how there’s a difference between platform (macOS, iOS, iOS Simulator, and so on) and architecture (arm64, x86_64, and so on). It looks like your third-party build system is creating a static library that’s built for the macOS platform but you’re then trying to use it in an iOS target. This won’t work, despite the fact that the architectures are the same.

I no experience with your third-party build system, so I’ve not got a specific recommendation here. My general advice is that you build a similar project in Xcode and then look at the options that it passes to the compiler driver.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"