shoutem / react-native-shopify

React Native bridge to Shopify Buy SDK
261 stars 42 forks source link

Installation questions #11

Closed jonathandion closed 7 years ago

jonathandion commented 7 years ago

Hi,

When I run the command react-native run-ios to build the project I got 2 errors from the Shopify ios SDK: error: cannot find protocol declaration for 'PKPaymentAuthorizationControllerDelegate'; did you mean 'PKPaymentAuthorizationViewControllerDelegate'?

I installed the SDK with cocoapod but never called #import "Buy.h" inside my Xcode project. Should I?

Thanks.

donedgardo commented 7 years ago

Once you install with cocoapod you should open your xcode project with the newly created workspace inside your ios folder. Once opened try building it.

Air-Miha commented 7 years ago

Hi Jonathan,

The bridge imports "Buy.h". What version of the Pod are you using and did you run react-native link?

Could you give us the exact file and line where this error is raised?

jonathandion commented 7 years ago

@donedgardo Hi, exactly what I did but failed.

@sirhotsauce cocoapod version 1.2.0 and shopify sdk 2.2.0 . Yes, I ran the link command. No issue there.

I built the project using xCode and react-native run-ios both failed.

Screenshot

React native version react-native-cli: 2.0.1 react-native: 0.41.2

Air-Miha commented 7 years ago

@jonathandion

Use Mobile Buy SDK 2.2.0 pod instead of 1.2.0.

jonathandion commented 7 years ago

@sirhotsauce Sorry about that I'm using Mobile-Buy-SDK (2.2.0) my Cocoapod installation is 1.2.0

Air-Miha commented 7 years ago

@jonathandion

It can't find the protocol in the PassKit framework that the Shopify iOS SDK is linking to. It has something to do with your XCode, iOS or CocoaPods version. What version of XCode is this? I use 8.2.1 and CocoaPods 1.1.1. Try changing these parameters.

Btw, did you open .xcodeproj or workspace? You need to open the workspace file after installing the pod.

jonathandion commented 7 years ago

@sirhotsauce I updated my Xcode now it's working. I still have an error argument 0 (NSUInteger) of RNShopify. must not be null

Your help is appreciate. thanks.

jgrancher commented 7 years ago

@jonathandion Is that when your calling Shopify.getProducts() ? In that case, just replace it by Shopify.getProducts(1).

jonathandion commented 7 years ago

@jgrancher it's working thanks. How come I need to add 1?

jgrancher commented 7 years ago

@jonathandion For some reason, the simplest way to get your products from the Shopify SDK is via their mehod getProductsPage:completion that requires a page number, starting from page 1. You can also get your products by Tags or Ids, if you need to.

From this bridge though, you shouldn't need to specify 1 as it's the default argument since this PR #8.

jonathandion commented 7 years ago

@jgrancher thank you for the details! We need to update the Readme it's confusing.

webmaster100 commented 7 years ago

Hi, I installed Mobile Buy SDK for IOS according to Dynamic framework installation instructions( Dragged Mobile Buy SDK.xcodeproj to the Libraries folder; added Buy as a Target Dependency; Add Buy.Framework as Embedded Binaries in General tab) and after that ran react-native link react-native-shopify. When building the project, the following error occurs: "Buy.h file not found" in RNShopify.h file. Can you advise what else should I do to correctly import Buy.h? Thanks! embedded_binaries file_not_found

Air-Miha commented 7 years ago

Hi @webmaster100 ,

Any reason you're not using CocoaPods? We can debug this, but if you have an option to use Pods, it would work out of the box.

webmaster100 commented 7 years ago

Hi @Air-Miha, I used it earlier, but there was an error "Shopify.initialize is not defined" and I could not resolve it with packager restart. I tried it again and this time the error gone . With CocoaPods it is working. Now when calling getProducts Shopify.getProducts(1).then(products => { console.log( 'products', products); }).catch(error => { console.log( 'error', error); }); the app crashes and the console in Xcode shows the following error: image How can I resolve it? Thank you!

Air-Miha commented 7 years ago

@webmaster100, what version of the SDK are you using? And, do you have any products in your shop? It seems that parsing the products from JSON fails in the SDK. Put some logs there in XCode and see what object becomes nil and crashes everything.

