美文网首页
gomobile导出android/ios sdk注意事项

gomobile导出android/ios sdk注意事项

作者: 谢二九 | 来源:发表于2023-01-17 14:49 被阅读0次

导出命令

iOS

gomobile bind -o ./output/xxx.xcframework -target ios ./dir/a  ./dir/b

Android

gomobile bind -o ./output/xxx.aar -target android -androidapi 21 ./dir/a  ./dir/b

gomobile如何编译参考该文章:https://www.jianshu.com/p/c950e3118ac3

注意事项

  • 导出的只能是基本数据类型、error、指针、interface
    • 数组不能导出,如[]string
    • 字典不能导出,如map[string]string
    • []byte 可以导出,但是在部分iOS机器上执行会crash,也不要使用
  • 导出的方法不能两个及以上返回参数,会在gomobile时报错
functions and methods must return either zero or one values, and optionally an error
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1023ec5f4]
  • 需要导出的方法/实体首字母大写,同时打包命令里包含该文件或其所在目录
  • 导出方法不能与默认方法名冲突,如 xxx.Wait() 会与 android的wait()冲突。

相关文章

网友评论

      本文标题:gomobile导出android/ios sdk注意事项

      本文链接:https://www.haomeiwen.com/subject/balfirtx.html