Skip to content

Commit

Permalink
Patch fula ios build (#139)
Browse files Browse the repository at this point in the history
* add patch to build for ios

* update the readme file

* add cocoapods spec

* add github action for cocoapods builds

* add cocoapods bundler

* typo fix

* add gomobile init

* small fix

* add release perm

* small fix

---------

Co-authored-by: Homayoun <[email protected]>
  • Loading branch information
ehsan6sha and Homayoun authored May 19, 2023
1 parent c07f3c2 commit 4ea89b2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions FulaMobile.podspec
Original file line number Diff line number Diff line change
@@ -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' => '[email protected]' }
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
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4ea89b2

Please sign in to comment.