React-native-iap: Can't run on iOS due to 'unknown type name 'SKPaymentDiscount'

Created on 25 Apr 2019  ·  38Comments  ·  Source: dooboolab/react-native-iap

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.

⌛️ legacy 📱 iOS

Most helpful comment

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

All 38 comments

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?

@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

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

@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

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

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

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.

@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

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

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

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

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

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

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 !

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

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

It will from 3.0.0

Thanks, will stay on 2.4.8 till 3.0.0 will be released

@DataGreed Just released 3.0.0 now.

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

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

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

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

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

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.

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

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

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

@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 (https://github.com/facebook/react-native/issues/25252)

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

@murilobast different xCode versions?

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

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.

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.

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

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

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

Yes, me too ! excellent work from the maintainers !

Was this page helpful?
0 / 5 - 0 ratings