Skip to content

Commit 7662eee

Browse files
authored
Merge pull request #1 from OneSignal/Supporting_SwiftPM
Supporting swift pm binary target
2 parents c73c0f1 + 1404494 commit 7662eee

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
.swiftpm/.DS_Store
3+
.swiftpm/xcode/.DS_Store
4+
.DS_Store
5+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
6+
.swiftpm
7+
.swiftpm/xcode/xcuserdata
8+
xcuserdata
9+
.swiftpm/xcode/package.xcworkspace/xcuserdata

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "OneSignalXCFramework",
8+
products: [
9+
.library(
10+
name: "OneSignal",
11+
targets: ["OneSignal"]),
12+
],
13+
targets: [
14+
.binaryTarget(
15+
name: "OneSignal",
16+
url: "https://github.com/OneSignal/OneSignal-iOS-SDK/releases/download/3.1.0/OneSignal.xcframework.zip",
17+
checksum: "b7a4bd8bc44bdca452dd19055e7efa20bb3c889a246ad824ba49cd0cbc9b3d86"
18+
)
19+
]
20+
)

update_swift_package.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -e
3+
4+
WORKING_DIR="../OneSignal-iOS-SDK/iOS_SDK/OneSignalSDK/"
5+
6+
FRAMEWORK_FOLDER_NAME="OneSignal_XCFramework"
7+
8+
FRAMEWORK_NAME="OneSignal"
9+
10+
FRAMEWORK_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/${FRAMEWORK_NAME}.xcframework"
11+
12+
FRAMEWORK_ZIP_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/${FRAMEWORK_NAME}.xcframework.zip"
13+
14+
SIMULATOR_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/simulator.xcarchive"
15+
16+
IOS_DEVICE_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/iOS.xcarchive"
17+
18+
CATALYST_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/catalyst.xcarchive"
19+
20+
SWIFT_PACKAGE_DIRECTORY=$(pwd)
21+
22+
SWIFT_PACKAGE_PATH="${SWIFT_PACKAGE_DIRECTORY}/Package.swift"
23+
24+
# Remove the old Zipped XCFramework and create a new Zip
25+
echo "Removing old Zipped XCFramework ${FRAMEWORK_ZIP_PATH}"
26+
rm -rf "${FRAMEWORK_ZIP_PATH}"
27+
echo "Creating new Zipped XCFramework ${FRAMEWORK_ZIP_PATH}"
28+
ditto -c -k --sequesterRsrc --keepParent "${FRAMEWORK_PATH}" "${FRAMEWORK_ZIP_PATH}"
29+
30+
# Compute the checksum for the Zipped framework
31+
echo "Computing package checksum and updating Package.swift ${SWIFT_PACKAGE_PATH}"
32+
CHECKSUM=$(swift package compute-checksum "${FRAMEWORK_ZIP_PATH}")
33+
SWIFT_PM_CHECKSUM_LINE=" checksum: \"${CHECKSUM}\""
34+
# Use sed to remove line 17 from the Swift.package and replace it with the new checksum
35+
sed -i '' "17s/.*/$SWIFT_PM_CHECKSUM_LINE/" "${SWIFT_PACKAGE_PATH}"
36+
#Ask for the new release version number to be placed in the package URL
37+
echo -e "\033[1mEnter the new SDK release version number\033[0m"
38+
read VERSION_NUMBER
39+
SWIFT_PM_URL_LINE=" url: \"https:\/\/github.com\/OneSignal\/OneSignal-iOS-SDK\/releases\/download\/${VERSION_NUMBER}\/OneSignal.xcframework.zip\","
40+
# Use sed to remove line 16 from the Swift.package and replace it with the new URL for the new release
41+
sed -i '' "16s/.*/$SWIFT_PM_URL_LINE/" "${SWIFT_PACKAGE_PATH}"
42+
#Open XCFramework folder to drag zip into new release
43+
open "${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}"
44+

0 commit comments

Comments
 (0)