gomobile導(dǎo)出android/ios sdk注意事項(xiàng)

導(dǎo)出命令

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如何編譯參考該文章:http://www.itdecent.cn/p/c950e3118ac3

注意事項(xiàng)

  • 導(dǎo)出的只能是基本數(shù)據(jù)類型、error、指針、interface
    • 數(shù)組不能導(dǎo)出,如[]string
    • 字典不能導(dǎo)出,如map[string]string
    • []byte 可以導(dǎo)出,但是在部分iOS機(jī)器上執(zhí)行會crash,也不要使用
  • 導(dǎo)出的方法不能兩個及以上返回參數(shù),會在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]
  • 需要導(dǎo)出的方法/實(shí)體首字母大寫,同時打包命令里包含該文件或其所在目錄
  • 導(dǎo)出方法不能與默認(rèn)方法名沖突,如 xxx.Wait() 會與 android的wait()沖突。
  • 不支持同時集成兩個gomobile編譯的framework,會報錯 duplicate symbol
  • 針對iOS,當(dāng)函數(shù)有多個參數(shù),需要保證interface和implemention的行參名稱一致,因?yàn)闀唇觨c方法
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容