Skip to content

Commit e381a4e

Browse files
committed
revert: "revert: swift package release workflow and follow-ups (#404)"
1 parent 2c2b63f commit e381a4e

13 files changed

Lines changed: 836 additions & 109 deletions

File tree

.github/workflows/npm_release.yml

Lines changed: 382 additions & 68 deletions
Large diffs are not rendered by default.

build_all_ios.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ rm -rf ./dist
77
./build_nativescript.sh --no-vision
88
./build_tklivesync.sh --no-vision
99
./prepare_dSYMs.sh
10+
./build_spm_artifacts.sh ios
1011
./build_npm_ios.sh

build_all_vision.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ rm -rf ./dist
77
./build_nativescript.sh --no-catalyst --no-iphone --no-sim
88
./build_tklivesync.sh --no-catalyst --no-iphone --no-sim
99
./prepare_dSYMs.sh
10+
./build_spm_artifacts.sh visionos
1011
./build_npm_vision.sh

build_npm_ios.sh

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,65 @@ cp ./package.json "$OUTPUT_DIR"
1111

1212
cp -r "./project-template-ios/" "$OUTPUT_DIR/framework"
1313

14-
cp -r "dist/NativeScript.xcframework" "$OUTPUT_DIR/framework/internal"
15-
cp -r "dist/TKLiveSync.xcframework" "$OUTPUT_DIR/framework/internal"
14+
# The NativeScript / TKLiveSync xcframeworks are NO LONGER bundled in npm. They
15+
# are published as GitHub Release artifacts and consumed via SwiftPM
16+
# (github.com/NativeScript/ios-spm). Stamp the runtime version into the packaged
17+
# template's SwiftPM reference so it resolves the matching release.
18+
NPM_VERSION=$(node -e "console.log(require('./package.json').version)")
19+
node ./scripts/stamp-template-version.mjs \
20+
"$OUTPUT_DIR/framework/__PROJECT_NAME__.xcodeproj/project.pbxproj" \
21+
"$NPM_VERSION"
1622

23+
# Local builds have no ios-spm release tag to resolve, so by default (outside
24+
# CI) rewrite the template to a LOCAL SwiftPM package over the xcframeworks
25+
# just built into dist/. Force with NS_SPM_LOCAL=1, disable with NS_SPM_LOCAL=0.
26+
# The resulting .tgz embeds an absolute path into this checkout — local
27+
# `ns platform add ios --framework-path=dist/nativescript-ios-*.tgz` use only.
28+
if [[ "${NS_SPM_LOCAL:-}" == "1" || ( -z "${CI:-}" && "${NS_SPM_LOCAL:-}" != "0" ) ]]; then
29+
LOCAL_SPM_DIR="$(pwd)/dist/local-spm"
30+
rm -rf "$LOCAL_SPM_DIR"
31+
mkdir -p "$LOCAL_SPM_DIR"
32+
cp -R "dist/NativeScript.xcframework" "$LOCAL_SPM_DIR/"
33+
cp -R "dist/TKLiveSync.xcframework" "$LOCAL_SPM_DIR/"
34+
cat > "$LOCAL_SPM_DIR/Package.swift" <<'EOF'
35+
// swift-tools-version: 5.10
36+
// Local dev override of github.com/NativeScript/ios-spm: same product shape,
37+
// but binaryTargets point at the freshly built xcframeworks in this folder.
38+
import PackageDescription
39+
40+
let package = Package(
41+
name: "NativeScriptSDK",
42+
platforms: [
43+
.iOS(.v13),
44+
.macCatalyst(.v13),
45+
],
46+
products: [
47+
.library(name: "NativeScript", targets: ["NativeScript", "TKLiveSync"]),
48+
.library(name: "NativeScriptSDK", targets: ["NativeScript", "TKLiveSync"]),
49+
],
50+
dependencies: [],
51+
targets: [
52+
.binaryTarget(name: "NativeScript", path: "NativeScript.xcframework"),
53+
.binaryTarget(name: "TKLiveSync", path: "TKLiveSync.xcframework"),
54+
]
55+
)
56+
EOF
57+
node ./scripts/stamp-template-local-spm.mjs \
58+
"$OUTPUT_DIR/framework/__PROJECT_NAME__.xcodeproj/project.pbxproj" \
59+
"$LOCAL_SPM_DIR"
60+
fi
61+
62+
# Build-time metadata generator is still shipped in npm (Phase 1). See the
63+
# distribution plan for moving this to an on-demand artifact (Phase 2).
1764
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
1865
cp -r "metadata-generator/dist/x86_64/." "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
1966

2067
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
2168
cp -r "metadata-generator/dist/arm64/." "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
2269

