Skip to content

Commit

Permalink
feat: generate XCFramework when releasing for Swift (wireapp#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
typfel authored Jun 2, 2023
1 parent 4970ee1 commit 19fd4c0
Show file tree
Hide file tree
Showing 14 changed files with 480 additions and 476 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: |
cd crypto-ffi
cargo make create-swift-package
cd bindings/swift
swift build
cargo make ios
check-wasm:
runs-on: ubuntu-latest
Expand Down
27 changes: 6 additions & 21 deletions .github/workflows/publish-swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,11 @@ jobs:
targets: "aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim"
- name: Setup cargo-make
uses: davidB/rust-cargo-make@v1

- name: Build and Publish Swift package
env:
GIT_SSH_COMMAND: "ssh -i /Users/runner/.ssh/id_rsa -o UserKnownHostsFile=/Users/runner/.ssh/known_hosts"
- name: Build xcframework
run: |
export SEMANTIC_VERSION=$(echo $GITHUB_REF_NAME | sed 's/^v\(.*\)/\1/')
mkdir -p /Users/runner/.ssh
echo "${{ secrets.SSH_DEPLOY_KEY }}" > /Users/runner/.ssh/id_rsa
chmod 600 /Users/runner/.ssh/id_rsa
cd crypto-ffi
ssh-keyscan -H github.com > /Users/runner/.ssh/known_hosts
cargo make create-swift-package
cd ../../
git clone [email protected]:wireapp/core-crypto-swift.git
cd core-crypto-swift
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
cp -r ../core-crypto/crypto-ffi/bindings/swift/* ./
git add .
git commit -m "chore: release of core-crypto $GITHUB_REF_NAME"
git tag $SEMANTIC_VERSION
git push origin main
git push origin $SEMANTIC_VERSION
cargo make create-ios-xcframework
- name: Upload xcframework
uses: softprops/action-gh-release@v1
with:
files: crypto-ffi/bindings/swift/WireCoreCrypto.xcframework.zip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ crypto-ffi/bindings/*/out
crypto-ffi/bindings/*/.build
crypto-ffi/bindings/*/build
crypto-ffi/bindings/*/.swiftpm
**/WireCoreCrypto/CoreCrypto.swift
**/WireCoreCrypto/core_cryptoFFI.h
DerivedData/
*.moved-aside
*.pbxuser
Expand Down
16 changes: 3 additions & 13 deletions crypto-ffi/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,16 @@ args = ["build", "--target", "aarch64-apple-ios-sim", "--features", "mobile", "-
condition = { platforms = ["mac"] }
dependencies = ["ios-device", "ios-simulator-x86", "ios-simulator-arm"]

[tasks.ios-test-sim-build]
[tasks.ios-create-xcframework]
condition = { platforms = ["mac"] }
script = '''
cd bindings/swift
swift build
'''
dependencies = ["create-swift-package"]

[tasks.create-swift-package]
condition = { platforms = ["mac"] }
script = '''
cd bindings/swift
lipo -create -output ./lib/libcore_crypto_ffi.a \
../../../target/x86_64-apple-ios/release/libcore_crypto_ffi.a \
../../../target/aarch64-apple-ios/release/libcore_crypto_ffi.a
./create-xcframework.sh
'''
dependencies = ["ios"]


################################### Android ###################################

[tasks.android-env]
Expand Down
33 changes: 0 additions & 33 deletions crypto-ffi/bindings/swift/Package.swift

This file was deleted.

22 changes: 22 additions & 0 deletions crypto-ffi/bindings/swift/WireCoreCrypto/BuildSettings.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Wire
// Copyright (C) 2023 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

CURRENT_PROJECT_VERSION = 11.0.0
Loading

0 comments on commit 19fd4c0

Please sign in to comment.