devthedevel
devthedevel

Reputation: 43

Cannot find generated -Swift.h file from local pod

I am creating a Turbo Module for React Native. The TM depends on another pod that I have created locally. I'm getting a compilation error stating that my generated -Swift.h header file is missing.

Heres the setup:

I have a local pod (lets call it "MyLocalPod") that is written in Swift. It is intended to use this pod with Objective-C code from my Turbo Module, so I have placed @objc attributes to the relevant public code in the pod. I have also updated some structs to be class objects that extends NSObject as well.

I have a React Native Turbo Module package setup with an example RN project included. The TM package's podspec uses the above local pod like so:

s.dependency "MyLocalPod"

Now I know you cannot add a local development pod to a podspec file so I used a workaround from this answer https://stackoverflow.com/a/49422999/10820594. My example app's Podfile is like the following:

pod 'MyLocalPod', :path => '/Users/dev/Projects/MyLocalPod'

In my Objective-C (.mm file) source code for the TM I import my local pod like:

#import <MyLocalPod/MyLocalPod-Swift.h>

But I always get a compilation error when I run npm run ios that says fatal error: 'MyLocalPod/MyLocalPod-Swift.h' file not found. The MyLocalPod-Umbrella.h file is found, but not the -Swift.h file.

I have tried a few things:

  1. Cleaned the product build, manually deleted DerivedData, and deleted Pods folder and Podfile.lock before completely re-adding the TM, codegen, and pod install multiple times (and in different orders)
  2. I manually built MyLocalPod before doing pod install in the example app
  3. Found the generated MyLocalPod-Swift.h header file deep in DerivedData and added its path to HEADER_SEARCH_PATHS in XCode
  4. Set Defined Modules to YES in MyLocalPod's target's Build Settings

Each possible fix never found the generated -Swift.h file.

Upvotes: 3

Views: 729

Answers (1)

La Gregance
La Gregance

Reputation: 359

On my case adding the following line in the iOS .podspec fix the problem (in the podspec from your iOS Swift library, not from the React Native library):

s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }

Then re-run pod install in your react native example app and Clean the Build folder

EDIT: Finally this doesn't work at all (it was a cache issue that make it temporary working in my case), I'm still looking for a solution...

Upvotes: 0

Related Questions