Skip to content

fix(flutter): stage xcframework slice via script_phase — iOS CocoaPods link (issue #25) - #26

Merged
eric8810 merged 12 commits into
masterfrom
fix/ios-xcframework-link
Aug 4, 2026
Merged

fix(flutter): stage xcframework slice via script_phase — iOS CocoaPods link (issue #25)#26
eric8810 merged 12 commits into
masterfrom
fix/ios-xcframework-link

Conversation

@eric8810

@eric8810 eric8810 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

问题

Closes #25 — iOS 构建在链接阶段失败:\Framework 'aimux_ffi' not found\。

根因

Flutter 项目自定义了构建配置(base configuration),CocoaPods 的自动 xcframework 解包脚本(\Pods-*-frameworks.sh\)没有被挂载到 target——vendored framework 从未进入链接输入。pod install 警告:\CocoaPods did not set the base configuration...\。

修复

  • **\�indings/flutter/ios/embed-xcframework.sh**(新):按 \SDK_NAME\ 选择 slice(真机 \ios-arm64\ / 模拟器 \ios-arm64-simulator\),复制到 \PODS_XCFRAMEWORKS_BUILD_DIR/aimux/\(该目录已在 app 的 FRAMEWORK_SEARCH_PATHS 里)
  • podspec:新增 \script_phase\(pod target 构建阶段、before_compile 执行——不依赖 CocoaPods 的 base configuration 机制);\ orce_load\ 改为无条件指向 staged framework(每次只 stage 一个 slice)
  • CI:iOS example job 移除 \continue-on-error\,恢复
    m\ 符号检查(阻塞)

验证

  • \ lutter build ios --debug --no-codesign --simulator\ 通过

  • m -g Runner | grep aimux_openai_new\ 符号存在(force_load 生效)
  • Android/其他 job 不受影响

eric8810 added 12 commits August 4, 2026 16:47
CocoaPods' automatic xcframework script is not mounted in Flutter
projects (base configuration conflict), so the vendored framework never
reached the link step ('Framework aimux_ffi not found'). The podspec now
runs embed-xcframework.sh as a script_phase (pod target build, before
compile): it copies the slice selected by SDK_NAME into
PODS_XCFRAMEWORKS_BUILD_DIR/aimux, which is already in the app's
FRAMEWORK_SEARCH_PATHS. force_load now points at the staged framework
(unconditional — only one slice is ever staged). CI iOS job is blocking
again with the nm symbol check.
Slice staging fixed the 'Framework not found' error, but the app link
never consumed the framework: CocoaPods did not emit -framework aimux_ffi
for the vendored xcframework. Add -framework aimux_ffi (resolved via the
existing FRAMEWORK_SEARCH_PATHS entry) plus -force_load for the staged
archive so DynamicLibrary.process() finds the symbols.
With use_frameworks, aimux builds as a dynamic framework and the vendored
static library links into IT, not into the app. The -framework/-force_load
flags therefore belong in pod_target_xcconfig (the pod's own link step);
app-level flags never pulled the archive members in. The staged slice path
(PODS_XCFRAMEWORKS_BUILD_DIR) is valid in the pod build context, same as
the staging script_phase.
…real result

The first diagnostic grep returned exit 2 (missing xcconfig path) and
bash -e aborted the step before the symbol check ran — the build itself
may have been fine. Symbol check now runs first and prints OK/FAIL
explicitly; diagnostics are best-effort (|| true).
… must live in the main executable

Verified via full xcodebuild logs: aimux is a DYNAMIC framework under
use_frameworks; pod_target_xcconfig's force_load landed in aimux.framework
(clang -dynamiclib ... -force_load ... -o aimux), which is never embedded
(Runner.app/Frameworks empty). Dart uses DynamicLibrary.process()
(dlsym RTLD_DEFAULT), so symbols must be in the main binary.
user_target_xcconfig reaches Runner's link (Pods xcconfig is consumed).
Consulted gpt-5.6-sol + glm-5.2 (issue #25).
…unner.debug.dylib

The debug simulator build compiles the app code into Runner.debug.dylib
(link command: -o Binary/Runner.debug.dylib); Runner.app/Runner is a thin
stub, so checking it directly always came up empty. Scan every executable
inside Runner.app instead.
Verified fix (issue #25): force_load via user_target_xcconfig puts the
Rust symbols into the main executable (Runner.debug.dylib in debug
builds). Keep the whole-app symbol scan as the guard; remove verbose
linkage diagnostics.
@eric8810
eric8810 merged commit a322c7f into master Aug 4, 2026
21 checks passed
eric8810 added a commit that referenced this pull request Aug 4, 2026
docs: iOS CocoaPods link verified (issue #25/#26)
zerob13 pushed a commit to zerob13/aimux that referenced this pull request Aug 5, 2026
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.

iOS: CocoaPods fails to link vendored aimux_ffi.xcframework ('Framework aimux_ffi not found')

1 participant