Skip to content

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

Merged
craftzdog merged 3 commits into
craftzdog:masterfrom
chrfalch:spm-support
Nov 17, 2026
Merged

craftzdog merged 3 commits into
craftzdog:masterfrom
chrfalch:spm-support

Conversation

@chrfalch

Copy link
Copy Markdown
Contributor

Summary

React Native 0.88 can build iOS libraries with Swift Package Manager (SwiftPM) instead of CocoaPods. react-native-quick-base64 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/ and cpp/ folders and defines RCT_NEW_ARCH_ENABLED=1, because CocoaPods gets that define from install_modules_dependencies. The library ships its codegen output in ios/generated (includesGeneratedCode: true), so the manifest compiles that output and the app does not generate it again.
  2. spm-include/react_native_quick_base64/QuickBase64.h: SwiftPM needs a public header folder. This folder holds only one header with no API. The podspec keeps the ios/ headers private. Under CocoaPods the cpp/ headers are public. Here they are private: as public headers, they broke @import react_native_quick_base64, because cpp/QuickBase64Impl.h includes the codegen header QuickBase64SpecJSI.h.
  3. package.json: the Swift package name (swiftpmConfig.name, react_native_quick_base64) and the new files in files. The podspec name has hyphens, which a Swift name cannot have.

#57 proposed a SwiftPM manifest for React Native 0.87 and was closed. Would you like SwiftPM support in this library? I am glad to change the approach.

Test plan

  • New React Native 0.88.1 app, set up for SwiftPM with npx react-native spm add --deintegrate --yes, with react-native-quick-base64 from this branch.
  • Without this change, spm add fails: Package.swift is missing for library "react-native-quick-base64".
  • xcodebuild Debug and Release, iOS simulator: both BUILD SUCCEEDED.
  • An Objective-C file in the app with @import react_native_quick_base64; compiles. With cpp/ as the public folder, it failed with 'QuickBase64SpecJSI.h' file not found.
  • Release build, without Metro: fromByteArray encodes SwiftPM native base64 to U3dpZnRQTSBuYXRpdmUgYmFzZTY0, and toByteArray decodes it back to the same text.
  • Not run: the library's lint and tests. This PR changes no JavaScript.

@craftzdog

Copy link
Copy Markdown
Owner

Thanks, i'll check it tomorrow

@craftzdog
craftzdog merged commit 0d71a07 into craftzdog:master Nov 17, 2026
5 of 6 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.

2 participants