webmaster100 commented 7 years ago

@Air-Miha, I am using 2.2.0. I see that products are returned The error occurs after this line and debugger do not go further nsarray buyadditions m edited 2017-04-03 18-25-41 Also the same error occurs for Shopify.getCollections(1)

webmaster100 commented 7 years ago

When running the following code: var cart = [{ variant: 29192253131, quantity: 1, }]; Shopify.checkout(cart).then(products => { I get an error -[__NSCFNumber count]: unrecognized selector sent to instance 0xb000006cbfe6ecb3' was thrown while invoking checkout on target RNShopify with params ( ( { quantity = 1; variant = 29192253131; } ) I have not found documentation for different methods, so I am not sure is it a proper format for cart parameter. I am not IOS developer and finding the correct method usages in Mobile Buy SDK Sample App is not the easiest option. What can be the cause of this error? Thanks!

Air-Miha commented 7 years ago

@webmaster100,

Can you log (using NS Log) all the products returned? It will tell us why the SDK breaks on this method. We're using 2.2.0 as well.

As for the cart, check out this thread:

https://github.com/shoutem/react-native-shopify/issues/6

webmaster100 commented 7 years ago

@Air-Miha, I could not use NSLog or printf, it seems there is some bug with printing logs in Xcode 8 and simulator. I copied one of the product from debug window: <__NSArrayI 0x6000003a4600>( { available = 1; "body_html" = "

\n

Condition: Barely Used

\n

Personal Note:

\n<p style=\"padding-left: 30px;\">\"not specified\"

\n
"; "created_at" = "2017-04-03T07:47:12-06:00"; handle = "02-04-phone-1"; images = ( { "created_at" = "2017-04-03T04:04:18-06:00"; id = 17319786827; position = 1; "product_id" = 8447042955; src = "https://cdn.shopify.com/s/files/1/1626/9455/products/122a5b147-466c-4e33-8678-49ca87569e5b.jpg?v=1491213858"; "updated_at" = "2017-04-03T04:04:18-06:00"; "variant_ids" = ( ); } ); options = ( { id = 10121130443; name = Title; position = 1; "product_id" = 8447042955; } ); "product_id" = 8447042955; "product_type" = ""; "published_at" = "2017-04-03T07:47:12-06:00"; tags = "Furniture"; title = "02.04 phone"; "updated_at" = "2017-04-03T07:47:12-06:00"; variants = ( { available = 1; barcode = ""; "compare_at_price" = "19.00"; "created_at" = "2017-04-03T04:04:08-06:00"; "formatted_price" = "$9.00"; grams = 0; id = 29192253131; "option_values" = ( { name = Title; "option_id" = 10121130443; value = "Default Title"; } ); position = 1; price = "9.00"; "requires_shipping" = 1; sku = ""; taxable = 0; title = "Default Title"; "updated_at" = "2017-04-03T07:47:12-06:00"; } ); vendor = Name; }, I also opened the issue here https://github.com/Shopify/mobile-buy-sdk-ios/issues/561

Air-Miha commented 7 years ago

@webmaster100, this looks like a similar issue to this one:

https://github.com/Shopify/mobile-buy-sdk-ios/issues/405

Could you tell me the steps you did to include the Mobile Buy SDK? Perhaps the issue is something trivial.

Here's what we did:

  1. We created a Podfile where we included the Mobile Buy SDK 2.2.0 as a Pod.
  2. We ran pod install

Did you do anything else in between? Also, could you try with a different XCode version? In the worst case, you can do what the guys in the above thread did: copying the managed object model file directly into your project. But, perhaps uninstalling and then reinstalling everything will help.

Keep us posted!

webmaster100 commented 7 years ago

@Air-Miha I just run pod install with the file like this:

frameworks use_frameworks! pod "Mobile-Buy-SDK" end There were a warning about overwriting Framework Search Paths and I added $(inherited) to the list of paths as described in this message. But this didn't fix the error. After I copied by reference the datamodel file to Compile Sources it started to work. image Thank you!

Definitely-Not-Vlad commented 7 years ago

Closing since it's resolved.