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

Adding XCFramework distribution #671

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 8 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ jobs:
with:
submodules: recursive
- name: Check symbolic links
run: find . -type d -name .build -prune -o -type l ! -exec test -e {} \; -print | grep -q . && exit 1 || exit 0
run: |
broken_links=$(find . -type d -name .build -prune -o -type l ! -exec test -e {} \; -print)
if [ -n "$broken_links" ]; then
echo "Broken symbolic links found:"
echo "$broken_links"
exit 1
fi
- name: Build the Docker zkp image
run: docker build .
- name: Build the Docker secp256k1 image
run: docker build -f Exhaustive/Package/Dockerfile .
run: docker build .
82 changes: 82 additions & 0 deletions .github/workflows/xcframework-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@



name: XCFramework Release
on:
release:
types: [published]
jobs:
macos:
name: Build XCFramework
runs-on: macos-15
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Generate Xcode project
run: swift package --disable-sandbox tuist generate -p Projects/ --no-open
- name: Archive & Create XCFramework
run: |
# Define workspace and scheme
WORKSPACE='Projects/XCFramework.xcworkspace'
SCHEME='P256K'
CONFIGURATION='Release'
ARCHIVE_DIR='Archives'

# Platforms to archive
PLATFORMS=(
"iOS"
"iOS Simulator"
"macOS"
"tvOS"
"tvOS Simulator"
"watchOS"
"watchOS Simulator"
"visionOS"
)

# Loop over platforms and archive for each one
for PLATFORM in "${PLATFORMS[@]}"; do
echo "Archiving for $PLATFORM..."

# Run xcodebuild archive for each platform
xcodebuild archive \
-workspace "$WORKSPACE" \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-destination "generic/platform=$PLATFORM" \
-archivePath "$ARCHIVE_DIR/P256K-$PLATFORM.xcarchive"

# Check if archive command was successful
if [ $? -eq 0 ]; then
echo "$PLATFORM archive created successfully."
else
echo "Failed to archive for $PLATFORM. Exiting."
exit 1
fi
done

echo "All archives completed successfully."

# Create an XCFramework to support multiple platforms and architectures
# Each -archive parameter specifies a path to a .xcarchive built for a different platform
# -framework specifies the framework within those archives to include in the XCFramework
# The -output parameter specifies the name and location of the XCFramework to be created
xcodebuild -create-xcframework \
-archive "Archives/P256K-iOS.xcarchive" -framework P256K.framework \
-archive "Archives/P256K-iOS Simulator.xcarchive" -framework P256K.framework \
-archive "Archives/P256K-macOS.xcarchive" -framework P256K.framework \
-archive "Archives/P256K-tvOS.xcarchive" -framework P256K.framework \
-archive "Archives/P256K-tvOS Simulator.xcarchive" -framework P256K.framework \
-archive "Archives/P256K-watchOS.xcarchive" -framework P256K.framework \
-archive "Archives/P256K-watchOS Simulator.xcarchive" -framework P256K.framework \
-output P256K.xcframework
- name: 7z XCFramework
run: |
7z a -tzip -mx=9 P256K.xcframework.zip P256K.xcframework
- name: Upload XCFramework
run: |
gh release upload ${{ github.ref_name }} P256K.xcframework.zip
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ADD . /LinuxTests
WORKDIR /LinuxTests

