feat: add macOS bridge podspec, Windows project, sync versions to 0.2.0-beta.1

This commit is contained in:
Edison Jwa
2026-05-17 21:42:54 +09:00
parent 7a59f5b9a1
commit 618b6930fe
30 changed files with 1408 additions and 18 deletions
@@ -0,0 +1 @@
Versions/Current/Resources
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key><string>chanora_bridge</string>
<key>CFBundleIdentifier</key><string>app.chanora.bridge</string>
<key>CFBundleName</key><string>chanora_bridge</string>
<key>CFBundlePackageType</key><string>FMWK</string>
<key>CFBundleShortVersionString</key><string>1.0.0</string>
<key>CFBundleVersion</key><string>1</string>
<key>CFBundleSupportedPlatforms</key><array><string>MacOSX</string></array>
<key>MinimumOSVersion</key><string>10.15</string>
</dict>
</plist>
@@ -0,0 +1 @@
Versions/Current/chanora_bridge
+3
View File
@@ -30,6 +30,9 @@ target 'Runner' do
use_frameworks!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
pod 'chanora_bridge', :path => File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
+18 -1
View File
@@ -1,22 +1,39 @@
PODS:
- audio_session (0.0.1):
- FlutterMacOS
- chanora_bridge (1.0.0)
- connectivity_plus (0.0.1):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- package_info_plus (0.0.1):
- FlutterMacOS
DEPENDENCIES:
- audio_session (from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos`)
- chanora_bridge (from `/Users/edison/chanora/apps/chanora_flutter/macos`)
- connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
EXTERNAL SOURCES:
audio_session:
:path: Flutter/ephemeral/.symlinks/plugins/audio_session/macos
chanora_bridge:
:path: "/Users/edison/chanora/apps/chanora_flutter/macos"
connectivity_plus:
:path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos
FlutterMacOS:
:path: Flutter/ephemeral
package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
SPEC CHECKSUMS:
audio_session: eaca2512cf2b39212d724f35d11f46180ad3a33e
chanora_bridge: 1403e892a388d6bbb751d2d658e539d7a456fb1b
connectivity_plus: 4adf20a405e25b42b9c9f87feff8f4b6fde18a4e
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
package_info_plus: f0052d280d17aa382b932f399edf32507174e870
PODFILE CHECKSUM: 54d867c82ac51cbd61b565781b9fada492027009
PODFILE CHECKSUM: d2e26b3cd926b9e407faa321206548300d262a08
COCOAPODS: 1.16.2
@@ -393,14 +393,10 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
@@ -485,7 +481,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = app.chanora.chanoraFlutter.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@@ -501,7 +497,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = app.chanora.chanoraFlutter.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@@ -517,7 +513,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 0.2;
PRODUCT_BUNDLE_IDENTIFIER = app.chanora.chanoraFlutter.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@@ -0,0 +1,210 @@
#
# chanora_bridge — Rust bridge library as a CocoaPods-vended dynamic framework
# (macOS edition).
#
# What this file does:
#
# 1. `prepare_command` runs once per `pod install` and once per archive
# / device build. It:
# a) Invokes `cargo build --release` for both `aarch64-apple-darwin`
# (Apple Silicon) and `x86_64-apple-darwin` (Intel).
# b) Uses `lipo` to merge the two into a universal binary.
# c) Wraps the universal dylib in a proper `chanora_bridge.framework`
# bundle (Versions/A layout with the right Info.plist).
# d) Rewrites LC_ID_DYLIB to
# @rpath/chanora_bridge.framework/Versions/A/chanora_bridge so dyld
# resolves it as a framework when embedded in Runner.app.
#
# 2. `vendored_frameworks` exposes the result to the Pods workspace.
# CocoaPods then integrates the framework into Runner.xcodeproj
# with the appropriate embed phase.
#
# Path note: this podspec lives at apps/chanora_flutter/macos/, and
# refers to the Rust workspace at ../../.. (repo root). The
# prepare_command runs with PWD = the directory of this file, so all
# paths are relative to apps/chanora_flutter/macos/.
Pod::Spec.new do |s|
s.name = 'chanora_bridge'
s.version = '1.0.0'
s.summary = 'Chanora Rust bridge (libchanora_bridge) as a macOS framework.'
s.description = <<-DESC
Vendors the Rust-built libchanora_bridge as chanora_bridge.framework so
flutter_rust_bridge's runtime loader can dlopen it on macOS.
DESC
s.homepage = 'https://github.com/EdisonJwa/chanora'
s.license = { :type => 'Apache-2.0 OR MIT', :text => 'See LICENSE-APACHE / LICENSE-MIT at the repo root' }
s.author = { 'EdisonJwa' => 'me@edison.network' }
s.source = { :path => '.' }
s.platform = :osx, '10.15'
# Build the Rust bridge on `pod install`. The script runs under
# bash; we use `set -e` so any failure (cargo missing, target not
# installed, link error) aborts the install loudly.
s.prepare_command = <<-SCRIPT
set -e
REPO_ROOT="$(cd ../../.. && pwd)"
BRIDGE_ARM64="$REPO_ROOT/target/aarch64-apple-darwin/release/libchanora_bridge.dylib"
BRIDGE_X86_64="$REPO_ROOT/target/x86_64-apple-darwin/release/libchanora_bridge.dylib"
UNIVERSAL="$REPO_ROOT/target/universal/release/libchanora_bridge.dylib"
echo "[chanora_bridge.podspec] cargo build aarch64-apple-darwin"
cd "$REPO_ROOT"
PATH="$HOME/.cargo/bin:$PATH" \\
MACOSX_DEPLOYMENT_TARGET=10.15 \\
CMAKE_POLICY_VERSION_MINIMUM=3.5 \\
LIBOPUS_STATIC=1 \\
LIBOPUS_NO_PKG=1 \\
cargo build --release --target aarch64-apple-darwin -p chanora_bridge
echo "[chanora_bridge.podspec] cargo build x86_64-apple-darwin"
PATH="$HOME/.cargo/bin:$PATH" \\
MACOSX_DEPLOYMENT_TARGET=10.15 \\
CMAKE_POLICY_VERSION_MINIMUM=3.5 \\
LIBOPUS_STATIC=1 \\
LIBOPUS_NO_PKG=1 \\
cargo build --release --target x86_64-apple-darwin -p chanora_bridge
if [ ! -f "$BRIDGE_ARM64" ]; then
echo "ERROR: arm64 dylib not found at $BRIDGE_ARM64" >&2
exit 1
fi
if [ ! -f "$BRIDGE_X86_64" ]; then
echo "ERROR: x86_64 dylib not found at $BRIDGE_X86_64" >&2
exit 1
fi
# Create universal binary with lipo.
mkdir -p "$(dirname "$UNIVERSAL")"
lipo -create "$BRIDGE_ARM64" "$BRIDGE_X86_64" -output "$UNIVERSAL"
echo "[chanora_bridge.podspec] universal binary created"
cd "$REPO_ROOT/apps/chanora_flutter/macos"
# Build the chanora_bridge.framework layout (Versions/A) in a known
# location this podspec will then point vendored_frameworks at.
FW=Frameworks/chanora_bridge.framework
rm -rf "$FW"
mkdir -p "$FW/Versions/A/Resources"
ln -sfh A "$FW/Versions/Current"
ln -sfh Versions/Current/Resources "$FW/Resources"
cp "$UNIVERSAL" "$FW/Versions/A/chanora_bridge"
ln -sfh Versions/Current/chanora_bridge "$FW/chanora_bridge"
cat > "$FW/Versions/A/Resources/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key><string>chanora_bridge</string>
<key>CFBundleIdentifier</key><string>app.chanora.bridge</string>
<key>CFBundleName</key><string>chanora_bridge</string>
<key>CFBundlePackageType</key><string>FMWK</string>
<key>CFBundleShortVersionString</key><string>1.0.0</string>
<key>CFBundleVersion</key><string>1</string>
<key>CFBundleSupportedPlatforms</key><array><string>MacOSX</string></array>
<key>MinimumOSVersion</key><string>10.15</string>
</dict>
</plist>
PLIST
install_name_tool -id "@rpath/chanora_bridge.framework/Versions/A/chanora_bridge" \\
"$FW/Versions/A/chanora_bridge"
echo "[chanora_bridge.podspec] framework ready at $FW"
SCRIPT
# Pod CocoaPods picks this up; the framework gets embedded into
# Runner.app/Contents/Frameworks/ automatically.
s.vendored_frameworks = 'Frameworks/chanora_bridge.framework'
# Re-run the cargo build + framework wrap on every Xcode build,
# not only on `pod install`. The `prepare_command` above runs
# once per `pod install` which is too sticky — Rust source
# changes were getting silently ignored because Xcode happily
# re-bundled the stale framework. This script_phase shells out to
# cargo on every Xcode "Build" so the framework is always in sync
# with the current Rust workspace.
#
# `:execution_position => :before_compile` runs the script before
# Xcode's CompileSources phase, so by the time the linker / embed
# step sees `Frameworks/chanora_bridge.framework`, it is fresh.
s.script_phase = {
:name => 'Rebuild chanora_bridge.framework from Rust',
:script => <<-SCRIPT,
set -e
REPO_ROOT="$(cd "${PODS_TARGET_SRCROOT}/../../.." && pwd)"
BRIDGE_ARM64="$REPO_ROOT/target/aarch64-apple-darwin/release/libchanora_bridge.dylib"
BRIDGE_X86_64="$REPO_ROOT/target/x86_64-apple-darwin/release/libchanora_bridge.dylib"
UNIVERSAL="$REPO_ROOT/target/universal/release/libchanora_bridge.dylib"
echo "[chanora_bridge script_phase] cargo build aarch64-apple-darwin"
cd "$REPO_ROOT"
PATH="$HOME/.cargo/bin:$PATH" \
MACOSX_DEPLOYMENT_TARGET=10.15 \
CMAKE_POLICY_VERSION_MINIMUM=3.5 \
LIBOPUS_STATIC=1 \
LIBOPUS_NO_PKG=1 \
cargo build --release --target aarch64-apple-darwin -p chanora_bridge
echo "[chanora_bridge script_phase] cargo build x86_64-apple-darwin"
PATH="$HOME/.cargo/bin:$PATH" \
MACOSX_DEPLOYMENT_TARGET=10.15 \
CMAKE_POLICY_VERSION_MINIMUM=3.5 \
LIBOPUS_STATIC=1 \
LIBOPUS_NO_PKG=1 \
cargo build --release --target x86_64-apple-darwin -p chanora_bridge
cd "$REPO_ROOT/apps/chanora_flutter/macos"
FW=Frameworks/chanora_bridge.framework
# Skip the wrap step if the framework's binary is already
# up-to-date with the cargo output (fast no-op on incremental
# builds where Rust didn't change).
if [ -f "$FW/Versions/A/chanora_bridge" ] && [ "$FW/Versions/A/chanora_bridge" -nt "$BRIDGE_ARM64" ] && [ "$FW/Versions/A/chanora_bridge" -nt "$BRIDGE_X86_64" ]; then
echo "[chanora_bridge script_phase] framework already up-to-date"
exit 0
fi
# Create universal binary with lipo.
mkdir -p "$(dirname "$UNIVERSAL")"
lipo -create "$BRIDGE_ARM64" "$BRIDGE_X86_64" -output "$UNIVERSAL"
rm -rf "$FW"
mkdir -p "$FW/Versions/A/Resources"
ln -sfh A "$FW/Versions/Current"
ln -sfh Versions/Current/Resources "$FW/Resources"
cp "$UNIVERSAL" "$FW/Versions/A/chanora_bridge"
ln -sfh Versions/Current/chanora_bridge "$FW/chanora_bridge"
cat > "$FW/Versions/A/Resources/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key><string>chanora_bridge</string>
<key>CFBundleIdentifier</key><string>app.chanora.bridge</string>
<key>CFBundleName</key><string>chanora_bridge</string>
<key>CFBundlePackageType</key><string>FMWK</string>
<key>CFBundleShortVersionString</key><string>1.0.0</string>
<key>CFBundleVersion</key><string>1</string>
<key>CFBundleSupportedPlatforms</key><array><string>MacOSX</string></array>
<key>MinimumOSVersion</key><string>10.15</string>
</dict>
</plist>
PLIST
install_name_tool -id "@rpath/chanora_bridge.framework/Versions/A/chanora_bridge" \
"$FW/Versions/A/chanora_bridge"
echo "[chanora_bridge script_phase] framework refreshed"
SCRIPT
:execution_position => :before_compile,
}
# The pod has no Objective-C sources; it's purely a framework
# carrier. Suppress CocoaPods's source-file warning.
s.source_files = 'Frameworks/chanora_bridge.framework/Headers/*.h'
# No public Swift / ObjC API to expose — the Flutter app talks to
# the framework via FRB's FFI symbol lookup at runtime, not via
# imports.
end