Closed CouplenessTech closed 3 years ago
@CouplenessTech lmk how it goes! FWIW I think the important bit is upgrading to React Native 0.63.4
, since that sets the ENABLE_MODULES
flag to YES
, and not having had that might easily have been the problem, and I think RN might actually overwrite whatever value your project is set to
I had this problem too and tried a few things and now the problem is gone. I reduced react-native-purchases to 4.0.0 from 4.0.1 and npx react-native unlink react-native-purchases, and after reinstalling dependencies the problem was gone. Hopefully one of these two things solves your issue too.
Neither upgrading to React Native 0.63.4 nor unlinking and reinstalling dependencies worked
I had the exact same problem.
React Native 0.63.4 react-native-purchases 4.0.1
Before i was using 3.xx and it was working without issues. I then deleted the Pods folder, deleted the Podfile.lock and built again and it works now
@NiklasMencke that makes sense, thanks for posting. @iDuuck @EricWiener were you able to get it working?
@aboedo I will try to check soon. Sorry for the delay
@aboedo the solution @NiklasMencke mentioned worked for me. Thanks!
that's great to hear! thanks for reporting back!
@aboedo I spoke too soon. I was able to build, but when I just archived to try to release, it fails with the same error as before.
For anyone reading this to save you some time, here's all the things I tried. (And to make my last few hours seem worthwhile.)
I was working with an app I generated using Expo about a year ago and then ejected to be an Expo bare app a couple of months ago.
npx npm-check-updates -u
Reference: https://stackoverflow.com/a/16074029/3469524
Use compatible dependencies for Expo Bare App and Expo Web
expo upgrade
(This will also remove and reinstall your node_modules folder and package-lock.json file for you.) Reference: https://dev.to/expo/expo-sdk-40-is-now-available-1in0#bare-workflow
sudo gem install Cocoapods
References: https://guides.cocoapods.org/using/getting-started.html https://stackoverflow.com/questions/39481636/updating-to-latest-version-of-cocoapods/51103633#51103633
ios/Podfile
use_flipper!('Flipper' => '0.78.0')
android/gradle.properties
FLIPPER_VERSION=0.78.0
Reference: https://github.com/facebook/react-native/issues/30836#issuecomment-789368146
react-native link react-native-purchases
Manually update RNPurchases
pod 'RNPurchases', :path => '../node_modules/react-native-purchases', :inhibit_warnings => true, :modular_headers => false
Look at your git diff and manually remove duplicates lines that have been generated in ios/Podfile and android/app/src/main/java/[your/package/name]/MainApplication.java
rm ios/Podfile.lock
pod install --repo-update
cd android && ./gradlew clean && cd ../
cd ios && xcodebuild clean && cd ../
Reference: https://stackoverflow.com/a/56941424/3469524
On home screen click and hold icon -> 'Remove App' -> 'Delete App'
In Xcode go to Window -> Devices and Simulators right click your device click 'Unpair device'. Then unplug the device and plug it back in again and tap to trust it when popup displays.
Open in Xcode at the top if it says Any iOS Device (arm64, armv7) click on it and select your actual iPhone device. (Note: you need an actual iPhone, you can't use a simulator with react-native-purchases.) Click the big play button ▶
https://www.youtube.com/watch?v=lKXe3HUG2l4
Product -> Scheme -> Edit Scheme click on 'Run' on the left, change Build Configuration to 'Release' Press that play button again ▶
error: declaration of 'RCPurchases' must be imported from module 'Purchases' before it is required
pod cache clean --all
Reference: https://github.com/RevenueCat/react-native-purchases/issues/200#issuecomment-758538322
Press that play button again ▶ It works!
Product -> Archive
cd ios
rm -rf Pods
rm Podfile.lock
pod install
Then I was then able to make an archive in XCode XCode -> Product -> Archive
Reference: I did this after I read this comment by @NiklasMencke : https://github.com/RevenueCat/react-native-purchases/issues/200#issuecomment-788065699
I don't know why this works. I thought previously deleting Podfile.lock would be enough. I speculate either:
diff ios/Podfile.lock ios/Pods/Manifest.lock
)
(Update 30 March 2021: or it could be to do with non-semantic versioning. Either way looks like reinstalling Cocoapods works differently to npm install
that I'm used to.Also see: all the things I did first before this worked for me
Closing out this issue due to inactivity. If you're still running into issues, try following our SDK troubleshooting guide and open up a new issue if the steps described there don't help.
I am still getting this issue on my repo. Every time I want to do a release build I have to delete the pods and re-install. Did anyone solve this issue permanently without having to do cd ios rm -rf Pods rm Podfile.lock pod install
This is something I've been experiencing for a while, it starts working after doing some random changes (listed above ) and spending days to fix it, then out of the blue, it starts failing again. This happens on our CI/CD pipeline without any big changes to Xcode config or code.
No other library happens to behave like this one. Have any of you moved out to something else?
We recently re-wrote our PurchasesHybridCommon (and the Purchases
module it uses under the hood), and the re-write will very likely get rid of those issues. We're working on porting those changes over to React-Native soon, stay tuned!
So we could use the native SDKs? That's an option we are considering, we have a bunch of native integrations so we could pull this off too. Do you think it's a better approach?
You can use the native SDKs directly, of course, although it will take some extra work. All of what react-native-purchases
does is to bridge over the native SDKs to React-Native, so you'd essentially be doing the same as what react-native-purchases
does
Is there an update to this @aboedo? I'm still seeing it almost every month
@kdthomas2121 could you clarify exactly what you're running into? We've made quite a few changes since this issue was posted, including migrating the entire internal dependency that was originally causing the issue into Swift. So if you're still seeing it on modern SDK versions, it's likely to be caused by something different.
Would you mind opening up a new issue explaining what you're seeing?
Hi there, I wanted to share here in case this helps anyone else or helps debug the issue further.
I had never experienced this issue before with my project which has been using this lib for over 2 years. Then I got a new macbook with M2 Max chip and installed latest xcode 14.3.0 and got this for the first time. Others on here have said it happens randomly for them but I have found a specific scenario where I can replicate every time.
With a fresh clean project, I run the pod install and everything works fine, I can run over and over, I can make changes to podfile, install other libraries and run pod install again etc and everything continues to work fine. The issues begin if I run the xcode clean command (command + shift + K). When I run this and try to build it will fail every time with the could not build Objective-C module 'PurchasesHybridCommon'
error. Then the only way to recover is to delete pods and pod install again. (FYI for me it is enough to just delete the Purchases, PurchasesCoreSwift and PurchasesHybridCommon folders and run pod install, I do not have to delete and re-install all my Pods).
I'm not sure exactly what the xcode clean is doing under the hood but it is the only thing that causes this issue to happen for me. I can delete ios/build
folder, I can delete everything under the xcode DerivedData
folder and do a clean build with with no errors. Clearly the clean command does some other things too and one of them is messing with these Pods somehow.
Unfortunately I don't have time to investigate further due to other deadlines so I have simply been avoiding using the xcode clean command. Hope this helps others
The team responsible for Flutter projects here encountered this problem today. We still haven't figured out what is a definitive solution. But we noticed that it's happening only when running on iOS Simulators. Doesn't happen when running (debugging or not) in physical ones.
The problem also started after we cleaned the build folder.
Even after deleting Pods and Podfile.lock then running pod install, the problem persists. The only difference is that we can build and run the project, but the error comes up always when we face any kind of exception. But as I said before, it happens only in iOS Simulator.
Describe the bug
Production build of the app fails with the following error:
with the underlying error:
Context Platform: Azure DevOps Hosted Pool (macos-10.15) SDK: react-native-purchases@4.0.0 (latest) Software: XCode 12.2
Details Building using the command line: /xcodebuild -sdk iphoneos -configuration Release -workspace /ios/XX.xcworkspace -scheme XX build CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=iPhone Distribution: XX (XX) PROVISIONING_PROFILE=XX PROVISIONING_PROFILE_SPECIFIER=