# Execute Linux test suite
RUN swift test -v && swift build --target secp256k1
RUN swift test
11 changes: 0 additions & 11 deletions Exhaustive/Package/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions Exhaustive/Package/Package.swift

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 11 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@ let package = Package(
name: "swift-secp256k1",
products: [
// WARNING: These APIs should not be considered stable and may change at any time.
.library(name: "secp256k1", targets: ["secp256k1"]),
.library(name: "zkp", targets: ["zkp"])
.library(name: "libsecp256k1", targets: ["libsecp256k1"]),
.library(name: "libsecp256k1_zkp", targets: ["libsecp256k1_zkp"]),
.library(name: "P256K", targets: ["P256K"]),
.library(name: "ZKP", targets: ["ZKP"])
],
dependencies: [
// Dependencies used for package development
.package(url: "https://github.com/csjones/lefthook-plugin.git", exact: "1.11.2"),
.package(url: "https://github.com/21-DOT-DEV/swift-plugin-tuist.git", exact: "4.43.2"),
.package(url: "https://github.com/nicklockwood/SwiftFormat.git", exact: "0.55.5"),
.package(url: "https://github.com/realm/SwiftLint.git", exact: "0.58.2")
],
targets: [
.target(name: "secp256k1", dependencies: ["secp256k1_bindings"]),
.target(name: "zkp", dependencies: ["zkp_bindings"]),
.target(name: "P256K", dependencies: ["libsecp256k1"]),
.target(name: "ZKP", dependencies: ["libsecp256k1_zkp"]),
.target(
name: "secp256k1_bindings",
name: "libsecp256k1",
cSettings: PackageDescription.CSetting.baseSettings
),
.target(
name: "zkp_bindings",
name: "libsecp256k1_zkp",
cSettings: PackageDescription.CSetting.baseSettings + [
.define("ENABLE_MODULE_BPPP"),
.define("ENABLE_MODULE_ECDSA_ADAPTOR"),
Expand All @@ -38,7 +41,8 @@ let package = Package(
.headerSearchPath("../../Submodules/secp256k1-zkp/src")
]
),
.testTarget(name: "zkpTests", dependencies: ["zkp"])
.testTarget(name: "libsecp256k1zkpTests", dependencies: ["ZKP", "libsecp256k1_zkp"]),
.testTarget(name: "ZKPTests", dependencies: ["ZKP"])
],
swiftLanguageModes: [.v5],
cLanguageStandard: .c89
Expand Down
70 changes: 70 additions & 0 deletions Projects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

### Projects ###
*.xcodeproj
*.xcworkspace

### Tuist derived files ###
graph.dot
Derived/

### Tuist managed dependencies ###
Tuist/.build
101 changes: 101 additions & 0 deletions Projects/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import ProjectDescription

let deploymentTargets = ProjectDescription.DeploymentTargets.multiplatform(
iOS: "18.0",
macOS: "15.0",
watchOS: "11.0",
tvOS: "18.0",
visionOS: "2.0"
)

let project = Project(
name: "XCFramework",
packages: [
.package(path: "..")
],
settings: .settings(
configurations: [
.debug(name: "Debug", xcconfig: "Resources/Project/Debug.xcconfig"),
.debug(name: "Release", xcconfig: "Resources/Project/Release.xcconfig")
]
),
targets: [
.target(
name: "P256K",
destinations: [.iPhone, .iPad, .mac, .appleWatch, .appleTv, .appleVision],
product: .staticFramework,
bundleId: "dev.21.P256K",
deploymentTargets: deploymentTargets,
sources: ["Sources/P256K/**"],
resources: [],
dependencies: [
.package(product: "libsecp256k1")
],
settings: .settings(
base: [
"BUILD_LIBRARY_FOR_DISTRIBUTION": "YES",
"MACOSX_DEPLOYMENT_TARGET": "13.0"
],
configurations: [
.debug(name: "Debug", xcconfig: "Resources/P256K/Debug.xcconfig"),
.release(name: "Release", xcconfig: "Resources/P256K/Release.xcconfig")
],
defaultSettings: .recommended(
excluding: ["SKIP_INSTALL"]
)
)
),
.target(
name: "P256KTests",
destinations: [.iPhone, .iPad, .mac, .appleWatch, .appleTv, .appleVision],
product: .unitTests,
bundleId: "dev.21.P256KTests",
deploymentTargets: deploymentTargets,
sources: ["Sources/P256KTests/**"],
dependencies: [.target(name: "P256K")],
settings: .settings(
configurations: [
.debug(name: "Debug", xcconfig: "Resources/P256KTests/Debug.xcconfig"),
.release(name: "Release", xcconfig: "Resources/P256KTests/Release.xcconfig")
]
)
),
.target(
name: "libsecp256k1Tests",
destinations: [.iPhone, .iPad, .mac, .appleWatch, .appleTv, .appleVision],
product: .unitTests,
bundleId: "dev.21.libsecp256k1Tests",
deploymentTargets: deploymentTargets,
sources: ["Sources/libsecp256k1Tests/**"],
dependencies: [.package(product: "libsecp256k1")],
settings: .settings(
configurations: [
.debug(name: "Debug", xcconfig: "Resources/libsecp256k1Tests/Debug.xcconfig"),
.release(name: "Release", xcconfig: "Resources/libsecp256k1Tests/Release.xcconfig")
]
)
),
.target(
name: "XCFrameworkApp",
destinations: [.iPhone, .iPad, .mac, .appleTv, .appleVision],
product: .app,
bundleId: "dev.21.XCFrameworkApp",
sources: ["Sources/XCFrameworkApp/**"],
resources: [
"Resources/XCFrameworkApp/Assets.xcassets/**",
"Resources/XCFrameworkApp/Preview Content/**"
],
entitlements: "Resources/XCFrameworkApp/XCFrameworkApp.entitlements",
dependencies: [
.target(name: "P256K")
],
settings: .settings(
base: ["ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME": ""],
configurations: [
.debug(name: "Debug", xcconfig: "Resources/XCFrameworkApp/Debug.xcconfig"),
.release(name: "Release", xcconfig: "Resources/XCFrameworkApp/Release.xcconfig")
]
)
)
]
)
File renamed without changes.
Loading