Skip to content

feat: add Swift Package Manager support for iOS and fix iOS available-memory reporting - #113

Merged
AmisKwok merged 7 commits into
mainfrom
feat/spm-migration
Oct 6, 2026
Merged

AmisKwok merged 7 commits into
mainfrom
feat/spm-migration

Conversation

@AmisKwok

@AmisKwok AmisKwok commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary / 摘要

Adds Swift Package Manager (SPM) support for iOS while keeping CocoaPods, fixes the iOS availMem metric that was badly over-reported, and bumps the version to 1.15.0.
为 iOS 新增 Swift Package Manager(SPM)支持(同时保留 CocoaPods),修复 iOS availMem 严重高估的问题,并将版本升至 1.15.0。

Changes / 变更

  • Added ios/zero_inspector_kit/Package.swift and moved the native Swift sources into the SPM layout ios/zero_inspector_kit/Sources/zero_inspector_kit/; the podspec now points at the new paths. CocoaPods support is kept, as Flutter requires plugins to support both until further notice.
    • 新增 ios/zero_inspector_kit/Package.swift,并把原生 Swift 源码迁到 SPM 布局 ios/zero_inspector_kit/Sources/zero_inspector_kit/;podspec 同步指向新路径。仍保留 CocoaPods 支持,因为 Flutter 要求插件暂时同时支持两者。
  • Fixed iOS availMem: it was estimated as "device total physical memory minus this process RSS", which ignored other processes and badly over-reported available memory. It now uses os_proc_available_memory() (iOS 13+). Removed the now-unused getUsedMemory() helper, and documented that iOS has no equivalent of Android's MemoryInfo.threshold (filled with 0).
    • 修复 iOS availMem:此前按「设备总物理内存减去本进程 RSS」估算,忽略其它进程,严重高估可用内存;现改用 os_proc_available_memory()(iOS 13+)。移除不再使用的 getUsedMemory(),并注明 iOS 无 Android MemoryInfo.threshold 对应项(填 0)。
  • Added version: 1.0.0+1 to the example app, removing the "Missing build name / build number" warnings on iOS builds.
    • 给 example 工程补上 version: 1.0.0+1,消除 iOS 构建的 “Missing build name / build number” 警告。
  • Bumped the version to 1.15.0 across pubspec.yaml, the iOS podspec, inspector_version.dart, both READMEs (install snippet, release/v1.15.0 ref, upgrade callout) and CHANGELOG.md.
    • 版本升至 1.15.0,同步更新 pubspec.yaml、iOS podspec、inspector_version.dart、中英 README(安装片段、release/v1.15.0 引用、推荐升级文案)与 CHANGELOG.md。

Context / 背景

Flutter 3.44+ uses Swift Package Manager by default and the CocoaPods registry becomes read-only on December 2, 2026, so plugins without SPM support break projects that have migrated. While reviewing the iOS native memory collection (after the 1.14.1 lowMemory fix), availMem turned out to have the same class of semantic defect, so it is fixed here as well.
Flutter 3.44+ 默认启用 SwiftPM,且 CocoaPods registry 将于 2026 年 12 月 2 日转为只读,插件若不提供 SPM 支持会导致已迁移的项目出问题。在复查 iOS 原生内存采集(继 1.14.1 的 lowMemory 修复之后)时发现 availMem 存在同类语义缺陷,故一并修复。

Checklist / 检查项

  • Title follows Conventional Commits / 标题符合约定式提交
  • CI checks pass after merge / 合入后 CI 通过

Test plan

  • flutter analyze clean and flutter test green (285 tests, including version_consistency_test) / flutter analyze 无问题、flutter test 全绿(285 项,含版本一致性测试)
  • flutter config --enable-swift-package-manager, then cd example && flutter build ios --simulator --no-codesign / 开启 SPM 后构建 iOS 示例
  • flutter config --no-enable-swift-package-manager, rebuild, and run pod lib lint ios/zero_inspector_kit.podspec --configuration=Debug --skip-tests --use-modular-headers / 关闭 SPM 后重新构建并跑 pod lib lint

🤖 Generated with Zero Buddy

Migrate the iOS native source into an SPM package layout per the Flutter plugin guide.

- Added ios/zero_inspector_kit/Package.swift: package name zero_inspector_kit, library zero-inspector-kit, platform iOS 13.0, FlutterFramework dependency, PrivacyInfo.xcprivacy as a resource.

- Moved ZeroInspectorKitPlugin.swift and PrivacyInfo.xcprivacy into ios/zero_inspector_kit/Sources/zero_inspector_kit/.

- Updated the podspec source_files path and enabled the privacy manifest resource bundle; CocoaPods support is retained as required.
Records the Swift Package Manager support and the iOS source layout move under a version placeholder, since this change will ship together with the next release and its version is not decided yet.
availMem was estimated as device total physical memory minus this process RSS, which ignored other processes and badly over-reported available memory. It now uses os_proc_available_memory() on iOS 13 plus. Also removes the now-unused getUsedMemory() helper, fills threshold with 0 because iOS has no equivalent of Android MemoryInfo.threshold, and clarifies the Dart field docs about the per-platform semantics.
Version bump covering the Swift Package Manager support and the iOS available-memory fix. Also adds a version field to the example app so iOS builds no longer warn about a missing build name and number.
Adds .github/workflows/docs.yml, which on pushes to main touching website sources or pubspec.yaml builds the Nextra site and commits the result back to docs/ as github-actions bot. Pages keeps serving the docs folder of main, so no repository setting change is needed.

sync-docs.mjs gains a --ci flag, because CI checks out a clean tree and the existing staged or unstaged change detection would always skip the build. The local .git/hooks/pre-commit is no longer used, and AGENTS.md plus CONTRIBUTING.md are updated to match (including the Pages branch, which is main and not docs/github-pages).
main is branch-protected, so a bot cannot push the built site back to it. docs.yml now publishes website/out/ to the root of the gh-pages branch (force_orphan, so the branch holds a single commit with only the built site), and the generated docs/ directory is removed from main.

sync-docs.mjs now only builds into website/out/ and writes .nojekyll, instead of syncing into docs/. link-check.yml scans website/pages instead of the removed docs directory. AGENTS.md, CONTRIBUTING.md and .pubignore are updated to match.

Manual step required once: Settings, Pages, Source, Deploy from a branch, branch gh-pages, folder root.
Scanning website/pages produced 69 false positives: Nextra uses extensionless route links such as /Custom-Database-Provider, which lychee resolves as local files that do not exist because the real file is Custom-Database-Provider.md. The previously scanned docs/ was built HTML where those routes existed as directories, so this only surfaced after the switch to the markdown source.

link-check now scans only README.md, README_zh.md and CHANGELOG.md again, and both the workflow and AGENTS.md record why website/pages is excluded.
@AmisKwok
AmisKwok merged commit 8245ef8 into main Oct 6, 2026
7 checks passed
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