23-
# Add xcframeworks to .zip (NPM modules do not support symlinks, unzipping is done by {N} CLI)
24-
(
25-
set -e
26-
cd $OUTPUT_DIR/framework/internal
27-
zip -qr --symlinks XCFrameworks.zip *.xcframework
28-
rm -rf *.xcframework
29-
)
30-
3170
pushd "$OUTPUT_DIR"
3271
npm pack
3372
mv *.tgz ../
3473
popd
3574

36-
checkpoint "npm package created."
75+
checkpoint "npm package created."

build_npm_vision.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,26 @@ cp ./package.json "$OUTPUT_DIR"
1111

1212
cp -r "./project-template-vision/" "$OUTPUT_DIR/framework"
1313

14-
cp -r "dist/NativeScript.xcframework" "$OUTPUT_DIR/framework/internal"
15-
cp -r "dist/TKLiveSync.xcframework" "$OUTPUT_DIR/framework/internal"
16-
14+
# The NativeScript / TKLiveSync xcframeworks are NO LONGER bundled in npm. They
15+
# are published as GitHub Release artifacts and consumed via SwiftPM
16+
# (github.com/NativeScript/ios-spm). Stamp the runtime version into the packaged
17+
# template's SwiftPM reference so it resolves the matching release.
18+
NPM_VERSION=$(node -e "console.log(require('./package.json').version)")
19+
node ./scripts/stamp-template-version.mjs \
20+
"$OUTPUT_DIR/framework/__PROJECT_NAME__.xcodeproj/project.pbxproj" \
21+
"$NPM_VERSION"
22+
23+
# Build-time metadata generator is still shipped in npm (Phase 1). See the
24+
# distribution plan for moving this to an on-demand artifact (Phase 2).
1725
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
1826
cp -r "metadata-generator/dist/x86_64/." "$OUTPUT_DIR/framework/internal/metadata-generator-x86_64"
1927

2028
mkdir -p "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
2129
cp -r "metadata-generator/dist/arm64/." "$OUTPUT_DIR/framework/internal/metadata-generator-arm64"
2230

23-
# Add xcframeworks to .zip (NPM modules do not support symlinks, unzipping is done by {N} CLI)
24-
(
25-
set -e
26-
cd $OUTPUT_DIR/framework/internal
27-
zip -qr --symlinks XCFrameworks.zip *.xcframework
28-
rm -rf *.xcframework
29-
)
30-
3131
pushd "$OUTPUT_DIR"
3232
npm pack
3333
mv *.tgz ../
3434
popd
3535

36-
checkpoint "npm package created."
36+
checkpoint "npm package created."

build_spm_artifacts.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
# Package the built xcframeworks as SwiftPM binary-target artifacts:
3+
# * a .zip per xcframework (framework at the zip root, symlinks preserved)
4+
# * a SHA-256 checksum for each (the value SwiftPM's binaryTarget(checksum:) expects)
5+
#
6+
# Output goes to dist/artifacts/:
7+
# <name>.zip and a combined checksums.env (KEY=sha256 lines)
8+
#
9+
# Usage: ./build_spm_artifacts.sh [ios|visionos] (default: ios)
10+
#
11+
# These artifacts are uploaded to the GitHub Release and referenced by
12+
# github.com/NativeScript/ios-spm (see scripts/stamp-spm-release.mjs).
13+
set -e
14+
source "$(dirname "$0")/build_utils.sh"
15+
16+
TARGET="${1:-ios}"
17+
DIST="$(pwd)/dist"
18+
OUT="$DIST/artifacts"
19+
20+
case "$TARGET" in
21+
ios)
22+
NS_ZIP="NativeScript.xcframework.zip"
23+
TK_ZIP="TKLiveSync.xcframework.zip"
24+
NS_KEY="NS_CHECKSUM_NATIVESCRIPT_IOS"
25+
TK_KEY="NS_CHECKSUM_TKLIVESYNC_IOS"
26+
;;
27+
visionos|vision|xr)
28+
TARGET="visionos"
29+
NS_ZIP="NativeScript.visionos.xcframework.zip"
30+
TK_ZIP="TKLiveSync.visionos.xcframework.zip"
31+
NS_KEY="NS_CHECKSUM_NATIVESCRIPT_VISIONOS"
32+
TK_KEY="NS_CHECKSUM_TKLIVESYNC_VISIONOS"
33+
;;
34+
*)
35+
echo "Unknown target '$TARGET' (expected ios or visionos)" >&2
36+
exit 1
37+
;;
38+
esac
39+
40+
checkpoint "Packaging SwiftPM artifacts for $TARGET..."
41+
rm -rf "$OUT"
42+
mkdir -p "$OUT"
43+
44+
# SwiftPM's binaryTarget(checksum:) is the SHA-256 of the zip. `swift package
45+
# compute-checksum` is the canonical producer; shasum -a 256 yields the same
46+
# value and is the portable fallback.
47+
compute_checksum() {
48+
local zip="$1"
49+
if command -v swift >/dev/null 2>&1 && swift package compute-checksum "$zip" >/dev/null 2>&1; then
50+
swift package compute-checksum "$zip"
51+
else
52+
shasum -a 256 "$zip" | awk '{print $1}'
53+
fi
54+
}
55+
56+
# zip_xcframework <SourceXcframeworkDir> <OutputZipName>
57+
zip_xcframework() {
58+
local src="$1" zipname="$2"
59+
if [ ! -d "$DIST/$src" ]; then
60+
echo "Missing $DIST/$src — run the runtime build first." >&2
61+
exit 1
62+
fi
63+
( cd "$DIST" && zip -qr --symlinks "$OUT/$zipname" "$src" )
64+
}
65+
66+
zip_xcframework "NativeScript.xcframework" "$NS_ZIP"
67+
zip_xcframework "TKLiveSync.xcframework" "$TK_ZIP"
68+
69+
NS_SUM="$(compute_checksum "$OUT/$NS_ZIP")"
70+
TK_SUM="$(compute_checksum "$OUT/$TK_ZIP")"
71+
72+
# Per-target filename so the iOS and visionOS env files don't collide when the
73+
# release/stamp jobs merge both platforms' artifacts into one directory.
74+
CHECKSUMS="$OUT/checksums-$TARGET.env"
75+
{
76+
echo "${NS_KEY}=${NS_SUM}"
77+
echo "${TK_KEY}=${TK_SUM}"
78+
} > "$CHECKSUMS"
79+
80+
checkpoint "SwiftPM artifacts ready in $OUT:"
81+
( cd "$OUT" && ls -lh *.zip )
82+
echo "Checksums ($CHECKSUMS):"
83+
cat "$CHECKSUMS"

