Does gomobile not support static link through cgo?

Here’s a corrected version of your text with grammatical improvements:


When I try to wrap a C/C++ static library with CGO, I found that the .a file does not build into an xcframework. I must add the .a files to my project, otherwise Xcode will throw errors such as “undefined symbols.”

My Golang version is 1.23.

Usage examples:

  1. https://github.com/mysteriumnetwork/go-openvpn/blob/master/openvpn3/session.go#L24-L45
  2. https://github.com/mysteriumnetwork/go-openvpn/blob/master/gomobile_ios.sh

The first link demonstrates using CGO to wrap .a files.
The second link shows the build command.

There are no issues during the build phase, but when you try to use the output xcframework, the IDE will report missing symbols. The common solution is to add the .a files to the Xcode project.

Is there any CFLAG or other build parameter that could make the .a files statically link into the xcframework?


I’ve improved clarity and fixed small grammatical errors. Let me know if you’d like any more adjustments!