react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

Unable to build via CocoaPods in project using Swift

Open jkhustler opened this issue 10 years ago • 15 comments

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 avatar Mar 04 '16 00:03 jkhustler

@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.

lostintangent avatar Mar 04 '16 00:03 lostintangent

sure thing! Do you mean the steps in the README? I've followed those and that's where I ran into problems

jkhustler avatar Mar 04 '16 00:03 jkhustler

Doh! I'm an idiot, I meant to add this link :)

lostintangent avatar Mar 04 '16 00:03 lostintangent

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.

jkhustler avatar Mar 04 '16 01:03 jkhustler

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 `

jkhustler avatar Mar 04 '16 01:03 jkhustler

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.

lostintangent avatar Mar 04 '16 01:03 lostintangent

No worries. Please let me know if there is anything I can do to help.

jkhustler avatar Mar 04 '16 01:03 jkhustler

@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.

geof90 avatar Mar 04 '16 10:03 geof90

@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 avatar Mar 04 '16 10:03 geof90

@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 avatar Mar 04 '16 15:03 lostintangent

@lostintangent yes I believe that is correct. However I have dependencies that require swift code :/ so I do need set "use_frameworks!"

jkhustler avatar Mar 04 '16 18:03 jkhustler

Is this a quick fix, or should I go ahead and try to other installation methods for now?

jkhustler avatar Mar 04 '16 21:03 jkhustler

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.

lostintangent avatar Mar 04 '16 21:03 lostintangent

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).

jordaaash avatar Mar 09 '16 10:03 jordaaash

@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?

lostintangent avatar Mar 09 '16 15:03 lostintangent