Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run on iOS due to 'unknown type name 'SKPaymentDiscount' #465

Closed
dayhaysoos opened this issue Apr 25, 2019 · 38 comments
Closed

Can't run on iOS due to 'unknown type name 'SKPaymentDiscount' #465

dayhaysoos opened this issue Apr 25, 2019 · 38 comments
Labels
📱 iOS Related to iOS ⌛️ legacy Getting old

Comments

@dayhaysoos
Copy link

Version of react-native-iap

2.4.9

Version of react-native

0.59.5

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

App builds

Actual behavior

App doesn't build

Tested environment (Emulator? Real Device?)

Emulator

Steps to reproduce the behavior

Just react-native run-ios with the above versions of react-native-iap and React native

This is the exact error I get:

/node_modules/react-native-iap/ios/RNIapIos.m:167:5: unknown type name 'SKPaymentDiscount'; did you mean 'SKProductDiscount'?

I tried renaming SKPaymentDiscount to SKProductDiscount just to see and I was getting different errors.

Let me know if you have any questions.

@hyochan hyochan added ⌛️ legacy Getting old 📱 iOS Related to iOS labels Apr 26, 2019
@hyochan
Copy link
Owner

hyochan commented Apr 26, 2019

I've not yet tested this in recent ios version. I feel like there has been changes in newer version. Could you give us a PR if possible?

@dayhaysoos
Copy link
Author

@hyochan I'd be happy to, but I'm not 100% sure how I'd do it. Can you walk me through setting up a PR for y'all? I don't know what the fix would be

@hyochan
Copy link
Owner

hyochan commented Apr 26, 2019

@ndejesus1227 Do you think you've found the solution to this issue?

@dayhaysoos
Copy link
Author

@hyochan no, I haven't. I've made attempts at fixing it but I only know JavaScript. I'd have to find someone to help who knows Native iOS much better than I do

@hyochan
Copy link
Owner

hyochan commented Apr 26, 2019

@ndejesus1227 Actually, this feature has been implemented by @renatoalencar in #455. I can't help this out further currently.

@dayhaysoos
Copy link
Author

Thanks, @hyochan.

@renatoalencar what version of react native are you running on? I'm not sure if I should be downgrading react-native-iap or RN for now

@renatoalencar
Copy link
Contributor

Hello @ndejesus1227, that's on me, sorry. What is actually happening is that your iOS version is below 12.2. As the Apple documentation describes, the SKPaymentDiscount is available only for iOS 12.2+.

I was suppose to verify the actual iOS version, but ended up forgetting.

@dayhaysoos
Copy link
Author

@renatoalencar ah, okay. That makes sense. Do you have any idea on when you can make a fix for this? You can take your time, just curious

@dayhaysoos
Copy link
Author

I'll be downgrading to a version before this update until this is addressed @hyochan @renatoalencar

@ggdegreat
Copy link

i having this issue too on version 2.4.11. The only version that worked before @hyochan made a changes is 2.4.8

@Lucas-Geitner
Copy link

Thanks for the explanation @ggdegreat, so i'm going to 2.4.8 !

@nolanrbrady
Copy link

I was having the same issue, and can confirm that 2.4.8 fixes the issue. Thanks for the help!

@hyochan
Copy link
Owner

hyochan commented May 6, 2019

So the package won't be compatible with ios below 12 from 2.4.9. I've updated readme for migration.

@hyochan hyochan closed this as completed May 6, 2019
@Lucas-Geitner
Copy link

Is the payment with apple Pay (and no popup) going to work ?

We need to keep both version sync if we want to use in production library.

We cannot choose between version > 12 or version < 12 for business !

There are probably something i don't get ! Thanks for your work @hyochan !

@aniltirola
Copy link

aniltirola commented Jun 6, 2019

I had the same problem - now solved. For over a year I did not open Xcode. Now I took my iphone 6s and upgraded to firmware 12.3.1; my mac was still on 'Sierra', so my Xcode installation was not compatible with the latest ios. When trying to run code on macbook-connected iphone I got these messages. Then the solution:

  • I upgraded my Mac-OS to 10.14.5
  • I upgrade Xcode to 10.2.1
  • I use react-native-iap 2.5.5
  • iPhone 6S with iOS 12.3.1
  • ejected expo-project with sdk 32.0.0, that means expo-modified-react-native based on 0.57

---> now everything works

@DataGreed
Copy link

So, the app using this library won't work when running on iOS <12.2 ?

@hyochan
Copy link
Owner

hyochan commented Jun 19, 2019

It will from 3.0.0

@DataGreed
Copy link

Thanks, will stay on 2.4.8 till 3.0.0 will be released

@hyochan
Copy link
Owner

