Skip to content

Commit

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

* add github action for cocoapods builds

* add cocoapods bundler

* add gomobile init

* small fix

* small fix

* Add headers to cocoapods bundle

* typo fix

* lipo ios archs

* lipo: remove unused arm64 arch

* fix ios version

* switch to vendored frameworks

* add proper versining

* update the ios workflows

* removed extra whitspace

---------

Co-authored-by: Homayoun <homayoun@Homayouns-MacBook-Pro.local>
Co-authored-by: ehsan shariati <ehsan6sha@gmail.com>
  • Loading branch information
3 people committed Jul 18, 2023
1 parent dd13411 commit 7ddaa0d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 23 deletions.
33 changes: 24 additions & 9 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ name: Build for iOS

on:
push:
tags:
- '*'
pull_request:
release:
types: [published]

jobs:
build:
name: Build & check fula mobile for ios
runs-on: macos-latest
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -26,13 +28,26 @@ jobs:
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/')
- name: Upload release asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/cocoapods-bundle.zip
asset_name: cocoapods-bundle.zip
asset_content_type: application/zip

- name: Upload release asset checksum
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
build/cocoapods-bundle.zip
build/cocoapods-bundle.zip.sha256
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/cocoapods-bundle.zip.sha256
asset_name: cocoapods-bundle.zip.sha256
asset_content_type: text/plain
30 changes: 30 additions & 0 deletions .github/workflows/ensure-podspec-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Update Podspec Version

on:
release:
types: [published]

jobs:
update-version:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Update version
run: |
VERSION=$(echo ${{ github.event.release.tag_name }} | cut -c 2-) # remove the v from the tag name
sed -i 's/\(s.version\s*=\s*\).*$/\1\''"$VERSION"'\'/' Fula.podspec
sed -i 's/#{s.version}/'"$VERSION"'/' Fula.podspec
- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Commit and push
run: |
git add .
git commit -m "Update version to $VERSION"
git push
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ dist
**.env
*/**/tmp
wap/wap
.history/*
.history/*
.env
build
tmp-fula-build
16 changes: 8 additions & 8 deletions FulaMobile.podspec → Fula.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FulaMobile' # Name for your pod
s.version = '0.1.6'
s.name = 'Fula' # Name for your pod
s.version = '1.0.0'
s.summary = 'Go-fula for iOS'
s.homepage = 'https://github.com/functionland/go-fula'

Expand All @@ -10,10 +10,10 @@ Pod::Spec.new do |s|
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.ios.deployment_target = '13.0'
s.vendored_framework = 'Fula.xcframework'
s.static_framework = true
end
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
end
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ GO_MOD_REPLACEMENT=replace github.com/raulk/go-watchdog => ./tmp-fula-build/go-w
all:
go test ./...

fula-xcframework: patch-go-watchdog prepare-gomobile build-fula-xcframework bundles
fula-xcframework: patch-go-watchdog prepare-gomobile build-fula-xcframework build-bundle zip

patch-go-watchdog:
mkdir -p tmp-fula-build &&\
cd tmp-fula-build &&\
Expand All @@ -21,12 +22,14 @@ build-fula-xcframework:
gomobile init &&\
gomobile bind -v -o Fula.xcframework -target=ios github.com/functionland/go-fula/mobile

bundles:
build-bundle:
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
mv ../Fula.xcframework .

zip:
cd build &&\
zip -r ./cocoapods-bundle.zip ./Fula.xcframework ./LICENSE && 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 &&\
Expand Down

0 comments on commit 7ddaa0d

Please sign in to comment.