Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests/swift/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ runs:
working-directory: ./wrappers/swift
shell: bash
run: sh generate.sh

- name: Upload package
uses: actions/upload-artifact@v4.3.6
with:
name: swift
path: ./wrappers/swift/package
22 changes: 22 additions & 0 deletions wrappers/swift/DevolutionsCryptoSwift.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Pod::Spec.new do |s|
s.name = 'DevolutionsCryptoSwift'
s.version = '0.9.2'
s.summary = 'A Swift wrapper around Devolutions Crypto Rust crate'

s.homepage = 'https://github.com/Devolutions/devolutions-crypto.git'
s.license = { :type => 'MIT', :file => './LICENSE-MIT' }
s.author = { 'Devolutions Security' => 'security@devolutions.net' }
s.source = {
:git => 'https://github.com/Devolutions/devolutions-crypto.git',
:tag => s.version.to_s
}

s.swift_version = '5.0'
s.ios.deployment_target = '16.0'

s.vendored_frameworks = 'DevolutionsCrypto.xcframework'
s.source_files = [
'Sources/**/*.{swift}',
'Tests/**/*.{swift}',
]
end
37 changes: 28 additions & 9 deletions wrappers/swift/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,32 @@ mv "./bindings/devolutions_cryptoFFI.modulemap" ./bindings/module.modulemap
# combine the platforms

# ios simulator
lipo "../../target/x86_64-apple-ios/release/lib$LIBNAME.a" \
"../../target/aarch64-apple-ios-sim/release/lib$LIBNAME.a" \
-create -output "./bindings/ios-simulator/lib$LIBNAME.a"
lipo "../../target/x86_64-apple-ios/release/lib$LIBNAME.dylib" \
"../../target/aarch64-apple-ios-sim/release/lib$LIBNAME.dylib" \
-create -output "./bindings/ios-simulator/lib$LIBNAME.dylib"

# mac
lipo ../../target/x86_64-apple-darwin/release/lib$LIBNAME.a \
../../target/aarch64-apple-darwin/release/lib$LIBNAME.a \
-create -output ./bindings/mac/lib$LIBNAME.a
lipo ../../target/x86_64-apple-darwin/release/lib$LIBNAME.dylib \
../../target/aarch64-apple-darwin/release/lib$LIBNAME.dylib \
-create -output ./bindings/mac/lib$LIBNAME.dylib


# no need to combine ios

# Move headers
mkdir headers
cp ./bindings/devolutions_crypto.swift ./headers
cp ./bindings/devolutions_cryptoFFI.h ./headers
cp ./bindings/module.modulemap ./headers

# create the XCFramework
xcodebuild -create-xcframework \
-library "./bindings/ios-simulator/lib$LIBNAME.a" -headers ./bindings \
-library "./bindings/mac/lib$LIBNAME.a" -headers ./bindings \
-library "../../target/aarch64-apple-ios/release/lib$LIBNAME.a" -headers ./bindings \
-library "./bindings/ios-simulator/lib$LIBNAME.dylib" -headers ./headers \
-library "./bindings/mac/lib$LIBNAME.dylib" -headers ./headers \
-library "../../target/aarch64-apple-ios/release/lib$LIBNAME.dylib" -headers ./headers \
-output "$XCFRAMEWORK_FOLDER"


# Compress XCFramework
ditto -c -k --sequesterRsrc --keepParent "$XCFRAMEWORK_FOLDER" "$XCFRAMEWORK_FOLDER.zip"

Expand All @@ -68,4 +75,16 @@ cd ./DevolutionsCryptoSwift

swift test

cd ../

mkdir package

cp -R ./output/DevolutionsCrypto.xcframework ./package
cp -R ./DevolutionsCryptoSwift/Sources ./package
cp -R ./DevolutionsCryptoSwift/Tests ./package
cp ./DevolutionsCryptoSwift/Package.swift ./package
cp ./DevolutionsCryptoSwift.podspec ./package

sed -i '' 's|\.\./output/DevolutionsCrypto\.xcframework|./DevolutionsCrypto\.xcframework|g' ./package/Package.swift