Stripe publishable key error


I’m building a white label app for work and wanted to test the different builds. I use app.config to setup the different variants. The app builds and runs fine when I build with the run commands but when I try to launch a release build from Xcode it throws an error for the stripe publishable key being nil.

I thought you could use the run commands to build the native projects and deploy manually through the native IDEs, if you wanted but maybe that’s not correct?

can you elaborate on exactly what is happening here? please provide code and exact commands, and what you are trying to accomplish

Hi Brent,

So the I am rebuilding existing native apps and currently there are 5 different variants. There’s no major differences between the projects. Just app icons, splash screens and some env variables, Api key, stripe key, google services etc.

I convinced my boss that using expo was the way to go now that EAS is here but I wanted to test it as much as I could before I signed us up. I didn’t want to get too deep into the project and find something that would block me.

So I install the stripe dependency and run expo run:ios. Builds no problem, and the client is installed and runs fine on the simulator. I wanted to test a release build so I changed the scheme to release in xcode and build and run from there. The app crashes on start up. It brings up a file from the stripe library where the publishable key is read from a dictionary and force unwrapped and thats where it crashes. Value is nil. I initialise stripe in App.tsx, with the initStripe method from a useEffect hook and provide the publishable key there. The key is coming from an environment variable that’s added with dotenv. I would have thought that was the problem but there are several variable being added and the rest work fine. It only happens when I run from Xcode. The dev client works fine if I run from the cli as normal.

Sorry about not providing code, I’m not at my work machine, I can get whatever you need tomorrow.

hi there! it sounds like maybe your dotenv isn’t working as expected. you might need to install something to inline that value in js - babel-plugin-inline-dotenv - npm

Ok, I’ll try that tomorrow. I’m still trying to get a grasp on how everything works so it most likely is a mistake I’m making with the config. Am I right in thinking that the run commands build the projects and I can archive as normal in Xcode or would there be something missing that EAS build provides? I fully intend to use EAS build but I like to know as much as I can about what’s going on with each command.

anything you can do with eas build you can also do on your own machine, yeah. see more info about what you can do with it here: EAS Build - Expo Documentation