Skip to content

feat(ios): add Swift Package Manager support - #44

Open
chrfalch wants to merge 1 commit into
appandflow:mainfrom
chrfalch:spm-support
Open

chrfalch wants to merge 1 commit into
appandflow:mainfrom
chrfalch:spm-support

Conversation

@chrfalch

Copy link
Copy Markdown

Summary

React Native 0.88 can build iOS libraries with Swift Package Manager (SwiftPM) instead of CocoaPods. react-native-reserved-regions has no Package.swift, so apps that use SwiftPM cannot use it.

This PR adds SwiftPM support. CocoaPods users see no change, and no source file changes.

  1. Package.swift: the manifest that React Native's SwiftPM autolinking uses. It builds the ios/ folder and defines RCT_NEW_ARCH_ENABLED=1, because CocoaPods gets that define from install_modules_dependencies.
  2. spm-headers/RCTFabricComponentsPlugins.h: a one-line header that re-exports <React/RCTFabricComponentsPlugins.h>. ios/ReservedRegionsView.mm imports it with quotes. CocoaPods finds it through its header search paths, but SwiftPM does not.
  3. package.json: the Swift package name (swiftpmConfig.name, ReservedRegions, the same as the podspec) and the new files in files.

We sent the same kind of change to react-native-safe-area-context, which merged it.

Test plan

  • New React Native 0.88.1 app, set up for SwiftPM with npx react-native spm add --deintegrate, with react-native-reserved-regions from this branch.
  • Without this change, spm add fails: Package.swift is missing for library "react-native-reserved-regions".
  • xcodebuild Debug and Release, iOS simulator: both BUILD SUCCEEDED.
  • Release build, without Metro, iPhone 17 Pro simulator: the native view reports one region, an occlusion with frame x 0, y 0, width 402, height 54.
  • yarn lint, yarn typecheck and the Jest tests pass.

This branch has not been deployed

No deployments
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