use*_*299 9 compiler-errors go ios swift
我已经在这个问题上工作了一整天并且非常困难。我很乐意帮忙。
我正在尝试编译 C/Go 代码以在我的 iOS swift 应用程序中运行。该库可以很好地编译正常的 amd64 架构。
为了进行编译,我从生成静态 .a 存档的编译步骤开始。
GOOS=ios GOARCH=arm64 CGO_ENABLED=1 CC=$(go env GOROOT)/misc/ios/clangwrap.sh go build -ldflags -w -v -tags ios -o "storj_uplink-arm64.a" -buildmode=c-档案
我使用擦除转换为 dylib 后的下一步
xcrun -sdk iphoneos clang -arch arm64 -fpic -shared -Wl,-all_load storj_uplink-arm64.a -framework Corefoundation -o libuplinkc.dylib
在 Xcode 中,我将依赖项拖到复制文件构建阶段。在 Swift 中,我检查了我需要的各种符号地址,并且可以在该步骤之后进行确认。然而,当实际的二进制文件运行时,我收到一系列运行时错误。
dyld4配置:DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport。动态库
在 lldb 调试器中,此消息是通过 Thread 12 信号 SIGILL 错误给出的。
libuplinkc.dylib`golang.org/x/sys/cpu.getisar0:
-> 0x10c7a36f0 <+0>: mrs x0, ID_AA64ISAR0_EL1
0x10c7a36f4 <+4>: str x0, [sp, #0x8]
0x10c7a36f8 <+8>: ret
0x10c7a36fc <+12>: udf #0x0
Run Code Online (Sandbox Code Playgroud)
根据这些错误和步骤,我相信这与 Go 构建过程有关,但尚不清楚是什么破坏了。如果这有帮助,我正在使用 Storj uplink-c 到 Swift 绑定(此处有相关票证)。人们似乎非常确信 C 库没问题,并建议我去 Go 社区进行更多调试。
小智 1
您可以使用gomobile它为 iOS 构建本机库并从 iOS 应用程序调用您的 go 代码。
https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile#hdr-Build_a_library_for_Android_and_iOS
| 归档时间: |
|
| 查看次数: |
1974 次 |
| 最近记录: |