Open KernAlan opened 2 weeks ago
I spent a few hours trying to simplify my setup, and only after removing a dynamic configuration function in my app.config.json
did this it fix the issue. I removed the dynamic configuration there in favor of an almost entirely static file.
Hi @KernAlan,
Can you share your dynamic config setup with me? Also, I believe that running a failing command with EXPO_DEBUG=1
would print a whole stack trace of the error giving us more info about the issue.
Here was the problematic app.config.json
:
const path = require("path");
const dotenv = require("dotenv");
module.exports = () => {
// Determine which .env file to use
const envPath = process.env.EAS_BUILD
? ".env.production"
: process.env.NODE_ENV === "production"
? ".env.production"
: ".env.development";
console.log(`[DEBUG] Attempting to load environment file: ${envPath}`);
const result = dotenv.config({ path: path.resolve(__dirname, envPath) });
if (result.error) {
console.error(`[ERROR] Failed to load ${envPath}:`, result.error);
} else {
console.log(`[INFO] Successfully loaded ${envPath}`);
}
console.log("[DEBUG] Environment variables in app.config.js:", {
API_BASE_URL: process.env.API_BASE_URL,
NODE_ENV: process.env.NODE_ENV,
});
const requiredVars = [
"FIREBASE_API_KEY",
"FIREBASE_AUTH_DOMAIN",
"FIREBASE_PROJECT_ID",
"FIREBASE_STORAGE_BUCKET",
"FIREBASE_MESSAGING_SENDER_ID",
"FIREBASE_APP_ID",
"API_BASE_URL",
];
requiredVars.forEach((varName) => {
if (!process.env[varName]) {
throw new Error(`Missing required environment variable: ${varName}`);
}
});
return {
expo: {
name: "lifesage",
scheme: "lifesage",
slug: "lifesage",
version: "1.0.1",
orientation: "portrait",
icon: "./assets/icon.png",
userInterfaceStyle: "light",
splash: {
image: "./assets/splash.png",
resizeMode: "contain",
backgroundColor: "#ffffff",
},
assetBundlePatterns: ["**/*"],
ios: {
supportsTablet: true,
bundleIdentifier: "com.kernalan.lifesage",
buildNumber: "1",
googleServicesFile: "./GoogleService-Info.plist",
entitlements: {
"aps-environment": "production",
},
podfileProperties: {
"use_modular_headers!": true,
"use_frameworks!": "static",
},
usesAppleSignIn: true,
},
android: {
adaptiveIcon: {
foregroundImage: "./assets/adaptive-icon.png",
backgroundColor: "#ffffff",
},
package: "com.kernalan.lifesage",
versionCode: 1,
},
web: {
favicon: "./assets/favicon.png",
bundler: "metro",
},
plugins: [
"expo-router",
[
"expo-build-properties",
{
ios: {
useFrameworks: "static",
},
},
],
],
extra: {
eas: {
projectId: "ad20d820-991c-44ec-8528-26af05ab9834",
},
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
FIREBASE_AUTH_DOMAIN: process.env.FIREBASE_AUTH_DOMAIN,
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID,
FIREBASE_STORAGE_BUCKET: process.env.FIREBASE_STORAGE_BUCKET,
FIREBASE_MESSAGING_SENDER_ID: process.env.FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_APP_ID: process.env.FIREBASE_APP_ID,
FIREBASE_MEASUREMENT_ID: process.env.FIREBASE_MEASUREMENT_ID,
API_BASE_URL: process.env.API_BASE_URL,
},
owner: "kernalan",
},
};
};
I haven't been able to test more, but I suspect EAS expects an object, not a function wrapper. I used the function to be able to do dynamic swapping of env variables here, but getting rid of that approach fixes the issue.
Build/Submit details page URL
https://expo.dev/accounts/kernalan/projects/lifesage
Summary
Running
eas build --platform ios --profile development
triggers a json parsing error as soon as the archive hits the EAS server:Managed or bare?
Managed
Environment
Error output
Reproducible demo or steps to reproduce from a blank project
eas build --platform ios --profile development