Skip to content

refactor(macos): streamline KDF binary placement; update signing flow#247

Merged
CharlVS merged 6 commits intodevfrom
patch-macos-release-profile
Oct 20, 2025
Merged

refactor(macos): streamline KDF binary placement; update signing flow#247
CharlVS merged 6 commits intodevfrom
patch-macos-release-profile

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Oct 20, 2025

This PR merges macOS build/signing updates into dev.

Key changes

  • Streamline directory creation for KDF binary in podspec.
  • Move KDF binary from Resources to Framework Helpers.
  • Remove legacy macOS path in kdf_executable_finder.
  • Use code_sign_if_enabled and apply signing in required configurations.
  • Use thin_binary_to_archs for all Release configs.

Diff summary

  • 342ca1f refactor(podspec): streamline macOS directory creation for KDF binary
  • fb8cb57 refactor(kdf_executable_finder): remove legacy macOS path for KDF executable
  • c236a44 macos: move kdf binary from Resources to Framework Helpers
  • 2c696e1 change code signing approach, using code_sign_if_enabled function
  • 923f030 use thin_binary_to_archs for all Release configurations
  • b6ae8c6 signing for all configurations in which it's needed

Files touched

 .../lib/src/native/kdf_executable_finder.dart      |  15 ++-
 .../macos/komodo_defi_framework.podspec            | 110 ++++++++++++---------
 2 files changed, 69 insertions(+), 56 deletions(-)

Notes

  • Validated with static review. No tests run due to known repo constraints.
  • Please review CocoaPods/macOS build steps closely.

Summary by CodeRabbit

  • Chores
    • Restructured macOS resource bundling to improve how the framework locates and manages native helper executables.
    • Enhanced macOS build process with improved code signing, binary management, and organized helper directory structure.

not only in "Release", runtime flags for signing in "Release",
"Release-production", etc.
to avoid issues with unsigned resources ... we put SIGNED kdf binary to
Contents/Frameworks/komodo_defi_framework.framework/Versions/Current/Helpers/kdf

In case of using Resources - it will result with unsigned binary (!)

TODO: May be this should be reworked, but we shouldn't store the binaries
in resources, to avoid issues.
…cutable

Eliminated the legacy path for the KDF executable in macOS to streamline the executable finding process. This change aligns with the recent restructuring of binary locations to avoid issues with unsigned resources.
Consolidated the creation of application support, frameworks, and helpers directories into a single command to simplify the build process.
Copilot AI review requested due to automatic review settings October 20, 2025 12:38
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 20, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Refactors macOS executable discovery and packaging, transitioning from Resources bundle architecture to Helpers directory within the framework. Updates path construction in the finder and consolidates build-time code-signing operations into a reusable function.

Changes

Cohort / File(s) Summary
Executable Path Resolution
packages/komodo_defi_framework/lib/src/native/kdf_executable_finder.dart
Updates macOS resource path construction from Resources/kdf_resources.bundle/Contents/Resources to Versions/Current/Helpers. Renames macosKdfResourcePath to macosHelpersInFrameworkPath and updates all references. Minor constructor formatting adjustment.
Build Configuration & Packaging
packages/komodo_defi_framework/macos/komodo_defi_framework.podspec
Narrows resource bundle from ['bin/kdf', 'lib/*.dylib'] to ['lib/*.dylib'] only. Introduces helpers directory variable and consolidates directory creation. Refactors file-filtering logic to use case-based configuration. Reorganizes fat-binary pruning with consistent indentation. Consolidates per-file code-signing blocks into single code_sign_if_enabled function with parallel-signing support. Adds explicit code-sign and copy steps for kdf and libkdflib.dylib to Helpers. Maintains backward-compatibility guard.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

The podspec contains dense, multi-faceted refactoring spanning resource bundling, helper directory setup, file-filtering logic, fat-binary pruning, and code-signing consolidation. The dart file presents straightforward path updates with consistent naming changes, but the heterogeneous nature of the build script modifications demands separate reasoning for each section.

Poem

🐰 The helpers gather in their new Helpers place,
No more bundle chase through Resources space,
Code signs in harmony, one function true,
Kdf finds its way, through Versions' avenue! ✨

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch patch-macos-release-profile

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b520355 and 342ca1f.