project-template-ios/__PROJECT_NAME__.xcodeproj/project.pbxproj

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
39940D9122C4EF600050DDE1 /* NativeScript.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 39940D8C22C4EAAA0050DDE1 /* NativeScript.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
11-
39940E1C22C5DFFF0050DDE1 /* TKLiveSync.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 39940E1B22C5DFFF0050DDE1 /* TKLiveSync.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
10+
AA10000000000000000000C1 /* NativeScript in Frameworks */ = {isa = PBXBuildFile; productRef = AA10000000000000000000B1 /* NativeScript */; };
1211
858B842D18CA22B800AB12DE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 858B833A18CA111C00AB12DE /* InfoPlist.strings */; };
1312
AAA0AADB2A54B96B00EE55A4 /* NativeScriptStart.m in Sources */ = {isa = PBXBuildFile; fileRef = AAA0AADA2A54B96B00EE55A4 /* NativeScriptStart.m */; };
1413
CD45EE7C18DC2D5800FB50C0 /* app in Resources */ = {isa = PBXBuildFile; fileRef = CD45EE7A18DC2D5800FB50C0 /* app */; };
@@ -22,8 +21,6 @@
2221
dstPath = "";
2322
dstSubfolderSpec = 10;
2423
files = (
25-
39940D9122C4EF600050DDE1 /* NativeScript.xcframework in Embed Frameworks */,
26-
39940E1C22C5DFFF0050DDE1 /* TKLiveSync.xcframework in Embed Frameworks */,
2724
);
2825
name = "Embed Frameworks";
2926
runOnlyForDeploymentPostprocessing = 0;
@@ -35,8 +32,6 @@
3532
391174B721F1D99900BA2583 /* plugins-release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "plugins-release.xcconfig"; sourceTree = SOURCE_ROOT; };
3633
391174B821F1D99900BA2583 /* plugins-debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "plugins-debug.xcconfig"; sourceTree = SOURCE_ROOT; };
3734
39940D8122C4E84C0050DDE1 /* __PROJECT_NAME__.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = __PROJECT_NAME__.entitlements; sourceTree = "<group>"; };
38-
39940D8C22C4EAAA0050DDE1 /* NativeScript.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = NativeScript.xcframework; path = internal/NativeScript.xcframework; sourceTree = "<group>"; };
39-
39940E1B22C5DFFF0050DDE1 /* TKLiveSync.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = TKLiveSync.xcframework; path = internal/TKLiveSync.xcframework; sourceTree = "<group>"; };
4035
42C751E2232B769100186695 /* nativescript-pre-link */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "nativescript-pre-link"; path = "internal/nativescript-pre-link"; sourceTree = SOURCE_ROOT; };
4136
42C751E3232B769100186695 /* strip-dynamic-framework-architectures.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "strip-dynamic-framework-architectures.sh"; path = "internal/strip-dynamic-framework-architectures.sh"; sourceTree = SOURCE_ROOT; };
4237
42C751E4232B769100186695 /* nsld.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = nsld.sh; path = internal/nsld.sh; sourceTree = SOURCE_ROOT; };
@@ -63,6 +58,7 @@
6358
isa = PBXFrameworksBuildPhase;
6459
buildActionMask = 2147483647;
6560
files = (
61+
AA10000000000000000000C1 /* NativeScript in Frameworks */,
6662
);
6763
runOnlyForDeploymentPostprocessing = 0;
6864
};
@@ -115,8 +111,6 @@
115111
858B833018CA111C00AB12DE /* Frameworks */ = {
116112
isa = PBXGroup;
117113
children = (
118-
39940E1B22C5DFFF0050DDE1 /* TKLiveSync.xcframework */,
119-
39940D8C22C4EAAA0050DDE1 /* NativeScript.xcframework */,
120114
);
121115
name = Frameworks;
122116
sourceTree = "<group>";
@@ -176,6 +170,9 @@
176170
dependencies = (
177171
);
178172
name = __PROJECT_NAME__;
173+
packageProductDependencies = (
174+
AA10000000000000000000B1 /* NativeScript */,
175+
);
179176
productName = JDBridgeApp;
180177
productReference = 858B843318CA22B800AB12DE /* __PROJECT_NAME__.app */;
181178
productType = "com.apple.product-type.application";
@@ -206,6 +203,9 @@
206203
Base,
207204
);
208205
mainGroup = 858B832518CA111C00AB12DE;
206+
packageReferences = (
207+
AA10000000000000000000A1 /* XCRemoteSwiftPackageReference "ios-spm" */,
208+
);
209209
productRefGroup = 858B832F18CA111C00AB12DE /* Products */;
210210
projectDirPath = "";
211211
projectRoot = "";
@@ -498,6 +498,25 @@
498498
defaultConfigurationName = Release;
499499
};
500500
/* End XCConfigurationList section */
501+
502+
/* Begin XCRemoteSwiftPackageReference section */
503+
AA10000000000000000000A1 /* XCRemoteSwiftPackageReference "ios-spm" */ = {
504+
isa = XCRemoteSwiftPackageReference;
505+
repositoryURL = "https://github.com/NativeScript/ios-spm.git";
506+
requirement = {
507+
kind = exactVersion;
508+
version = "__NS_RUNTIME_VERSION__";
509+
};
510+
};
511+
/* End XCRemoteSwiftPackageReference section */
512+
513+
/* Begin XCSwiftPackageProductDependency section */
514+
AA10000000000000000000B1 /* NativeScript */ = {
515+
isa = XCSwiftPackageProductDependency;
516+
package = AA10000000000000000000A1 /* XCRemoteSwiftPackageReference "ios-spm" */;
517+
productName = NativeScript;
518+
};
519+
/* End XCSwiftPackageProductDependency section */
501520
};
502521
rootObject = 858B832618CA111C00AB12DE /* Project object */;
503522
}

project-template-ios/internal/nativescript-build.xcconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// * NativeScript build related flags
22
// * Add [sdk=*] after each one to avoid conflict with CocoaPods flags
3-
OTHER_LDFLAGS[sdk=*] = $(inherited) -ObjC -sectcreate __DATA __TNSMetadata "$(CONFIGURATION_BUILD_DIR)/metadata-$(CURRENT_ARCH).bin" -framework NativeScript -framework TKLiveSync -F"$(SRCROOT)/internal" -licucore -lz -lc++ -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreServices -framework Security
3+
// * NativeScript + TKLiveSync are provided by the SwiftPM "NativeScript" product
4+
// * (github.com/NativeScript/ios-spm), so SwiftPM links/embeds them automatically.
5+
// * The explicit -framework NativeScript / -framework TKLiveSync / -F internal are
6+
// * intentionally omitted. SwiftPM stages the resolved framework slice into
7+
// * CONFIGURATION_BUILD_DIR (below), which is where the metadata generator finds it.
8+
OTHER_LDFLAGS[sdk=*] = $(inherited) -ObjC -sectcreate __DATA __TNSMetadata "$(CONFIGURATION_BUILD_DIR)/metadata-$(CURRENT_ARCH).bin" -licucore -lz -lc++ -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreServices -framework Security
49

510
// We need to add CONFIGURATION_BUILD_DIR here so that we can explicitly quote-escape any paths in it, because the implicitly added path by Xcode is not always escaped
611
FRAMEWORK_SEARCH_PATHS[sdk=*] = $(inherited) "$(SRCROOT)/internal/" "$(CONFIGURATION_BUILD_DIR)"

0 commit comments

Comments
 (0)