lrettig / react-native-stripe

A React Native wrapper for the Stripe native SDK (currently iOS only)
MIT License
130 stars 28 forks source link

Stripe.framework not installed correctly with npm #3

Closed tobycox closed 8 years ago

tobycox commented 8 years ago

It seems that the framework gets created, but without any symlinks, so linking fails when the project is built.

Is there a better way to include this dependency?

lrettig commented 8 years ago

I noticed this too. It looks like the Stripe lib contains symlinks and npm deliberately doesn't support symlinks. I can think of a few options to get this working:

  1. RN discusses a tool called rnpm here that might work - haven't had a chance to try this yet
  2. Manually modify the stripe lib to replace symlinks with directories or remove them entirely - annoying because it would require keeping this up to date
  3. Requiring users to install the Stripe lib on their own, manually or via cocoapods

What do you think?

tobycox commented 8 years ago
  1. I'm not sure this will help, as I think rnpm just handles the addition of dependencies to XCode. Our problem is actually when npm packs the module — it doesn't include symlinks in order to support all platforms (https://github.com/npm/npm/issues/3310)
  2. This is what I've done on my branch and it seems to work OK. The way frameworks are constructed it's pretty painless. This option might be the easiest way to go for now.
  3. This would be the cleanest way if we could get it going. I'm not entirely sure how you can have a child project (react-native-stripe) depend on a library that's in a parent project though. We could maybe do something with header/library search paths, but that would be kind of dependent on the structure of the user's project. I'd be keen for this way if there's something smart we can do to make it work though.
lrettig commented 8 years ago

Agree that #2 is probably the way to go for now. Stripe doesn't update their library all that often and it's not critical that it be kept up to date here. The real problem is that there isn't an npm-type solution to dynamically include non-JS libraries in an npm module!

lrettig commented 8 years ago

I think I figured this out. Just released https://github.com/lrettig/react-native-stripe/releases/tag/release_1.0.3 which depends on cocoapods to download and install the Stripe lib. This works for me on my end, give it a shot and let me know if it works! (Note that you'll probably want to completely delete the old module and remove references to it and the Stripe lib from xcode)

After thinking about this some more, option 2. above seemed messy and incorrect to me.

tobycox commented 8 years ago

Worked for me! :dancer:

lrettig commented 8 years ago

Thanks for testing!

On Fri, Jan 29, 2016 at 12:06 PM, Toby Cox notifications@github.com wrote:

Worked for me! [image: :dancer:]

— Reply to this email directly or view it on GitHub https://github.com/lrettig/react-native-stripe/issues/3#issuecomment-176864824 .

jordangarside commented 8 years ago

What version of CocoaPods are you using? On 1.0.0.beta.6 I get the error: The dependencyStripeis not used in any concrete target.

On 0.39.0 it won't install for me and gives me a more verbose answer:

Analyzing dependencies [!] Unable to load a specification for the plugin /usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-deint egrate-1.0.0.beta.1

Command

/usr/local/bin/pod install

Report

Stack

   CocoaPods : 0.39.0

        Ruby : ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
    RubyGems : 2.5.1
        Host : Mac OS X 10.11.4 (15E65)
       Xcode : 7.3 (7D175)
         Git : git version 2.6.4 (Apple Git-63)
Ruby lib dir : /usr/local/Cellar/ruby/2.3.0/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 8b5591e4d0c4a7ada94aee7a10a1f8675f5f4
1c2

Plugins

cocoapods-plugins : 0.4.2
cocoapods-search  : 0.1.0
cocoapods-stats   : 0.6.2
cocoapods-trunk   : 0.6.4
cocoapods-try     : 0.5.1

Podfile

pod 'Stripe'

Error

NoMethodError - undefined method `to_ary' for #<Pod::Specification name="Stripe">
Did you mean?  to_query
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/resolver/lazy_specification.rb:14:i
n `method_missing'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/resolver.rb:64:in `flatten'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/resolver.rb:64:in `block in resolve

'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/resolver.rb:63:in `tap'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/resolver.rb:63:in `resolve'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer/analyzer.rb:539:in `block
 in resolve_dependencies'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/user_interface.rb:59:in `section'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer/analyzer.rb:537:in `resol
ve_dependencies'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer/analyzer.rb:70:in `analyz
e'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer.rb:213:in `analyze'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer.rb:136:in `block in resol
ve_dependencies'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/user_interface.rb:59:in `section'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer.rb:135:in `resolve_depend
encies'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/installer.rb:105:in `install!'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/command/project.rb:71:in `run_insta
ll_with_update'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/command/project.rb:101:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/claide-0.9.1/lib/claide/command.rb:312:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/lib/cocoapods/command.rb:47:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/cocoapods-0.39.0/bin/pod:44:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
lrettig commented 8 years ago

Hi @jordangarside

Sorry to hear you're having trouble. I'm using 0.39.0. I've installed this on a few computers and never had a problem. Are you able to install other pods?

L

jordangarside commented 8 years ago

@lrettig Thanks for getting back to me! I just found more information on this, seems to have to do with Ruby and CocoaPods, going to try different versions of Ruby. https://github.com/CocoaPods/CocoaPods/issues/4391

lrettig commented 8 years ago

Good luck, let me know if it works out or if you get stuck

On Sat, Apr 9, 2016 at 12:48 AM, Jordan Garside notifications@github.com wrote:

@lrettig https://github.com/lrettig Thanks for getting back to me! I just found more information on this, seems to have to do with Ruby and CocoaPods, going to try different versions of Ruby. CocoaPods/CocoaPods#4391 https://github.com/CocoaPods/CocoaPods/issues/4391

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lrettig/react-native-stripe/issues/3#issuecomment-207706077

jordangarside commented 8 years ago

@irettig Yeah so I tried to make CocoaPods use a different version of Ruby with rvm, but for some reason CocoaPods isn't using the global Ruby version.

They fixed this original install issue I was having in the 1.0.0 CocoaPods betas, but the podfile has to be modified so it has to correct target. I'm going to look at trying to get it to work myself for the betas and let you know how it goes. Here's how the syntax changed in CocoaPods 1.0.0.

Thanks!

lrettig commented 8 years ago

Thanks for the update! Glad to hear you've made some progress. Let me know if tweaking anything on my end would be helpful!

Lane

On Sat, Apr 9, 2016 at 8:47 PM, Jordan Garside notifications@github.com wrote:

@irettig Yeah so I tried to make CocoaPods use a different version of Ruby with rvm, but for some reason CocoaPods isn't using the global Ruby version.

They fixed this issue in the 1.0.0 CocoaPods betas, but the podfile has to be modified http://stackoverflow.com/questions/34556991/pod-install-displaying-error-in-cocoapods-version-1-0-0-beta-1 so it has to correct target. I'm going to look at trying to get it to work myself for the betas and let you know how it goes.

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/lrettig/react-native-stripe/issues/3#issuecomment-207891713

jordangarside commented 8 years ago

@irettig I gave up getting this to work. In Cocoapods 1.0.0 you have to specify the target which means you have to know the name of the target. Even when I hard code in the name of the project as the target, and the exact xcode project I get a different error saying NoMethodError - undefined method 'name' for nil:NilClass.

It ends up being more work for me to get this up and running than just making the manual version/form to support Android and iOS.

Thanks for the project!

lrettig commented 8 years ago

Hey @jordangarside thanks again for giving this a shot and especially for reporting back about what you saw. I will absolutely keep these lessons in mind for the future. The decision about whether or not to use cocoapods inside npms is a little unclear to me for reasons like this--if anyone else knows more about this and would like to weigh in, I'm open to learning more about it.

tiffanyricks commented 8 years ago

Hi @lrettig I had the same problem as @jordangarside with the Podfile. Your podfile needs a target.


target 'StripeNative' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for StripeNative
   pod 'Stripe'

end

For now I will try to add this module manually instead of using the Node Package Manager.