diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml new file mode 100644 index 00000000..408a21a8 --- /dev/null +++ b/.github/workflows/build-ios.yml @@ -0,0 +1,38 @@ +name: Build for iOS + +on: + push: + tags: + - '*' + +jobs: + build: + name: Build & check fula mobile for ios + runs-on: macos-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: "1.19.x" + - name: Go information + run: | + go version + go env + - name: Run tests + run: go test -v -shuffle=on ./mobile + + - name: Build the artifact + if: startsWith(github.ref, 'refs/tags/') + run: make fula-xcframework + + - name: Release + uses: softprops/action-gh-release@v1 + # if: startsWith(github.ref, 'refs/tags/') + with: + files: | + build/cocoapods-bundle.zip + build/cocoapods-bundle.zip.sha256 diff --git a/FulaMobile.podspec b/FulaMobile.podspec new file mode 100644 index 00000000..af8ba80a --- /dev/null +++ b/FulaMobile.podspec @@ -0,0 +1,19 @@ +Pod::Spec.new do |s| + s.name = 'FulaMobile' # Name for your pod + s.version = '0.1.6' + s.summary = 'Go-fula for iOS' + s.homepage = 'https://github.com/functionland/go-fula' + + s.author = { 'Functionland' => 'info@fx.land' } + s.license = { :type => 'MIT', :file => 'LICENSE' } + + s.platform = :ios + # change the source location + s.source = { :http => "https://github.com/functionland/go-fula/releases/download/v#{s.version}/cocoapods-bundle.zip" } + s.source_files = "include/*.{h}" + s.module_map = "include/module.modulemap" + s.ios.deployment_target = '11.0' + s.ios.vendored_libraries = 'Fula' + s.osx.vendored_libraries = 'Fula' + s.static_framework = true +end \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..47cfee2f --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +GO_MOD_REPLACEMENT=replace github.com/raulk/go-watchdog => ./tmp-fula-build/go-watchdog +all: + go test ./... + +fula-xcframework: patch-go-watchdog prepare-gomobile build-fula-xcframework bundles +patch-go-watchdog: + mkdir -p tmp-fula-build &&\ + cd tmp-fula-build &&\ + git clone https://github.com/status-im/go-watchdog &&\ + cd go-watchdog &&\ + git checkout v1.2.0-ios-nolibproc &&\ + cd ../.. &&\ + echo "$(GO_MOD_REPLACEMENT)" >> go.mod &&\ + go mod tidy + +prepare-gomobile: + go install golang.org/x/mobile/cmd/gomobile@latest &&\ + go get -u golang.org/x/mobile/bind && go install golang.org/x/mobile/bind + +build-fula-xcframework: + gomobile init &&\ + gomobile bind -v -o Fula.xcframework -target=ios github.com/functionland/go-fula/mobile + +bundles: + mkdir -p build &&\ + cp LICENSE ./build/LICENSE && cd build &&\ + cp ../Fula.xcframework/ios-arm64/Fula.framework/Fula libfula_ios.a &&\ + cp ../Fula.xcframework/ios-arm64_x86_64-simulator/Fula.framework/Fula libfula_iossimulator.a &&\ + zip -r ./cocoapods-bundle.zip ./libfula_iossimulator.a ./libfula_ios.a && echo "$$(openssl dgst -sha256 ./cocoapods-bundle.zip)" > ./cocoapods-bundle.zip.sha256 + +clean-up: + grep -v "$(GO_MOD_REPLACEMENT)" ./go.mod > ./tmp.mod ; mv ./tmp.mod ./go.mod &&\ + rm -rf ./tmp-fula-build &&\ + rm -rf ./build &&\ + go mod tidy diff --git a/README.md b/README.md index 1ec582fc..7ef6941b 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,12 @@ The default generated config goes to a YAML file in home directory, under /.fula goreleaser --rm-dist --snapshot ``` +## Build for the iOS platform (using gomobile) +This process includes some iOS specific preparation. +```sh +make fula-xcframework +``` + ## License