Unable to build via CocoaPods in project using Swift
I'm using the version 1.7.3-beta and am also installing React 0.20.0 via CocoaPods. When I install CodePush via cocoapods I am unable to build my project.
The error I get is: "RCTBridgeModule.h file not found".
@jkhustler Hey! Could you try following the steps in this post to see if that works for you? We just updated the docs to explain how to use CocoaPods to install CodePush, but we likely need to add docs for Swift installation specifically.
sure thing! Do you mean the steps in the README? I've followed those and that's where I ran into problems
Doh! I'm an idiot, I meant to add this link :)
When I use #import "CodePush.h", I get File not found.
If I use #import <CodePush/CodePush.h> I'm able to find the file but get the same error as before.
Maybe something to note is that my nodes_modules dir lives .. relative to my iOS project root rather than .. Here is what my Podfile looks like:
`use_frameworks!
def app_pods pod 'CocoaLumberjack/Swift', '2.2.0' pod 'LogglyLogger-CocoaLumberjack', '2.3.0' pod 'PubNub', '4.2.7' pod 'libPhoneNumber-iOS', '~> 0.8' pod 'ObjectMapper', '1.1.4' pod 'React', :path => '../node_modules/react-native', :subspecs => [ 'Core', 'RCTImage', 'RCTNetwork', 'RCTText', 'RCTWebSocket', ] pod 'CodePush', :path => '../node_modules/react-native-code-push' end
def testing_pods pod 'Quick', '0.9.1' pod 'Nimble', '3.1.0' end
target 'FAKE_APP_TARGET' do app_pods end
target 'FAKE_APP_TESTING_TARGET' do app_pods testing_pods end `
Hmm, Ok let me take a look at this tonight. I'm not immediately sure what the issue might be since the React Native headers should have been added to your header search path after installing it via CocoaPods. Sorry for the issue here, we haven't been (unfortunately) testing in Swift apps so there are likely a few bugs.
No worries. Please let me know if there is anything I can do to help.
@lostintangent i think the problem might be because we forgot to update the podspec file after we moved all the ios files to a subdirectory. Ill send out a PR to fix this in a bit.
@jkhustler while I'm working on the fix, you may want to take a stab at updating your own podspec file too, note that all the codepush .h and .m files are in the ios subdirectory!
@geof90 We haven't shipped that change to NPM yet so I'm not sure if that's the problem. We definitely need to fix it for our next release, but I think here is a problem with CodePush being built as a framework by CocoaPods. If you don't set "use_frameworks!" in your podfile, and you add the CodePush.h header to a Swift bridging header file, it works fine. But when "use_frameworks!" is set, you'll get the compile error mentioned in this bug.
@lostintangent yes I believe that is correct. However I have dependencies that require swift code :/ so I do need set "use_frameworks!"
Is this a quick fix, or should I go ahead and try to other installation methods for now?
I think I figured out the solution, I'm just testing it now :) Stay tuned, I should be sending out a PR within the hour.
pod 'React', :path => '../node_modules/react-native' is still necessary with 1.8.0-beta, which installs the pod for React 0.11.0 rather than what's in node_modules (I'm on 0.20.0).
@jordansexton Wasn't that always necessary? Or are you referring to a scenario where you're installing CodePush via CocoaPods, but not React Native itself?