Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore(mobile): update expo config metro and simulator script

Richie McIlroy507b57079009
diff --git a/apps/mobile/app.config.js b/apps/mobile/app.config.js
index 7d6f2acd2..e2e19b298 100644
--- a/apps/mobile/app.config.js
+++ b/apps/mobile/app.config.js
@@ -7,6 +7,7 @@ const associatedDomains =
.filter(Boolean)
: ["applinks:cap.so"];
const bundleIdentifier = "so.cap.mobile";
+const projectId = process.env.EXPO_PROJECT_ID;
const ios = {
bundleIdentifier,
supportsTablet: false,
@@ -33,35 +34,60 @@ module.exports = ({ config }) => ({
platforms: ["ios"],
userInterfaceStyle: "light",
icon: "./assets/icon.png",
- splash: {
- image: "./assets/splash-icon.png",
- resizeMode: "contain",
- backgroundColor: "#f9f9f9",
- },
ios,
+ runtimeVersion: {
+ policy: "appVersion",
+ },
+ updates: projectId
+ ? {
+ url: `https://u.expo.dev/${projectId}`,
+ }
+ : undefined,
experiments: {
typedRoutes: true,
},
plugins: [
"expo-router",
+ [
+ "expo-camera",
+ {
+ barcodeScannerEnabled: false,
+ cameraPermission: "Allow Cap to use your camera to record videos.",
+ microphonePermission:
+ "Allow Cap to use your microphone while recording videos.",
+ },
+ ],
[
"expo-font",
{
fonts: [
- "../web/public/fonts/NeueMontreal-Regular.otf",
- "../web/public/fonts/NeueMontreal-Medium.otf",
- "../web/public/fonts/NeueMontreal-Bold.otf",
+ "./assets/fonts/NeueMontreal-Regular.otf",
+ "./assets/fonts/NeueMontreal-Medium.otf",
+ "./assets/fonts/NeueMontreal-Bold.otf",
],
},
],
+ [
+ "expo-splash-screen",
+ {
+ backgroundColor: "#f9f9f9",
+ image: "./assets/splash-icon.png",
+ imageWidth: 200,
+ resizeMode: "contain",
+ },
+ ],
[
"expo-secure-store",
{
faceIDPermission: "Allow Cap to protect your account key.",
},
],
+ "expo-sharing",
+ "expo-video",
+ "expo-web-browser",
],
extra: {
apiBaseUrl: process.env.EXPO_PUBLIC_CAP_WEB_URL ?? "https://cap.so",
+ eas: projectId ? { projectId } : undefined,
},
});
diff --git a/apps/mobile/metro.config.js b/apps/mobile/metro.config.js
index 9c8cf0a0e..a1840e5bb 100644
--- a/apps/mobile/metro.config.js
+++ b/apps/mobile/metro.config.js
@@ -1,14 +1,11 @@
-const path = require("node:path");
const { getDefaultConfig } = require("expo/metro-config");
-const projectRoot = __dirname;
-const workspaceRoot = path.resolve(projectRoot, "../..");
-const config = getDefaultConfig(projectRoot);
+const config = getDefaultConfig(__dirname);
+const blockList = config.resolver.blockList;
-config.watchFolders = [workspaceRoot];
-config.resolver.nodeModulesPaths = [
- path.resolve(projectRoot, "node_modules"),
- path.resolve(workspaceRoot, "node_modules"),
+config.resolver.blockList = [
+ ...(Array.isArray(blockList) ? blockList : blockList ? [blockList] : []),
+ /[/\\]\.next[/\\].*/,
];
module.exports = config;
diff --git a/apps/mobile/scripts/run-ios-simulator.mjs b/apps/mobile/scripts/run-ios-simulator.mjs
index 1ea40fa0d..e50adc2d2 100644
--- a/apps/mobile/scripts/run-ios-simulator.mjs
+++ b/apps/mobile/scripts/run-ios-simulator.mjs
@@ -17,16 +17,18 @@ const readSimulators = () => {
return JSON.parse(result.stdout);
};
-const findSimulator = () => {
- const requestedUdid = process.env.IOS_SIMULATOR_UDID;
- const requestedName = process.env.IOS_SIMULATOR_DEVICE;
- const data = readSimulators();
- const devices = Object.values(data.devices ?? {})
+const availableIphones = () =>
+ Object.values(readSimulators().devices ?? {})
.flat()
.filter(
(device) => device?.isAvailable && device?.name?.includes("iPhone"),
);
+const findSimulator = () => {
+ const requestedUdid = process.env.IOS_SIMULATOR_UDID;
+ const requestedName = process.env.IOS_SIMULATOR_DEVICE;
+ const devices = availableIphones();
+
if (requestedUdid) {
const requested = devices.find((device) => device.udid === requestedUdid);
if (requested) return requested;
@@ -46,6 +48,33 @@ const findSimulator = () => {
return preferred ?? devices[0] ?? null;
};
+const findSimulatorByUdid = (udid) =>
+ availableIphones().find((device) => device.udid === udid) ?? null;
+
+const ensureSimulatorReady = (device) => {
+ if (device.state !== "Booted") {
+ console.log(`Booting iOS simulator: ${device.name} (${device.udid})`);
+ const boot = spawnSync("xcrun", ["simctl", "boot", device.udid], {
+ encoding: "utf8",
+ });
+ if (boot.status !== 0) {
+ const current = findSimulatorByUdid(device.udid);
+ if (current?.state !== "Booted" && current?.state !== "Booting") {
+ throw new Error(boot.stderr || `Unable to boot ${device.name}`);
+ }
+ }
+ }
+
+ const ready = spawnSync(
+ "xcrun",
+ ["simctl", "bootstatus", device.udid, "-b"],
+ { stdio: "inherit" },
+ );
+ if (ready.status !== 0) {
+ throw new Error(`Simulator did not finish booting: ${device.name}`);
+ }
+};
+
const simulator = findSimulator();
if (!simulator) {
throw new Error("No available iPhone simulators found");
@@ -74,6 +103,8 @@ if (process.env.CAP_MOBILE_DRY_RUN === "1") {
process.exit(0);
}
+ensureSimulatorReady(simulator);
+
if (
process.env.CAP_MOBILE_DISABLE_ASSOCIATED_DOMAINS === "1" &&
needsDevPrebuild()
@@ -99,9 +130,22 @@ if (
}
}
-const result = spawnSync("pnpm", command, {
- stdio: "inherit",
- env: process.env,
-});
+const runExpo = () =>
+ spawnSync("pnpm", command, {
+ stdio: "inherit",
+ env: process.env,
+ });
+
+let result = runExpo();
+if (result.status !== 0) {
+ const current = findSimulatorByUdid(simulator.udid);
+ if (current && current.state !== "Booted") {
+ console.warn(
+ `iOS simulator stopped while Expo was launching. Rebooting ${current.name} and retrying once.`,
+ );
+ ensureSimulatorReady(current);
+ result = runExpo();
+ }
+}
process.exit(result.status ?? 1);