Cocoapods: "xxxx-swift.h" header file not found in dependent pod

Created on 26 Dec 2016  路  10Comments  路  Source: CocoaPods/CocoaPods

Hi

I m using cocoapod version :1.0.0
xcode version: 8.1

I created a new project called "NetworkManager" using Swift mix and match approach . As per apple guidelines xcode generated "-swift.h" header file. So "NetworkManger-swift.h" file generated at "build/intermediates/NetworkManager.build/Debug-iphonesimulator/NetworkManager.build/Derivedsources/" in my system. I added a statement #import "NetworkManager-swift.h" in my obj c file to use swift class. Build was success. Then converted this project into local pod.

I am adding above pod as dependent to client project. When i compile client project i am getting below error
fatal error: 'NetworkManager-Swift.h' file not found

import "NetworkManager-Swift.h"

This time the "NetworkManager-swift.h" generated at "/Build/Products/Debug-iphoneSimulator/NetworkManger/NetworkManager.framework/Headers" path.

is there any setting i have to set in podspec of my pod or in main project?
I did not find solution and stucked up from last few days
thank you

awaiting validation

Most helpful comment

In NMObjc, you should be importing NMSwift using angle brackets like this: #import <NMSwift/NMSwift-Swift.h>. What I see in the project is #import "NMSwift-Swift.h".

All 10 comments

Hi @VenuKotha! Are you attempting to import that header from outside of the framework project?

Yes! because i want to access those from my client projectt

I can not share my code so i created sample projects and placed in the below url. I created for just reference and can not execute.
https://github.com/VenuKotha/TestProj.git
https://github.com/VenuKotha/NMObjC.git
https://github.com/VenuKotha/NMSwift.git

Explanation:- "NMSwift" is one of my private pod written in Swift. I want to use this pod as dependent to "NMObjc" project. "NMObjc" is another private pod written in objc. As per apple guidelines if we want to use swift class in ObjC we have to use objective generated interface. So, I added "#import "NMSwift-Swift.h" in one of the file called "MZNetworkManager.m" in "NMObjC" project and Build was success.

Now i am using "NMObjc" as dependent for "TestProj". If I compile "TestProj" given error "NMSwift-Swift.h" file not found error at NMObjc pod

In NMObjc, you should be importing NMSwift using angle brackets like this: #import <NMSwift/NMSwift-Swift.h>. What I see in the project is #import "NMSwift-Swift.h".

Hi Ben,
Thank you very much for your solution. Your solution is successfully working in the reference project but it is not working with my project. After analyze I found one observation is NMObjc project created with Cocoatouch static library template in my project. So it works if I Imported "#import "NMSwift-Swift.h". In this context build is failed at "TestProject".
How can I handle in this case?
Can't I use swift mix and match if one pod is Staticlibrary template and other pod is singleview template?

Ah! For Swift libraries, you have to use the dynamic library template. That's an unfortunate limitation of Swift at this time.

Can you try with the dynamic library template?

Thank you Ben!

@VenuKotha no problem! It sounds like you were able to resolve this issue, so I'm going to close this out. If that's not the case, please feel free to reopen the issue. Have a great day!

I'm having the same issue.

I can build the stand alone project just fine if it has mixed swift/objc files, by just adding the following import to my .h file:

#import "MODULE_NAME-Swift.h"

However, when trying to build a react native app with cocoapods, I get that "MODULE_NAME-Swift.h" cannot be found. For me, it looks like cocoa is not building/generating the .h file. How can I fix this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gerchicov-bp picture gerchicov-bp  路  3Comments

pallaviMN picture pallaviMN  路  3Comments

steffendsommer picture steffendsommer  路  3Comments

5SMNOONMS5 picture 5SMNOONMS5  路  3Comments

hmistry picture hmistry  路  3Comments