📒 Files selected for processing (2)
  • packages/komodo_defi_framework/lib/src/native/kdf_executable_finder.dart (3 hunks)
  • packages/komodo_defi_framework/macos/komodo_defi_framework.podspec (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors macOS build/signing flow: relocates the kdf binary into the framework Helpers directory, updates pruning logic for Release configurations, and introduces a reusable code_sign_if_enabled function while removing the legacy resource bundle path in the Dart finder.

  • Streamlines directory creation and replaces single Release equality check with pattern matching.
  • Adds code signing helper and moves kdf lookup path to Framework Helpers.
  • Removes old macOS resource bundle path from executable finder.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
macos/komodo_defi_framework.podspec Adjusts resource bundles, directory setup, Release thinning logic, and introduces code_sign_if_enabled plus new Helpers placement and copy/sign flow.
lib/src/native/kdf_executable_finder.dart Replaces legacy resource bundle path with new Helpers path inside the framework for macOS executable discovery.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +60 to +61
case "$CONFIGURATION" in
Release*)
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case statement is missing a pattern terminator (;;). Shell case syntax requires ';;' after the commands for the Release* branch; without it the script will error at 'esac'. Add ';;' after the last command inside the Release* section before line 101.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The case statement is missing a pattern terminator (;;). Shell case syntax requires ';;' after the commands for the Release* branch; without it the script will error at 'esac'. Add ';;' after the last command inside the Release* section before line 101.

Suggested change
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 uses AI. Check for mistakes.
# Helpers in komodo_defi_framework is now the ONLY place where KdfExecutableFinder.findExecutable()
# will look for the kdf binary on macOS. The APP_SUPPORT_DIR copy is redundant but kept for
# backward compatibility with older builds.
if [ -f "$APP_SUPPORT_DIR/kdf" ]; then cp "$APP_SUPPORT_DIR/kdf" "$HELPERS_DIR/kdf"; fi
Copy link

Copilot AI Oct 20, 2025

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
'Resources',
'Versions',
'Current',
'Helpers',
Copy link
Copy Markdown

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 kdf binary within the framework at Versions/Current/Helpers/kdf, but the podspec copies it to Contents/Helpers/kdf. This path mismatch prevents the executable finder from locating the binary at runtime.

Additional Locations (1)

Fix in Cursor Fix in Web

'kdf_resources' => ['lib/*.dylib'].select { |f| Dir.exist?(File.dirname(f)) }
}

# s.preserve_paths = ['bin/kdf']
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing kdf Executable in App Bundle

The bin/kdf executable is no longer included in resource_bundles (L19) and its s.preserve_paths directive is commented out (L22). This prevents CocoaPods from making the file available, causing the build script's copy operation (L40) to fail. Consequently, the kdf executable is missing from the app bundle, breaking runtime functionality.

Fix in Cursor Fix in Web

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 28 to 35
# 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Copy kdf binary into framework Helpers path

The macOS script now defines HELPERS_DIR as ${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Helpers and copies the executable there. However, kdf_executable_finder.dart was simultaneously updated to only look in Frameworks/komodo_defi_framework.framework/Versions/Current/Helpers/kdf. Because the script no longer places the binary inside the framework’s Helpers directory, the runtime search path no longer contains the copied file and the kdf executable cannot be found on macOS builds. Update HELPERS_DIR to point at ${FRAMEWORKS_DIR}/komodo_defi_framework.framework/Versions/Current/Helpers (or add that location to the finder) so the binary ends up where the Dart code expects it.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown
Contributor

Visit the preview URL for this PR (updated for commit 342ca1f):

https://komodo-playground--pr247-patch-macos-release-yvz2hf45.web.app

(expires Mon, 27 Oct 2025 12:42:54 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2bfedd77fdea45b25ba7c784416e81f177aa5c47

@github-actions
Copy link
Copy Markdown
Contributor

Visit the preview URL for this PR (updated for commit 342ca1f):

https://kdf-sdk--pr247-patch-macos-release-plau059i.web.app

(expires Mon, 27 Oct 2025 12:43:39 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9c1b6e6c010cf0b965c455ba7a69c4aedafa8a1d

@CharlVS
Copy link
Copy Markdown
Collaborator Author

CharlVS commented Oct 20, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@CharlVS
Copy link
Copy Markdown
Collaborator Author

CharlVS commented Oct 20, 2025

Tested in GLEECBTC/gleec-wallet#3185

@CharlVS CharlVS merged commit 9881ff2 into dev Oct 20, 2025
8 of 9 checks passed
@CharlVS CharlVS deleted the patch-macos-release-profile branch October 20, 2025 12:53
@CharlVS CharlVS restored the patch-macos-release-profile branch October 20, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants