Skip to content

feat(apple/android): dual CocoaPods & SwiftPM support with universal Apple XCFramework (arm64 & x86_64) - #111

Open
sebasbad wants to merge 5 commits into
netdur:mainfrom
sebasbad:feat/cocoapods-swiftpm-dual-support
Open

feat(apple/android): dual CocoaPods & SwiftPM support with universal Apple XCFramework (arm64 & x86_64)#111
sebasbad wants to merge 5 commits into
netdur:mainfrom
sebasbad:feat/cocoapods-swiftpm-dual-support

Conversation

@sebasbad

@sebasbad sebasbad commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Restores CocoaPods compatibility alongside the newly added SwiftPM manifest (Package.swift), adds universal multi-architecture Apple XCFramework slices (arm64 and x86_64 for simulator, device, and macOS), and ensures out-of-the-box reliability for both iOS and Android downstream Flutter consumers.

Why Dual Support & Universal Binaries are Necessary

With v0.9.0-dev.12 introducing a SwiftPM manifest (Package.swift) while dropping .podspec, downstream Flutter iOS apps are forced into SwiftPM plugin resolution.

However, many existing Flutter apps cannot fully migrate to SwiftPM because they depend on popular third-party plugins (such as google_mobile_ads, google_mlkit_*, etc.) that currently support CocoaPods only and do not ship SwiftPM manifests. In these apps, Flutter's iOS build toolchain fails due to mixed package-manager collisions.

Furthermore, developer workflows on Apple platforms require running across heterogeneous simulator environments (Apple Silicon M1-M4 Macs as well as Intel / Rosetta Macs).

Providing dual package manager support and universal binaries enables:

  1. Legacy & Mixed CocoaPods Apps: Apps using CocoaPods dependencies resolve llama_cpp_dart seamlessly without breaking other CocoaPods plugins.
  2. SwiftPM Apps: Modern SwiftPM-only Flutter setups continue resolving via SwiftPM.
  3. Universal Simulator & Device Coverage: Developers on Apple Silicon (arm64) and Intel (x86_64) can test on both physical hardware and simulators without linker architecture errors (Framework 'llama' not found).

Changes Included

  • Universal llama.xcframework:
    • tool/build_apple_xcframework.sh: Enhanced build pipeline to compile and lipo universal slices for:
      • ios-arm64 (Physical iPhone/iPad)
      • ios-arm64_x86_64-simulator (Apple Silicon & Intel iOS Simulators)
      • macos-arm64_x86_64 (Universal macOS Desktop)
  • CocoaPods Dual Integration:
    • llama_cpp.podspec: Added s.prepare_command to automatically download and unpack the prebuilt llama-xcframework.zip release asset during pod install when build/apple/llama.xcframework is not present locally.
    • llama_cpp_dart.podspec: Added CocoaPods specifications (darwin/, ios/, and root) pointing directly to the release xcframework asset.
    • pubspec.yaml: Set podspecPath: llama_cpp_dart.podspec under ios and macos platform declarations.
  • FFI Dynamic Symbol Resolution:
    • lib/src/ffi/library_loader.dart: Enhanced loadFromProcess() with candidate dylib/framework fallback paths to ensure robust symbol resolution across case-sensitive and case-insensitive Apple filesystem layouts.

Supersedes

Supersedes #110.

…anager support

Restores CocoaPods compatibility (llama_cpp_dart.podspec) alongside the newly added SwiftPM manifest (Package.swift) for Flutter iOS apps with CocoaPods-only dependencies (e.g. google_mobile_ads).

Key Changes:
- Added llama_cpp_dart.podspec, ios/llama_cpp_dart.podspec, and darwin/llama_cpp_dart.podspec vendoring llama-xcframework.zip.
- Updated pubspec.yaml with podspecPath: llama_cpp_dart.podspec under iOS/macOS platform declarations.
- Bundled native/android/llama-cpp-dart.aar in repository for git dependency compatibility.
- Fixed iOS dynamic framework symbol lookup (LlamaLibrary.loadFromProcess) to support case-sensitive physical device APFS paths (Llama.framework/Llama).
@sebasbad
sebasbad force-pushed the feat/cocoapods-swiftpm-dual-support branch from c598bf9 to 659f80c Compare August 2, 2026 20:11
@sebasbad
sebasbad marked this pull request as ready for review August 2, 2026 20:11
@sebasbad
sebasbad marked this pull request as draft August 15, 2026 19:46
@sebasbad sebasbad changed the title feat(ios): add CocoaPods podspec alongside SwiftPM for dual package manager support feat(apple/android): dual CocoaPods & SwiftPM support with universal Apple XCFramework (arm64 & x86_64) Aug 15, 2026
@sebasbad
sebasbad marked this pull request as ready for review August 15, 2026 20:33
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.

1 participant