Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SPM support with XCF #789

Merged
merged 11 commits into from
Apr 28, 2021
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ let package = Package(
name: "themis",
targets: ["themis"]),
],
// OpenSSL XCF is statically linked to Themis XCF, so no need to have it as a dependency
dependencies: [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I wanted to ask, “Where is cl-openssl?“ But then I realized that it's not here because themis.xcframework will be statically linked to openssl.xcframework, hence users of themis.xcframework don't need to install shared OpenSSL.

targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.binaryTarget(name: "themis",
// update version in URL path
url: "https://github.com/julepka/themis/releases/download/2.2.1/themis.xcframework.zip",
// Run from package directory:
// $swift package compute-checksum output/themis.xcframework.zip
checksum: "b4a8d8868cbd09499d75a10315d1231281d40dee11d1fe549cf4893967f3ee38"),
ilammy marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
4 changes: 2 additions & 2 deletions Themis.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1893,8 +1893,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/julepka/openssl-apple";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.1.1080202;
kind = exactVersion;
version = 1.1.1080202;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
47 changes: 0 additions & 47 deletions create_xcframeworks.sh

This file was deleted.

66 changes: 66 additions & 0 deletions scripts/create_xcframeworks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
#
# Shebang to explicitly use bash and not break on macOS boxes with zsh as default shell.
#
# After that you usually describe what this script is for and how to use it. In particular,
# what it expects the current directory to be. (That's more important if it's it "scripts".)
ilammy marked this conversation as resolved.
Show resolved Hide resolved

set -eu # common flags to ensure that the shell does not ignore failures

BUILD_PATH=build
output_dir=$BUILD_PATH/xcf_output
ilammy marked this conversation as resolved.
Show resolved Hide resolved

cd ..
repo_root_path=$(pwd)
ilammy marked this conversation as resolved.
Show resolved Hide resolved

mkdir $BUILD_PATH
mkdir $output_dir
mkdir $output_dir/archives
mkdir $output_dir/iphoneos
mkdir $output_dir/macosx
ilammy marked this conversation as resolved.
Show resolved Hide resolved

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

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

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

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

rm -rf $output_dir/archives
rm -rf $output_dir/iphoneos
rm -rf $output_dir/macosx

cd $output_dir
zip -r themis.xcframework.zip themis.xcframework

rm -rf themis.xcframework

cd "$repo_root_path"
echo "XCF Checksum:"
swift package compute-checksum $output_dir/themis.xcframework.zip