gosdk for mobile builds (iOS and Android)

Setup gomobile

gosdk can be build to use on Mobile platforms iOS and Android using gomobile. To setup gomobile environment.
  1. 1.
    Make sure $HOME/go/bin/ is in your $PATH. If it's not, edit your bash profile to add it. Your profile is a file in your home directory named either .profile or .bash_profile. It should contain a line like this:
    export PATH=${PATH}:$HOME/go/bin/
  2. 2.
    Now to install and intialize gomobile package:
    go install golang.org/x/mobile/cmd/[email protected] init
  3. 3.
    Run below command inside the gosdk directory for the first time to setup gomobile environment
make setup-gomobile
Sample Response: ​ ​ Initializing gomobile. Please wait it may take a while ... ​ ------------------------------------------------------------ ​ go: downloading golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 ​ go: downloading golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 ​ go: downloading golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df ​ go: downloading golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab ​​

Build Mobile SDK

  1. 1.
    Now lets build Mobile SDK.
    For Android :Android studio with NDK is required to build SDK for Android.
    For iOS: Xcode Command Line Tools is required to build SDK for iOS.
  2. 2.
    Commands for building mobilesdk are below :
For iOS only: make build-ios
For Android only: make build-mobilesdk ANDROID=1
Sample Response for android :
make build-mobilesdk ANDROID=1
gosdk is not in GOPATH.
Creating softlink...Building Android framework.
Please wait... /home/ubuntu/gosdk/out/androidsdk/zcncore.aar. - [OK]
Sample Response for iOS :
xcframework successfully written out to:
/Users/sakshinayak/gosdk/out/iossdk/ios/zcncore.xcframework. - [OK]
The response will successfully build a library file which includes everything needed to build a 0chain mobile app, including source code, resource files, and an Android manifest. Now you can use the 0chain library into your own project.