-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SPM support with XCF (#789) * add SPM support with XCF * add swift SPM test project * add macOS swift SPM example, updated iOS one * updates per pr comments * removed cl-openssl from Themis.xcodeproj + edits per pr comments + extra comments * removed example projects * updated xcodeproj version * updated Package.swift * updated changelog * Update CHANGELOG.md Co-authored-by: vixentael <[email protected]> Co-authored-by: vixentael <[email protected]> * fixed automerge issue * fixed typo Co-authored-by: vixentael <[email protected]>
- Loading branch information
Showing
4 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// swift-tools-version:5.3 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "themis", | ||
products: [ | ||
.library( | ||
name: "themis", | ||
targets: ["themis"]), | ||
], | ||
// OpenSSL XCF is statically linked to Themis XCF, so no need to have it as a dependency | ||
dependencies: [], | ||
targets: [ | ||
.binaryTarget(name: "themis", | ||
// update version in URL path | ||
url: "https://github.com/cossacklabs/themis/releases/download/0.13.7/themis.xcframework.zip", | ||
// The scripts/create_xcframework.sh calculates the checksum when generating the XCF. | ||
// Alternatively, run from package directory: | ||
// swift package compute-checksum build/xcf_output/themis.xcframework.zip | ||
checksum: "9e7b42fa1b9c49a1e28ede9eb5e17340ea6a4e0f57de806db874cb22568bef96"), | ||
|
||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Shebang to explicitly use bash and not break on macOS boxes with zsh as default shell. | ||
# | ||
# This script generates Themis xcframework for iOS and macOS. | ||
# Run it from the repo root so the xcodebuild command finds Themis.xcodeproj | ||
|
||
set -eu # common flags to ensure that the shell does not ignore failures | ||
|
||
BUILD_PATH=${BUILD_PATH:-build} | ||
output_dir=$BUILD_PATH/xcf_output | ||
project_dir=$(pwd) #repo root where Themis.xcodeproj and Package.swift are | ||
|
||
# creating required xcframework structure | ||
mkdir -p $output_dir/archives | ||
mkdir -p $output_dir/iphoneos | ||
mkdir -p $output_dir/macosx | ||
|
||
# build the framework for iOS devices | ||
xcodebuild archive \ | ||
-scheme "Themis (iOS)" \ | ||
-destination="iOS" \ | ||
-archivePath $output_dir/archives/ios.xcarchive \ | ||
-derivedDataPath $output_dir/iphoneos \ | ||
-sdk iphoneos \ | ||
SKIP_INSTALL=NO \ | ||
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES | ||
|
||
# build the framework for iOS simulator | ||
xcodebuild archive \ | ||
-scheme "Themis (iOS)" \ | ||
-destination="iOS Simulator" \ | ||
-archivePath $output_dir/archives/iossimulator.xcarchive \ | ||
-derivedDataPath $output_dir/iphoneos \ | ||
-sdk iphonesimulator \ | ||
SKIP_INSTALL=NO \ | ||
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES | ||
|
||
# build the framework for macOS | ||
xcodebuild archive \ | ||
-scheme "Themis (macOS)" \ | ||
-destination="macOS" \ | ||
-archivePath $output_dir/archives/macosx.xcarchive \ | ||
-derivedDataPath $output_dir/macosx \ | ||
-sdk macosx \ | ||
SKIP_INSTALL=NO \ | ||
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES | ||
|
||
# gather separate frameworks into a single xcframework | ||
xcodebuild -create-xcframework \ | ||
-framework $output_dir/archives/ios.xcarchive/Products/Library/Frameworks/themis.framework \ | ||
-framework $output_dir/archives/iossimulator.xcarchive/Products/Library/Frameworks/themis.framework \ | ||
-framework $output_dir/archives/macosx.xcarchive/Products/Library/Frameworks/themis.framework \ | ||
-output $output_dir/themis.xcframework | ||
|
||
# deleting the artifacts | ||
rm -rf $output_dir/archives | ||
rm -rf $output_dir/iphoneos | ||
rm -rf $output_dir/macosx | ||
|
||
# zip the xcodeframework | ||
# SPM accepts binary targets only in zip format | ||
cd $output_dir | ||
zip -r themis.xcframework.zip themis.xcframework | ||
|
||
rm -rf themis.xcframework | ||
|
||
# calculate checksum from the directory with Package.swift | ||
# update the the checksum in Package.swift if that is a new release | ||
cd $project_dir | ||
echo "XCF Checksum:" | ||
swift package compute-checksum $output_dir/themis.xcframework.zip |