Search code examples
iosmacosarchiveshareddylib

Build a c-shared dylib from golang for iOS (armv7/arm64)


Is there a way to build a dynamic library (dylib) from go code? I get it done for x86_64 and i386, but for arm64 and armv7(s) it says "buildmode=c-shared is not supported on darwin/arm". Why? Or is there a way to convert a static a-library file into a dynamically linked Mach-O dylib? I can merge the dylibs and a-files into one universal binary using lipo, but that still leaves them as static archives.

I'm sure there must be a command to convert a static archive into a dynamic Mach-O library. Any help appreciated, thank you!


Solution

  • @Siguza gave me the correct hint. This is the final way to convert my static archive to a dynamic library for iOs - at least for arm64. I tried the same for armv7, but that lead to other issues and I decided to leave 32bit out here.

    xcrun -sdk iphoneos clang -arch armv7 -fpic -shared -Wl,-all_load libmystatic.a -framework Corefoundation -o libmydynamic.dylib