-
Notifications
You must be signed in to change notification settings - Fork 9
refactor(macos): streamline KDF binary placement; update signing flow #247
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
Changes from all commits
b6ae8c6
923f030
2c696e1
c236a44
fb8cb57
342ca1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,26 +16,22 @@ A new Flutter FFI plugin project. | |||||||
| s.dependency 'FlutterMacOS' | ||||||||
|
|
||||||||
| s.resource_bundles = { | ||||||||
| 'kdf_resources' => ['bin/kdf', 'lib/*.dylib'].select { |f| Dir.exist?(File.dirname(f)) } | ||||||||
| 'kdf_resources' => ['lib/*.dylib'].select { |f| Dir.exist?(File.dirname(f)) } | ||||||||
| } | ||||||||
|
|
||||||||
| # s.preserve_paths = ['bin/kdf'] | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Missing
|
||||||||
|
|
||||||||
| s.script_phase = { | ||||||||
| :name => 'Install kdf executable and/or dylib', | ||||||||
| :execution_position => :before_compile, | ||||||||
| :script => <<-SCRIPT | ||||||||
| # Get the application support directory for macOS | ||||||||
| APP_SUPPORT_DIR="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Library/Application Support" | ||||||||
| FRAMEWORKS_DIR="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Frameworks" | ||||||||
| HELPERS_DIR="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Helpers" | ||||||||
|
|
||||||||
| # Ensure the application support directory exists | ||||||||
| if [ ! -d "$APP_SUPPORT_DIR" ]; then | ||||||||
| mkdir -p "$APP_SUPPORT_DIR" | ||||||||
| fi | ||||||||
|
|
||||||||
| # Ensure the frameworks directory exists | ||||||||
| if [ ! -d "$FRAMEWORKS_DIR" ]; then | ||||||||
| mkdir -p "$FRAMEWORKS_DIR" | ||||||||
| fi | ||||||||
| # Create all required directories in one go | ||||||||
| mkdir -p "$APP_SUPPORT_DIR" "$FRAMEWORKS_DIR" "$HELPERS_DIR" | ||||||||
|
|
||||||||
|
Comment on lines
28
to
35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The macOS script now defines Useful? React with 👍 / 👎. |
||||||||
| # Track if we found at least one of the required files | ||||||||
| FOUND_REQUIRED_FILE=0 | ||||||||
|
|
@@ -61,54 +57,74 @@ A new Flutter FFI plugin project. | |||||||
| fi | ||||||||
|
|
||||||||
| # Prune binary slices to match $ARCHS (preserve universals) in Release builds only | ||||||||
| if [ "$CONFIGURATION" = "Release" ]; then | ||||||||
| TARGET_ARCHS="${ARCHS:-$(arch)}" | ||||||||
| case "$CONFIGURATION" in | ||||||||
| Release*) | ||||||||
|
Comment on lines
+60
to
+61
|
||||||||
| TARGET_ARCHS="${ARCHS:-$(arch)}" | ||||||||
|
|
||||||||
| thin_binary_to_archs() { | ||||||||
| file="$1" | ||||||||
| keep_archs="$2" | ||||||||
| thin_binary_to_archs() { | ||||||||
| file="$1" | ||||||||
| keep_archs="$2" | ||||||||
|
|
||||||||
| [ -f "$file" ] || return 0 | ||||||||
| [ -f "$file" ] || return 0 | ||||||||
|
|
||||||||
| # Only act on fat files (multi-arch) | ||||||||
| if ! lipo -info "$file" | grep -q 'Architectures in the fat file'; then | ||||||||
| return 0 | ||||||||
| fi | ||||||||
| # Only act on fat files (multi-arch) | ||||||||
| if ! lipo -info "$file" | grep -q 'Architectures in the fat file'; then | ||||||||
| return 0 | ||||||||
| fi | ||||||||
|
|
||||||||
| bin_archs="$(lipo -archs "$file" 2>/dev/null || true)" | ||||||||
| [ -n "$bin_archs" ] || return 0 | ||||||||
| bin_archs="$(lipo -archs "$file" 2>/dev/null || true)" | ||||||||
| [ -n "$bin_archs" ] || return 0 | ||||||||
|
|
||||||||
| dir="$(dirname "$file")" | ||||||||
| base="$(basename "$file")" | ||||||||
| work="$file" | ||||||||
| dir="$(dirname "$file")" | ||||||||
| base="$(basename "$file")" | ||||||||
| work="$file" | ||||||||
|
|
||||||||
| for arch in $bin_archs; do | ||||||||
| echo "$keep_archs" | tr ' ' '\n' | grep -qx "$arch" && continue | ||||||||
| echo "Removing architecture $arch from $base" | ||||||||
| next="$(mktemp "$dir/.${base}.XXXXXX")" | ||||||||
| lipo "$work" -remove "$arch" -output "$next" | ||||||||
| [ "$work" != "$file" ] && rm -f "$work" | ||||||||
| work="$next" | ||||||||
| done | ||||||||
| for arch in $bin_archs; do | ||||||||
| echo "$keep_archs" | tr ' ' '\n' | grep -qx "$arch" && continue | ||||||||
| echo "Removing architecture $arch from $base" | ||||||||
| next="$(mktemp "$dir/.${base}.XXXXXX")" | ||||||||
| lipo "$work" -remove "$arch" -output "$next" | ||||||||
| [ "$work" != "$file" ] && rm -f "$work" | ||||||||
| work="$next" | ||||||||
| done | ||||||||
|
|
||||||||
| if [ "$work" != "$file" ]; then | ||||||||
| mv -f "$work" "$file" | ||||||||
| fi | ||||||||
| } | ||||||||
| if [ "$work" != "$file" ]; then | ||||||||
| mv -f "$work" "$file" | ||||||||
| fi | ||||||||
| } | ||||||||
|
|
||||||||
| thin_binary_to_archs "$APP_SUPPORT_DIR/kdf" "$TARGET_ARCHS" | ||||||||
| if [ -f "$APP_SUPPORT_DIR/kdf" ]; then chmod +x "$APP_SUPPORT_DIR/kdf"; fi | ||||||||
| thin_binary_to_archs "$APP_SUPPORT_DIR/kdf" "$TARGET_ARCHS" | ||||||||
| if [ -f "$APP_SUPPORT_DIR/kdf" ]; then chmod +x "$APP_SUPPORT_DIR/kdf"; fi | ||||||||
|
|
||||||||
| thin_binary_to_archs "$FRAMEWORKS_DIR/libkdflib.dylib" "$TARGET_ARCHS" | ||||||||
| if [ -f "$FRAMEWORKS_DIR/libkdflib.dylib" ]; then install_name_tool -id "@rpath/libkdflib.dylib" "$FRAMEWORKS_DIR/libkdflib.dylib"; fi | ||||||||
| thin_binary_to_archs "$FRAMEWORKS_DIR/libkdflib.dylib" "$TARGET_ARCHS" | ||||||||
| if [ -f "$FRAMEWORKS_DIR/libkdflib.dylib" ]; then install_name_tool -id "@rpath/libkdflib.dylib" "$FRAMEWORKS_DIR/libkdflib.dylib"; fi | ||||||||
|
||||||||
| if [ -f "$FRAMEWORKS_DIR/libkdflib.dylib" ]; then install_name_tool -id "@rpath/libkdflib.dylib" "$FRAMEWORKS_DIR/libkdflib.dylib"; fi | |
| if [ -f "$FRAMEWORKS_DIR/libkdflib.dylib" ]; then install_name_tool -id "@rpath/libkdflib.dylib" "$FRAMEWORKS_DIR/libkdflib.dylib"; fi | |
| ;; |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The kdf binary is signed before being copied into Helpers, but the copy placed in Helpers (the only lookup location) is never re-signed. This can leave the executed binary unsigned, triggering Gatekeeper or runtime issues. Invoke code_sign_if_enabled on '$HELPERS_DIR/kdf' after the copy (or copy first, then sign both locations if backward compatibility is needed).
| if [ -f "$APP_SUPPORT_DIR/kdf" ]; then cp "$APP_SUPPORT_DIR/kdf" "$HELPERS_DIR/kdf"; fi | |
| if [ -f "$APP_SUPPORT_DIR/kdf" ]; then cp "$APP_SUPPORT_DIR/kdf" "$HELPERS_DIR/kdf"; fi | |
| code_sign_if_enabled "$HELPERS_DIR/kdf" || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Dart Code Mismatch with Podspec Path
The Dart code expects the
kdfbinary within the framework atVersions/Current/Helpers/kdf, but the podspec copies it toContents/Helpers/kdf. This path mismatch prevents the executable finder from locating the binary at runtime.Additional Locations (1)
packages/komodo_defi_framework/macos/komodo_defi_framework.podspec#L30-L34