0

I have a React Native app using Expo, and I need to integrate a Swift open-source library that doesn’t have any React Native bindings. Since I need to make some custom modifications to that library, I decided to clone the repository and include it as a git submodule inside a custom Expo module I created.

The library itself uses Swift Package Manager (SPM), and that’s where the problems begin. I’m getting errors like “... module not found” when the library tries to import its own SPM dependencies. I suspect this is due to conflicts between CocoaPods and SPM inside the Expo iOS environment.

Here’s what I’ve tried so far:

  1. Using spm_dependency in my .podspec file.

  2. Cloning all of the library’s dependencies into my module alongside the main repo, and creating a .podspec for each one to manually define dependency relationships (this sort of worked, but quickly became unscalable).

  3. Trying to bring the dependencies into the .podspec or Podfile, but the code is expecting them via SPM, so it only works with very old versions of the library.

  4. Using Xcode > Add Package Dependencies to manually add the SPM packages, both to the main project and to the Pods target generated inside the Expo module (this didn’t work either — same module resolution issues).

Note: every time I try something, I clean the iOS folder with:

-rf Pods build Podfile.lock pod install --repo-update

So here are my questions:

  1. Is it possible to use SPM dependencies in a React Native Expo project that uses CocoaPods?

  2. If I fork the library, make my changes, and keep using SPM (instead of migrating to Pods), could that actually work?

Any other ideas?

  • Node v22.12.0
  • Expo v0.22.26
  • React Native v0.76.9

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.