Open mrousavy opened 3 years ago
I already tried cleaning the CameraBridge.h
file to not import anything at all which would resolve an import cycle, but apparently that wasn't the problem.
Would it work if I split the Swift and Objective-C files into 2 subspecs?
I found someone having the same issue here. Also related:
is there any solution for this?
I could not access the link to your branch nor to your files, could you double check?
Sorry, I must've accidentally deleted the branch when cleaning a bit. The issue is still present in the frame-processor branch
Are you able to solve this issue? I am facing the same issue here.
No, unfortunately I couldn't manage to get the bridging header import working. I had to manually forward-declare the Swift classes, which seems like a hacky workaround. See code here
No, unfortunately I couldn't manage to get the bridging header import working. I had to manually forward-declare the Swift classes, which seems like a hacky workaround. See code here
Thanks @mrousavy . I took a different approach though not complete yet. I created a new new podspec as dependency and added only swift file in that. so i have 2 podspec one containing swift files and 1 containing .h &.m.
May be this can help someone to find a better solution.
But Really thanks for your help.
Did you create two separate podspecs or did you use subspecs? I tried to use subspecs, one for the Swift code ("Core") and one for the .h, .m, .mm logic that imported the Swift bridging header, but that didn't work, can't remember what build errors I was getting
Did you create two separate podspecs or did you use subspecs? I tried to use subspecs, one for the Swift code ("Core") and one for the .h, .m, .mm logic that imported the Swift bridging header, but that didn't work, can't remember what build errors I was getting
sorry my mistake, I used subspec like this. s.subspec 'temp_swift' do |ss| ss.dependency 'React' ss.source_files = 'ios/NativeModule/*/.{h,m}' end
I am also getting error in frameworks which i embedded using podspec
Could not find module 'Alamofire' for target 'x86_64-apple-ios-simulator'; found: arm64, armv7-apple-ios, arm64-apple-ios, arm, armv7
Struggling to solve this issue. Any idea how to solve such issue if you have similar issue ?
@mrousavy i will need to take a look. Separating into two different root podspecs is preferable compared to two subspecs. There are quite a few nuances and issues around subspecs, particularly when a different set of subspecs is used across different targets.
also thanks for the great report and sample app, those help a ton.
Same issue here with a React Native module, and splitting the Swift and ObjC files into separate podspecs (the Swift one depending on the ObjC one) solved the problem for us.
@craigrouse Can you please share you podspecs and the way you import the -Swift.h file?
I have the same issue with react-native. I have created two podspecs in the root, the main one is objc which has a dependency to the swift pod.
I can see the generated Module-Swift.h
in the derived data, but the compiler can't find it...
Here's an example import: https://github.com/firebase/firebase-ios-sdk/blob/master/CoreOnly/Sources/Firebase.h#L77. The relevant podspecs are at the top of the repo.
@DanijelBojcic Have you been able to figure it out?
Report
What did you do?
I'm creating a library which contains Swift and Objective-C code. The library is called
VisionCamera
.In the Objective-C code, I want to import the Swift code by making use of the Objective-C generated interface header:
The
VisionCamera-Swift.h
header gets generated successfully, but seems to be incorrect because it tries to import itself:Full code of the generated
```objc // Generated by Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28) #ifndef VISIONCAMERA_SWIFT_H #define VISIONCAMERA_SWIFT_H #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wgcc-compat" #if !defined(__has_include) # define __has_include(x) 0 #endif #if !defined(__has_attribute) # define __has_attribute(x) 0 #endif #if !defined(__has_feature) # define __has_feature(x) 0 #endif #if !defined(__has_warning) # define __has_warning(x) 0 #endif #if __has_include(VisionCamera-Swift.h
What did you expect to happen?
I expect the Swift header to be imported successfully.
What happened instead?
It somehow gets generated incorrectly and tries to import itself with angle brackets (
<
) instead of quotes ("
), which apparently does not work.CocoaPods Environment
Stack
Installation Source
Plugins
Podfile
Project that demonstrates the issue
VisionCamera (
try-simplify-frame-processor
branch). See theVisionCamera.podspec
in the root, andios/
for sources.Relevant files:
CameraBridge.h
: The Objective-C to Swift bridgeFrameProcessorRuntimeManager.mm
: The Objective-C++ file where I try to import the Swift umbrella header