Compare commits

..

1 commit

11 changed files with 147 additions and 198 deletions

View file

@ -1,59 +0,0 @@
name: Build and Release
on:
workflow_call:
inputs:
release-version:
required: true
type: string
draft-flag:
type: string
default: " "
secrets:
XCFRAMEWORK_SIGNING_TOKEN:
required: true
jobs:
build:
runs-on: macos-15
timeout-minutes: 30
steps:
- name: Validate release version
run: |
version="${{ inputs.release-version }}"
major="${version%%.*}"
if [[ ! "$major" =~ ^[0-9]+$ ]] || (( major < 6 || major > 8 )); then
echo "::error::Capacitor $version is not supported by this repository. Starting with Capacitor 9 (see https://github.com/ionic-team/capacitor/pull/8588 PR), the iOS platform is a source-first Swift package built directly from the ionic-team/capacitor repository, so SPM distribution no longer happens here. This repository only releases major versions 6, 7, and 8."
exit 1
fi
- run: |
if [[ "${{ inputs.release-version }}" =~ ^[67]\. ]]; then
sudo xcode-select --switch /Applications/Xcode_16.2.app
else
sudo xcode-select --switch /Applications/Xcode_26.0.app
fi
- uses: actions/checkout@v7
- name: Install dependencies
run: brew install ghr
- name: Check Simulators
run: xcrun simctl list > /dev/null
- name: Install Simulators
run: xcodebuild -downloadPlatform iOS
- name: Build Capacitor and Cordova
run: ./build-cap ${{ inputs.release-version }}
- name: Sign Capacitor xcframework
uses: ionic-team/sign-xcframework@main
with:
cert-token: ${{ secrets.XCFRAMEWORK_SIGNING_TOKEN }}
xcframework-path: Capacitor.xcframework
- name: Sign Cordova xcframework
uses: ionic-team/sign-xcframework@main
with:
cert-token: ${{ secrets.XCFRAMEWORK_SIGNING_TOKEN }}
xcframework-path: Cordova.xcframework
- name: Package Capacitor and Cordova
run: ./package-cap ${{ inputs.release-version }}
- name: Push manifest update
uses: EndBug/add-and-commit@v9
- name: Create Release
run: ghr -token ${{ secrets.GITHUB_TOKEN }} -name ${{ inputs.release-version }} ${{ inputs.draft-flag }} -replace ${{ inputs.release-version }} frameworks

View file

@ -1,21 +0,0 @@
name: Dispatch Release
on:
workflow_dispatch:
inputs:
release-version:
description: The version to release
required: true
type: string
draft-flag:
description: "Create a Draft Release or Immediately Release"
type: string
default: " "
jobs:
create-release:
uses: ./.github/workflows/build-and-release.yaml
with:
release-version: ${{ inputs.release-version }}
draft-flag: ${{ inputs.draft-flag }}
secrets: inherit

View file

