GoSDK for mobile builds (iOS and Android)
GoSDK can be built to use on mobile platforms iOS and Android using gomobile. To setup gomobile environment :
- 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.Now to install and intialize gomobile package
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
- 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
- 1.Now, let's build the Mobile SDK
- 2.Commands for building mobilesdk are below :
For iOS only: make build-ios
For Android only: make build-android
Sample Response for android :
jar: zcncore/Zcncore.java
C:/Users/0chain/Desktop/gosdk/out/androidsdk/zcncore.aar. - [OK]
Sample Response for iOS:
xcframework successfully written out to:
/Users//gosdk/out/iossdk/ios/zcncore.xcframework
/Users/0chain/gosdk/out/iossdk/ios/zcncore.xcframework. - [OK]
The response will successfully build a library file which includes everything needed to build a Züs mobile app, including source code and resource files. Now you can use the library into your own iOS or Android project.
In case of build errors check troubleshooting section below .
1. Java Development Kit(JDK) path has to be set to build libraries for Android with out any errors. Here is the command for setting JDK path (replace it with path where JDK is installed on your system)
set path = "%path%;c:program files\java\jdk1.7.0\bin"
2. NDK has to be properly installed for building libraries on Android. To check it go to
Android Studio > File > Project Structure...>
Make sure the directory path includes the version number for NDK (e.g. C:\Users...\ndk\21.3.6528147)
Last modified 4mo ago