Isar Plus
Recipes

SPM Migration

Migrating isar_plus_flutter_libs from CocoaPods to Swift Package Manager with a unified Darwin shared structure

SPM Migration Guide

This document describes the migration of isar_plus_flutter_libs from CocoaPods to Swift Package Manager (SPM) and the introduction of a unified Darwin shared structure for iOS and macOS.

If you are upgrading from a version that used CocoaPods, follow the steps in the Upgrading from CocoaPods section.

Overview

Prior to this migration, the plugin used separate CocoaPods podspecs for iOS and macOS, with distinct native source directories for each platform. The new structure:

  • Uses a single Package.swift at the plugin root for SPM configuration
  • Shares all Darwin (iOS + macOS) native source code under darwin/Classes/
  • Ships a unified IsarPlusCore.xcframework containing slices for iOS device, iOS simulator, and macOS
  • Removes all CocoaPods artifacts (.podspec files, Podfile, Pods/ directories)

New Darwin Shared Structure

packages/isar_plus_flutter_libs/
├── darwin/
│   └── Classes/
│       ├── binding.h                       ← FFI declarations (shared)
│       └── IsarPlusFlutterLibsPlugin.swift ← Unified plugin (iOS + macOS)
├── Package.swift                           ← SPM manifest
└── pubspec.yaml                            ← Flutter plugin config

The darwin/Classes/ directory is the single source of truth for all Apple platform native code. Platform-specific imports (UIKit vs Cocoa) are handled via Swift conditional compilation (#if os(iOS) / #elseif os(macOS)).

Unified XCFramework Structure

The native Isar Core library is distributed as a single IsarPlusCore.xcframework containing three slices:

SliceArchitectureDescription
ios-arm64arm64iOS physical devices
ios-arm64_x86_64-simulatorarm64 + x86_64iOS Simulator (universal)
macos-arm64_x86_64arm64 + x86_64macOS (Apple Silicon + Intel)

All slices use static archives (.a), which is required for SPM vendored binary support. The macOS slice is no longer a .dylib.

Installation and Setup

New Projects

For new projects, no special setup is required. Add the dependency to your pubspec.yaml and Flutter's tooling will automatically resolve the plugin via SPM:

dependencies:
  isar_plus: ^1.2.6
  isar_plus_flutter_libs: ^1.2.6

Flutter automatically handles SPM resolution when sharedDarwinSource: true is set in the plugin's pubspec.yaml. No manual Xcode configuration is needed.

Upgrading from CocoaPods

For most Flutter projects, migrating to Swift Package Manager does not require changing your application code unless your project has custom Xcode configurations or dependencies that make heavy use of CocoaPods install scripts. Updating to the latest version of the plugin will automatically migrate your underlying dependency manager on Apple platforms to Swift Package Manager.

If you are managing other non-Flutter dependencies via CocoaPods, you may need to migrate those manually or keep them. If you want to fully remove CocoaPods from your project, follow these steps:

Remove CocoaPods artifacts

With Xcode closed, uninstall your CocoaPods dependencies and delete the generated workspace:

cd ios
pod deintegrate
rm -rf Podfile Podfile.lock Pods Runner.xcworkspace
cd ..

(Repeat for the macos directory if applicable).

Clean derived data

In Xcode, go to Product → Clean Build Folder (⇧⌘K), or delete DerivedData manually:

rm -rf ~/Library/Developer/Xcode/DerivedData

Resolve packages

Open your project in Xcode and go to File → Packages → Resolve Package Versions, or run:

flutter pub get

Build and verify

Run your app on a simulator or device to confirm everything works:

flutter run

Last Update

Table of Contents