hyochan commented Jun 19, 2019

@DataGreed Just released 3.0.0 now.

@ghost
Copy link

ghost commented Jun 20, 2019

@hyochan we can still see the problem with SKPaymentDiscount on v3.0.0.

Is there something we are missing? we just updated the version on package.json, did the install and clean/build the app in xcode. The error still appear.

@hyochan
Copy link
Owner

hyochan commented Jun 20, 2019

@danidfm What is your build target in ios? Also, try to fully remove node_modules before npm install

@ghost
Copy link

ghost commented Jun 20, 2019

build target is 11.0 and we removed enterely the node_modules folder.

@DataGreed
Copy link

same problem with me – tried 3.0.0, but rolled back to 2.4.8

@DataGreed
Copy link

(by the way, prior to that I tried 3.0.0 RC versions and still got the same error)

@hyochan
Copy link
Owner

hyochan commented Jun 20, 2019

Could you all kindly test IamExample project and see the difference with your project? I want to be clear on looking at the same codes.

@dayhaysoos
Copy link
Author

Hello @ndejesus1227, that's on me, sorry. What is actually happening is that your iOS version is below 12.2. As the Apple documentation describes, the SKPaymentDiscount is available only for iOS 12.2+.

I was suppose to verify the actual iOS version, but ended up forgetting.

I just want to say that he literally send he was supposed to verify the version and avoid this issue, but he forgot. His pull request should have never been merged into master

@iLyxa3D
Copy link

iLyxa3D commented Jun 23, 2019

Trying to Run project in Xcode for my iPhone with iOS v12.3.1
Same error, using react-native-iap v3.2.2.
Going to 2.4.8 (build successful)

I think the reason is iOS version installed on the device

@hyochan
Copy link
Owner

hyochan commented Jun 24, 2019

This is very odd, because some of them already confirmed the build is ok (so do I). If you are having problem upgrading please try to remove ios/build then try again.

I've just tried building now. Check IapExample.
image

@francbelak
Copy link

francbelak commented Jun 24, 2019

@hyochan thank you for your great support!

I just tried all the hints mentioned in this issue (completely removed node_modules before npm install, clean app, removed ios/build). Unfortunately I am still getting this issue in combination with build target 11.2 and react-native-iap v3.2.2. I also tried downgrading to v2.4.8, which leads to a successful build. Moreover I tried to setup IapExample but end up in this react-native issue (facebook/react-native#25252)

@murilobast
Copy link

I'm having the same issue on an iMac with macOS 10.13. My macbook running 10.15 is building fine,

Maybe older mac version is not working? 🤔

@DataGreed
Copy link

@murilobast different xCode versions?

@rizvanrzayev
Copy link

rizvanrzayev commented Jun 28, 2019

Check os version #if __IPHONE_12_2 error code block and rebuild

`#if __IPHONE_12_2

    SKPaymentDiscount *discount = [[SKPaymentDiscount alloc]
                                   initWithIdentifier:discountOffer[@"identifier"]
                                   keyIdentifier:discountOffer[@"keyIdentifier"]
                                   nonce:[[NSUUID alloc] initWithUUIDString:discountOffer[@"nonce"]]
                                   signature:discountOffer[@"signature"]
                                   timestamp:discountOffer[@"timestamp"]
                                   ];

    SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
    payment.applicationUsername = usernameHash;
    payment.paymentDiscount = discount;
    
    [[SKPaymentQueue defaultQueue] addPayment:payment];
    [self addPromiseForKey:RCTKeyForInstance(payment.productIdentifier) resolve:resolve reject:reject];
    #endif `

like this

@NickAVolpe
Copy link

I was running into this issue. Updating my xcode from 10.1 to 10.2.1 fixed my issue. I am able to build my project now.

@lc3t35
Copy link

lc3t35 commented Jul 17, 2019

Same problem with Xcode 10.1, I can't update XCode to 10.2 because it needs OSX 10.14.3, not suppported by my old iMac stuck at 10.13.6.

@liudmyla-schastlyvets
Copy link

@lc3t35 , how did you build iOS project with Xcode 10.1?

@lc3t35
Copy link

lc3t35 commented Aug 21, 2019

@liudmyla-schastlyvets I can't build with 10.1, I had to use another computer with Xcode lastest version :(

@ismetsezer
Copy link

react-native: 0.59.0
react-native-iap:2.4.8
Xcode: 10.1
Successfully Built Project. Thanks

@lc3t35
Copy link

lc3t35 commented Sep 26, 2019

Yes, me too ! excellent work from the maintainers !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📱 iOS Related to iOS ⌛️ legacy Getting old
Projects
None yet
Development

No branches or pull requests