From 09fbb9e9667fdb640d26a2c69bbaf386e37e9fa2 Mon Sep 17 00:00:00 2001 From: manuroe Date: Fri, 2 Apr 2021 19:05:09 +0200 Subject: [PATCH 1/2] Xcode: Add support of Swift Package Manager Made by Johennes at https://github.com/matrix-org/olm/issues/51#issuecomment-809128833 --- Package.swift | 52 +++++++++++++++++++++++++++ include/module.modulemap | 4 +++ xcode/OLMKit/include/module.modulemap | 13 +++++++ 3 files changed, 69 insertions(+) create mode 100644 Package.swift create mode 100644 include/module.modulemap create mode 100644 xcode/OLMKit/include/module.modulemap diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..47f78cb --- /dev/null +++ b/Package.swift @@ -0,0 +1,52 @@ +// swift-tools-version:5.3 + +import PackageDescription + +let major = 3, minor = 2, patch = 2 + +let package = Package( + name: "Olm", + platforms: [.iOS(.v8), .macOS(.v10_10)], + products: [ + .library(name: "libolm", targets: ["libolm"]), + .library(name: "OLMKit", targets: ["OLMKit"]) + ], + targets: [ + .target( + name: "libolm", + path: ".", + sources: [ + "src", + "lib/crypto-algorithms/aes.c", + "lib/crypto-algorithms/sha256.c", + "lib/curve25519-donna/curve25519-donna.c" + ], + cSettings: [ + .headerSearchPath("lib"), + .define("OLMLIB_VERSION_MAJOR", to: "\(major)"), + .define("OLMLIB_VERSION_MINOR", to: "\(minor)"), + .define("OLMLIB_VERSION_PATCH", to: "\(patch)") + ] + ), + .target( + name: "OLMKit", + dependencies: ["libolm"], + path: "xcode/OLMKit", + exclude: ["Info.plist"], + cSettings: [ + .headerSearchPath("..") + ] + ), + .testTarget( + name: "OLMKitTests", + dependencies: ["OLMKit"], + path: "xcode/OLMKitTests", + exclude: ["Info.plist"], + cSettings: [ + .headerSearchPath("..") + ] + ) + ], + cLanguageStandard: .c99, + cxxLanguageStandard: .cxx11 +) diff --git a/include/module.modulemap b/include/module.modulemap new file mode 100644 index 0000000..ed116dc --- /dev/null +++ b/include/module.modulemap @@ -0,0 +1,4 @@ +module libolm { + header "olm/olm.h" + export * +} diff --git a/xcode/OLMKit/include/module.modulemap b/xcode/OLMKit/include/module.modulemap new file mode 100644 index 0000000..a13330d --- /dev/null +++ b/xcode/OLMKit/include/module.modulemap @@ -0,0 +1,13 @@ +module OLMKit { + header "../OLMAccount.h" + header "../OLMSession.h" + header "../OLMMessage.h" + header "../OLMUtility.h" + header "../OLMInboundGroupSession.h" + header "../OLMOutboundGroupSession.h" + header "../OLMPkEncryption.h" + header "../OLMPkDecryption.h" + header "../OLMPkSigning.h" + header "../OLMSAS.h" + export * +} From 26bd2fc35d1dc23c5a665319ad4140bb48418132 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 6 Apr 2021 17:18:50 +0200 Subject: [PATCH 2/2] Swift package: Update instructions --- .gitignore | 1 + README.md | 2 +- xcode/README.rst | 13 ++++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 87c1bbe..95c12e3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # Xcode build/ +.build/ DerivedData/ *.pbxuser !default.pbxuser diff --git a/README.md b/README.md index 6958d19..73d8005 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Note that bindings may have a different license from libolm. ## Release process First: bump version numbers in ``common.mk``, ``CMakeLists.txt``, -``javascript/package.json``, ``python/olm/__version__.py``, ``OLMKit.podspec``, +``javascript/package.json``, ``python/olm/__version__.py``, ``OLMKit.podspec``, ``Package.swift``, and ``android/olm-sdk/build.gradle`` (``versionCode``, ``versionName`` and ``version``). diff --git a/xcode/README.rst b/xcode/README.rst index d56fa85..aeff5dc 100644 --- a/xcode/README.rst +++ b/xcode/README.rst @@ -12,15 +12,22 @@ the latest OLMKit release is:: pod 'OLMKit' +Or you can use Swift Package Manager with the URL:: + + https://gitlab.matrix.org/matrix-org/olm + Development ----------- -Run `pod install` and open `OLMKit.xcworkspace`. +Run `pod install` and open `OLMKit.xcworkspace` with Xcode. The project contains only tests files. The libolm and the Objective-C wrapper source files are loaded via the OLMKit CocoaPods pod. To add a new source file, add it to the file system and run `pod update` to make CocoaPods insert it into OLMKit.xcworkspace. +Development alternative +----------------------- +Based on the Swift package, you can build source files and run tests directly from the command line: `swift test`. + Release ------- -See ../README.rst for the release of the CocoaPod. - +See ../README.rst for the release of the CocoaPod and the Swift package.