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
23 changes: 23 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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"]),
],
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.
ilammy marked this conversation as resolved.
Show resolved Hide resolved
.binaryTarget(name: "themis",
url: "https://github.com/julepka/themis/releases/download/2.2.1/themis.xcframework.zip",
// $swift package compute-checksum output/themis.xcframework.zip
checksum: "b4a8d8868cbd09499d75a10315d1231281d40dee11d1fe549cf4893967f3ee38"),

]
)
39 changes: 38 additions & 1 deletion Themis.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
6D0A527E25FA2E7000C49E55 /* cl-openssl in Frameworks */ = {isa = PBXBuildFile; productRef = 6D0A527D25FA2E7000C49E55 /* cl-openssl */; };
6D0A528025FA2E8300C49E55 /* cl-openssl in Frameworks */ = {isa = PBXBuildFile; productRef = 6D0A527F25FA2E8300C49E55 /* cl-openssl */; };
9F00E8E2223C1A3300EC1EF3 /* objcthemis.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F4A24B5223A8FA8005CB63A /* objcthemis.h */; settings = {ATTRIBUTES = (Public, ); }; };
9F00E8E3223C1A3300EC1EF3 /* scell_context_imprint.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F4A24B9223A8FA8005CB63A /* scell_context_imprint.h */; settings = {ATTRIBUTES = (Public, ); }; };
9F00E8E4223C1A3300EC1EF3 /* scell_seal.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F4A24BC223A8FA8005CB63A /* scell_seal.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -519,6 +521,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
6D0A528025FA2E8300C49E55 /* cl-openssl in Frameworks */,
9F00E941223C1AFA00EC1EF3 /* openssl.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -527,6 +530,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
6D0A527E25FA2E7000C49E55 /* cl-openssl in Frameworks */,
9FBD853D223BFB5E009EAEB3 /* openssl.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -947,6 +951,9 @@
dependencies = (
);
name = "Themis (macOS)";
packageProductDependencies = (
6D0A527F25FA2E8300C49E55 /* cl-openssl */,
);
productName = "Themis (macOS)";
productReference = 9F00E8D7223C197900EC1EF3 /* themis.framework */;
productType = "com.apple.product-type.framework";
Expand All @@ -964,6 +971,9 @@
dependencies = (
);
name = "Themis (iOS)";
packageProductDependencies = (
6D0A527D25FA2E7000C49E55 /* cl-openssl */,
);
productName = Themis;
productReference = 9F4A24A1223A8D7F005CB63A /* themis.framework */;
productType = "com.apple.product-type.framework";
Expand Down Expand Up @@ -1077,6 +1087,9 @@
Base,
);
mainGroup = 738B81052239809D00A9947C;
packageReferences = (
6D0A527C25FA2E7000C49E55 /* XCRemoteSwiftPackageReference "openssl-apple" */,
);
productRefGroup = 738B81102239809D00A9947C /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -1874,6 +1887,30 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
6D0A527C25FA2E7000C49E55 /* XCRemoteSwiftPackageReference "openssl-apple" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/julepka/openssl-apple";
requirement = {
kind = upToNextMajorVersion;
ilammy marked this conversation as resolved.
Show resolved Hide resolved
minimumVersion = 1.1.1080202;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
minimumVersion = 1.1.1080202;
minimumVersion = 1.1.108203;

TODO: re-define version after merging cossacklabs/openssl-apple#22

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, and the link will point to the cosacklabs repo.

};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
6D0A527D25FA2E7000C49E55 /* cl-openssl */ = {
isa = XCSwiftPackageProductDependency;
package = 6D0A527C25FA2E7000C49E55 /* XCRemoteSwiftPackageReference "openssl-apple" */;
productName = "cl-openssl";
};
6D0A527F25FA2E8300C49E55 /* cl-openssl */ = {
isa = XCSwiftPackageProductDependency;
package = 6D0A527C25FA2E7000C49E55 /* XCRemoteSwiftPackageReference "openssl-apple" */;
productName = "cl-openssl";
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 738B81062239809D00A9947C /* Project object */;
}
47 changes: 47 additions & 0 deletions create_xcframeworks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
mkdir output
mkdir output/archives
mkdir output/iphoneos
mkdir output/macosx
ilammy marked this conversation as resolved.
Show resolved Hide resolved

xcodebuild archive \
-scheme "Themis (iOS)" \
-destination="iOS" \
-archivePath output/archives/ios.xcarchive \
-derivedDataPath output/iphoneos \
-sdk iphoneos \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
ilammy marked this conversation as resolved.
Show resolved Hide resolved

xcodebuild archive \
-scheme "Themis (iOS)" \
-destination="iOS Simulator" \
-archivePath output/archives/iossimulator.xcarchive \
-derivedDataPath output/iphoneos \
-sdk iphonesimulator \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

xcodebuild archive \
-scheme "Themis (macOS)" \
-destination="macOS" \
-archivePath output/archives/macosx.xcarchive \
-derivedDataPath output/macosx \
-sdk macosx \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

xcodebuild -create-xcframework \
-framework output/archives/ios.xcarchive/Products/Library/Frameworks/themis.framework \
-framework output/archives/iossimulator.xcarchive/Products/Library/Frameworks/themis.framework \
-framework output/archives/macosx.xcarchive/Products/Library/Frameworks/themis.framework \
-output output/themis.xcframework

rm -rf output/archives
rm -rf output/iphoneos
rm -rf output/macosx

cd output
zip -r themis.xcframework.zip themis.xcframework

rm -rf themis.xcframework

cd ..
echo "XCF Chechsum:"
ilammy marked this conversation as resolved.
Show resolved Hide resolved
swift package compute-checksum output/themis.xcframework.zip