Skip to main content
Solved

RevenueCatUI/DebugErrorView.swift:68: Fatal error: Purchases has not been configured

  • Jul 20, 2024 7:56 PM UTC
  • 1 reply
  • 924 views

yavuzakyazici
Forum|alt.badge.img+7

Hello everyone,

I got RevenueCat working with Expo iOS development build but when I submit to appstore or even do a local preview build, app crashes on startup.

I connected my iPhone to my mac with cable and launched the console app. And when I filtered the streaming console I found this error that caused the crash 

RevenueCatUI/DebugErrorView.swift:68: Fatal error: Purchases has not been configured.

However, I did configure the Purchases at the very root in my App.js
I tried these both…
 

  const configurePurchases = async () => {
if (Platform.OS === "ios") {
Purchases.configure({ apiKey: process.env.EXPO_PUBLIC_RC_IOS });
}
};

configurePurchases();

and… 

 

const configurePurchases = async () => {
if (Platform.OS === "ios") {
Purchases.configure({ apiKey: process.env.EXPO_PUBLIC_RC_IOS });
}
};
useEffect(() => {
async function init() {
await configurePurchases();
}
init();
}, []);

They both work at the development build on a physical device.
But they both crash at startup on TestFlight or local Preview Build.

And when it crashes Mac Console App says..
“RevenueCatUI/DebugErrorView.swift:68: Fatal error: Purchases has not been configured.”

It was working fine before. I don’t know what happened or how to fix this.
Can anybody help?
 

Best answer by yavuzakyazici

This was because of gitignore respecting .env and this caused leaving API key out of the app.
So, It turns out you have to be careful with gitignore.
If you do not want to include your .env file with git commits, Then you can have it in your .gitignore but you have to remember to delete .env line from your gitignore everytime you build for store submission.

View original
This post has been closed for comments

1 reply

yavuzakyazici
Forum|alt.badge.img+7
  • Author
  • Helper
  • Answer
  • Jul 21, 2024 4:40 AM UTC

This was because of gitignore respecting .env and this caused leaving API key out of the app.
So, It turns out you have to be careful with gitignore.
If you do not want to include your .env file with git commits, Then you can have it in your .gitignore but you have to remember to delete .env line from your gitignore everytime you build for store submission.