@ -6,17 +6,21 @@ on:
- "release/**"
jobs:
release-version:
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.step1.outputs.release_version }}
build:
runs-on: macos-14
timeout-minutes: 30
steps:
- id: step1
run: echo "release_version=${GITHUB_REF#refs/*/*/}" >> $GITHUB_OUTPUT
create-pre-release:
needs: release-version
uses: ./.github/workflows/build-and-release.yaml
with:
release-version: ${{ needs.release-version.outputs.release-version }}
draft-flag: -draft
secrets: inherit
- run: sudo xcode-select --switch /Applications/Xcode_15.1.app
- uses: actions/checkout@v4
- name: Install build dependencies
run: |
gem install cocoapods xcpretty
brew install ghr
- name: Assign version to RELEASE_VERSION environment variable
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/*/}" >> $GITHUB_ENV
- name: Build Capacitor and Cordova
run: ./build-cap $RELEASE_VERSION
- name: Push manifest update
uses: EndBug/add-and-commit@v9
- name: Create Draft Release
run: ghr -token ${{ secrets.GITHUB_TOKEN }} -name ${{ env.RELEASE_VERSION }} -draft -replace ${{ env.RELEASE_VERSION }} frameworks

3
.gitignore vendored
View file

@ -1,6 +1,5 @@
capacitor-checkout
*.xcframework
*.zip
.swiftpm
frameworks
.build

View file

@ -1,4 +0,0 @@
Capacitor/Cordova 8.5.2, unchanged binary artifacts and upstream checksums.
Imported once from Ionic; future builds use only git.kico-dev.de.
Original upstream revision: 0b6882e9a3288342aacf36348e5a94e4f1dd7b13.
Licence and notices are retained from upstream. MeeNow pins this commit.

View file

@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.9
import PackageDescription
@ -18,13 +18,15 @@ let package = Package(
targets: [
.binaryTarget(
name: "Capacitor",
url: "https://git.kico-dev.de/martin/capacitor-swift-pm/raw/commit/916218efd53e6e646c36bbfd71e8f06c1b643fbf/artifacts/Capacitor.xcframework.zip",
checksum: "134c65a8bd30bfaa8ccb158d78142fa7231bf3f472e4a5d808c5fbed90fd4c75"
path: "frameworks/Capacitor.xcframework.zip"
//url: "https://github.com/ionic-team/capacitor-swift-pm/releases/download/vision/Capacitor.xcframework.zip",
//checksum: "498e6b0ac4bd90537ea1983dc4541b5c08990f1d06ac5522e866284947b7d6e7"
),
.binaryTarget(
name: "Cordova",
url: "https://git.kico-dev.de/martin/capacitor-swift-pm/raw/commit/916218efd53e6e646c36bbfd71e8f06c1b643fbf/artifacts/Cordova.xcframework.zip",
checksum: "57ff2c8f1e5dcd8d4379ac3cccde1407d81ccd575347dc2aff4f72272b8794a1"
path: "frameworks/Cordova.xcframework.zip"
//url: "https://github.com/ionic-team/capacitor-swift-pm/releases/download/vision/Cordova.xcframework.zip",
//checksum: "964c266e7b761630c2dc21ee1a6cb3861379b72ef068d0f7ec2b7e2baf994a4f"
)
]
)

View file

@ -1,5 +1,3 @@
# Swift Package Manager Support for Capacitor
# Experimental Swift Package Manager Support for Capacitor
This repo is for hosting binary xcframework releases of Capacitor and CapacitorCordova for SPM support.
Only applies to Capacitor major versions 6, 7, and 8. Starting with Capacitor 9, the iOS platform is a source-first Swift package built directly from the [ionic-team/capacitor](https://github.com/ionic-team/capacitor) repository.
This repo is for hosting binary xcframework releases of Capacitor and CapacitorCordova for experimental SPM support.

Binary file not shown.

Binary file not shown.

163
build-cap
View file

@ -1,54 +1,123 @@
#!/usr/bin/env bash -eoux pipefail
#!/bin/bash -eoux pipefail
build_simulator() {
local SCHEME=$1
xcodebuild archive \
-scheme $SCHEME \
-workspace Capacitor.xcworkspace \
-destination "generic/platform=iOS Simulator" \
-configuration Debug \
-archivePath ./Build/$SCHEME-iOS-Simulator \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
DEBUG_INFORMATION_FORMAT="dwarf-with-dsym"
build_capacitor_simulator() {
xcodebuild archive \
-scheme Capacitor \
-workspace Capacitor.xcworkspace \
-destination "generic/platform=iOS Simulator" \
-archivePath ./Build/iOS-Simulator \
-configuration Release \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
build_ios() {
local SCHEME=$1
xcodebuild archive \
-scheme $SCHEME \
-workspace Capacitor.xcworkspace \
-destination "generic/platform=iOS" \
-archivePath ./Build/$SCHEME-iOS \
SKIP_INSTALL=NO \
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO \
DEBUG_INFORMATION_FORMAT="dwarf-with-dsym" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
build_capacitor_ios() {
xcodebuild archive \
-scheme Capacitor \
-workspace Capacitor.xcworkspace \
-destination "generic/platform=iOS" \
-archivePath ./Build/iOS \
SKIP_INSTALL=NO \
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO \
DEBUG_INFORMATION_FORMAT="dwarf-with-dsym" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
build_capacitor_vision_simulator() {
xcodebuild archive \
-scheme Capacitor \
-workspace Capacitor.xcworkspace \
-destination "generic/platform=visionOS Simulator" \
-archivePath ./Build/visionOS-Simulator \
-configuration Release \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
build_capacitor_visionos() {
xcodebuild archive \
-scheme Capacitor \
-workspace Capacitor.xcworkspace \
-sdk xros \
-destination "generic/platform=visionOS" \
-archivePath ./Build/visionOS \
SKIP_INSTALL=NO \
SWIFT_SERIALIZE_DEBUGGING_OPTIONS=NO \
DEBUG_INFORMATION_FORMAT="dwarf-with-dsym" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
}
create_xcframeworks() {
build_simulator Capacitor
build_simulator Cordova
build_capacitor_simulator
build_capacitor_ios
build_capacitor_vision_simulator
build_capacitor_visionos
build_ios Capacitor
build_ios Cordova
rm -rf ./Build/iOS-Simulator.xcarchive/Products/Library/Frameworks/Capacitor.framework/Frameworks
rm -rf ./Build/iOS.xcarchive/Products/Library/Frameworks/Capacitor.framework/Frameworks
rm -rf ./Build/Capacitor-iOS-Simulator.xcarchive/Products/Library/Frameworks/Capacitor.framework/Frameworks
rm -rf ./Build/Capacitor-iOS.xcarchive/Products/Library/Frameworks/Capacitor.framework/Frameworks
rm -rf ./Build/visionOS-Simulator.xcarchive/Products/Library/Frameworks/Capacitor.framework/Frameworks
rm -rf ./Build/visionOS.xcarchive/Products/Library/Frameworks/Capacitor.framework/Frameworks
xcodebuild -create-xcframework \
-framework ./Build/Capacitor-iOS-Simulator.xcarchive/Products/Library/Frameworks/Capacitor.framework \
-debug-symbols $PWD/Build/Capacitor-iOS-Simulator.xcarchive/dSYMs/Capacitor.framework.dSYM \
-framework ./Build/Capacitor-iOS.xcarchive/Products/Library/Frameworks/Capacitor.framework \
-debug-symbols $PWD/Build/Capacitor-iOS.xcarchive/dSYMs/Capacitor.framework.dSYM \
-output Capacitor.xcframework
xcodebuild -create-xcframework \
-framework ./Build/iOS-Simulator.xcarchive/Products/Library/Frameworks/Capacitor.framework \
-debug-symbols $PWD/Build/iOS-Simulator.xcarchive/dSYMs/Capacitor.framework.dSYM \
-framework ./Build/iOS.xcarchive/Products/Library/Frameworks/Capacitor.framework \
-debug-symbols $PWD/Build/iOS.xcarchive/dSYMs/Capacitor.framework.dSYM \
-framework ./Build/visionOS-Simulator.xcarchive/Products/Library/Frameworks/Capacitor.framework \
-debug-symbols $PWD/Build/visionOS-Simulator.xcarchive/dSYMs/Capacitor.framework.dSYM \
-framework ./Build/visionOS.xcarchive/Products/Library/Frameworks/Capacitor.framework \
-debug-symbols $PWD/Build/visionOS.xcarchive/dSYMs/Capacitor.framework.dSYM \
-output Capacitor.xcframework
xcodebuild -create-xcframework \
-framework ./Build/Cordova-iOS-Simulator.xcarchive/Products/Library/Frameworks/Cordova.framework \
-debug-symbols $PWD/Build/Cordova-iOS-Simulator.xcarchive/dSYMs/Cordova.framework.dSYM \
-framework ./Build/Cordova-iOS.xcarchive/Products/Library/Frameworks/Cordova.framework \
-debug-symbols $PWD/Build/Cordova-iOS.xcarchive/dSYMs/Cordova.framework.dSYM \
-output Cordova.xcframework
xcodebuild -create-xcframework \
-framework ./Build/iOS-Simulator.xcarchive/Products/Library/Frameworks/Cordova.framework \
-debug-symbols $PWD/Build/iOS-Simulator.xcarchive/dSYMs/Cordova.framework.dSYM \
-framework ./Build/iOS.xcarchive/Products/Library/Frameworks/Cordova.framework \
-debug-symbols $PWD/Build/iOS.xcarchive/dSYMs/Cordova.framework.dSYM \
-framework ./Build/visionOS-Simulator.xcarchive/Products/Library/Frameworks/Cordova.framework \
-debug-symbols $PWD/Build/visionOS-Simulator.xcarchive/dSYMs/Cordova.framework.dSYM \
-framework ./Build/visionOS.xcarchive/Products/Library/Frameworks/Cordova.framework \
-debug-symbols $PWD/Build/visionOS.xcarchive/dSYMs/Cordova.framework.dSYM \
-output Cordova.xcframework
zip -r Capacitor.xcframework.zip Capacitor.xcframework
zip -r Cordova.xcframework.zip Cordova.xcframework
}
write_package_file() {
cat << EOF > Package.swift
// swift-tools-version:5.9
import PackageDescription
let package = Package(
name: "capacitor-swift-pm",
products: [
.library(
name: "Capacitor",
targets: ["Capacitor"]
),
.library(
name: "Cordova",
targets: ["Cordova"]
)
],
dependencies: [],
targets: [
.binaryTarget(
name: "Capacitor",
url: "$1",
checksum: "$2"
),
.binaryTarget(
name: "Cordova",
url: "$3",
checksum: "$4"
)
]
)
EOF
}
git clone https://github.com/ionic-team/capacitor capacitor-checkout
@ -57,5 +126,13 @@ git checkout $1
create_xcframeworks
mv Capacitor.xcframework ../../../
mv Cordova.xcframework ../../../
cap_url="https://github.com/ionic-team/capacitor-swift-pm/releases/download/$1/Capacitor.xcframework.zip"
cap_sha=$(shasum -a 256 Capacitor.xcframework.zip | sed 's/ /\n/g' | head -n1 | xargs echo -n)
cap_cordova_url="https://github.com/ionic-team/capacitor-swift-pm/releases/download/$1/Cordova.xcframework.zip"
cap_cordova_sha=$(shasum -a 256 Cordova.xcframework.zip | sed 's/ /\n/g' | head -n1 | xargs echo -n)
cd ../../../
mkdir frameworks
mv capacitor-checkout/ios/Capacitor/{Capacitor,Cordova}.xcframework.zip frameworks
write_package_file $cap_url $cap_sha $cap_cordova_url $cap_cordova_sha

View file

@ -1,47 +0,0 @@
#!/usr/bin/env bash -eoux pipefail
mkdir frameworks
zip -r frameworks/Capacitor.xcframework.zip Capacitor.xcframework
zip -r frameworks/Cordova.xcframework.zip Cordova.xcframework
write_package_file() {
cat <<EOF >Package.swift
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "capacitor-swift-pm",
products: [
.library(
name: "Capacitor",
targets: ["Capacitor"]
),
.library(
name: "Cordova",
targets: ["Cordova"]
)
],
dependencies: [],
targets: [
.binaryTarget(
name: "Capacitor",
url: "$1",
checksum: "$2"
),
.binaryTarget(
name: "Cordova",
url: "$3",
checksum: "$4"
)
]
)
EOF
}
cap_url="https://github.com/ionic-team/capacitor-swift-pm/releases/download/$1/Capacitor.xcframework.zip"
cap_sha=$(shasum -a 256 frameworks/Capacitor.xcframework.zip | sed 's/ /\n/g' | head -n1 | xargs echo -n)
cap_cordova_url="https://github.com/ionic-team/capacitor-swift-pm/releases/download/$1/Cordova.xcframework.zip"
cap_cordova_sha=$(shasum -a 256 frameworks/Cordova.xcframework.zip | sed 's/ /\n/g' | head -n1 | xargs echo -n)
write_package_file $cap_url $cap_sha $cap_cordova_url $cap_cordova_sha