Open History to see the last commit
1import type { ExpoConfig } from "expo/config";
2
3import { BRAND_ASSET_PATHS } from "../../scripts/lib/brand-assets.ts";
4import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
5
6type AppVariant = "development" | "preview" | "production";
7
8const repoEnv = loadRepoEnv();
9Object.assign(process.env, repoEnv);
10
11const APP_VARIANT = resolveAppVariant(repoEnv.APP_VARIANT);
12const isIosPersonalTeamBuild = repoEnv.T3CODE_IOS_PERSONAL_TEAM === "1";
13const runtimeVersionPolicy =
14 process.env.MOBILE_VERSION_POLICY ??
15 (APP_VARIANT === "development" ? "appVersion" : "fingerprint");
16
17const personalTeamBundleIdentifier = repoEnv.T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID?.trim();
18const IOS_BUNDLE_IDENTIFIER_PATTERN = /^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;
19
20const fromRepoRoot = (relativePath: string) => `../../${relativePath}`;
21// Android layers are rendered by scripts/export-android-icons.ts from the Icon Composer sources.
22// The wordmark sits inside the adaptive safe zone; the variant artwork is a full-bleed background.
23const androidAdaptiveForeground = "./assets/android-icon-foreground.png";
24
25if (
26 isIosPersonalTeamBuild &&
27 (!personalTeamBundleIdentifier ||
28 !IOS_BUNDLE_IDENTIFIER_PATTERN.test(personalTeamBundleIdentifier))
29) {
30 throw new Error(
31 "T3CODE_IOS_PERSONAL_TEAM_BUNDLE_ID must be a reverse-DNS identifier such as com.example.t3code when T3CODE_IOS_PERSONAL_TEAM=1.",
32 );
33}
34
35const DEVELOPMENT_ASSETS = {
36 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
37 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIconComposerProject),
38 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.developmentIosIconPng),
39 androidAdaptiveForeground,
40 androidAdaptiveBackgroundColor: "#347FF8",
41 androidAdaptiveBackgroundImage: "./assets/android-icon-background-dev.png",
42 androidSplashIcon: "./assets/android-splash-icon-dev.png",
43 androidMonochromeIcon: "./assets/android-icon-mark.png",
44 androidNotificationIcon: "./assets/android-notification-icon.png",
45 androidNotificationColor: "#00639B",
46} as const;
47
48const PREVIEW_ASSETS = {
49 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
50 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIconComposerProject),
51 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.nightlyIosIconPng),
52 androidAdaptiveForeground,
53 androidAdaptiveBackgroundColor: "#111533",
54 androidAdaptiveBackgroundImage: "./assets/android-icon-background-nightly.png",
55 androidSplashIcon: "./assets/android-splash-icon-nightly.png",
56 androidMonochromeIcon: "./assets/android-icon-mark.png",
57 androidNotificationIcon: "./assets/android-notification-icon.png",
58 androidNotificationColor: "#7565C7",
59} as const;
60
61const RELEASE_ASSETS = {
62 appIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
63 iosIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIconComposerProject),
64 splashIcon: fromRepoRoot(BRAND_ASSET_PATHS.productionIosIconPng),
65 androidAdaptiveForeground,
66 androidAdaptiveBackgroundColor: "#000000",
67 androidAdaptiveBackgroundImage: undefined,
68 androidSplashIcon: "./assets/android-splash-icon-prod.png",
69 androidMonochromeIcon: "./assets/android-icon-mark.png",
70 androidNotificationIcon: "./assets/android-notification-icon.png",
71 androidNotificationColor: "#FFFFFF",
72} as const;
73
74const VARIANT_CONFIG = {
75 development: {
76 appName: "T3 Code Dev",
77 scheme: "t3code-dev",
78 iosBundleIdentifier: "com.t3tools.t3code.dev",
79 androidPackage: "com.t3tools.t3code.dev",
80 relyingParty: "clerk.t3.codes",
81 assets: DEVELOPMENT_ASSETS,
82 },
83 preview: {
84 appName: "T3 Code Preview",
85 scheme: "t3code-preview",
86 iosBundleIdentifier: "com.t3tools.t3code.preview",
87 androidPackage: "com.t3tools.t3code.preview",
88 relyingParty: "clerk.t3.codes",
89 assets: PREVIEW_ASSETS,
90 },
91 production: {
92 appName: "T3 Code",
93 scheme: "t3code",
94 iosBundleIdentifier: "com.t3tools.t3code",
95 androidPackage: "com.t3tools.t3code",
96 relyingParty: "clerk.t3.codes",
97 assets: RELEASE_ASSETS,
98 },
99} as const;
100
101function resolveAppVariant(value: string | undefined): AppVariant {
102 switch (value) {
103 case "development":
104 case "preview":
105 case "production":
106 return value;
107 default:
108 return "production";
109 }
110}
111
112const variant = VARIANT_CONFIG[APP_VARIANT];
113const iosBundleIdentifier = isIosPersonalTeamBuild
114 ? personalTeamBundleIdentifier!
115 : variant.iosBundleIdentifier;
116
117const dmSansFonts = {
118 regular: "@expo-google-fonts/dm-sans/400Regular/DMSans_400Regular.ttf",
119 medium: "@expo-google-fonts/dm-sans/500Medium/DMSans_500Medium.ttf",
120 bold: "@expo-google-fonts/dm-sans/700Bold/DMSans_700Bold.ttf",
121} as const;
122
123const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
124 "expo-widgets",
125 {
126 bundleIdentifier: `${iosBundleIdentifier}.widgets`,
127 groupIdentifier: `group.${iosBundleIdentifier}`,
128 enablePushNotifications: true,
129 // Agent activity can update many times an hour; without the
130 // frequent-updates entitlement iOS throttles the update budget sooner.
131 frequentUpdates: true,
132 widgets: [
133 {
134 name: "AgentActivity",
135 displayName: "Agent Activity",
136 description: "Shows the current state of active T3 Code agents.",
137 supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
138 },
139 ],
140 },
141];
142
143const sharingPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
144 "expo-sharing",
145 {
146 ios: {
147 // Personal Teams cannot sign App Groups or extension targets. Keep the
148 // reduced-capability local build usable while release builds expose the
149 // real system share target.
150 enabled: !isIosPersonalTeamBuild,
151 extensionBundleIdentifier: `${iosBundleIdentifier}.sharing`,
152 appGroupId: `group.${iosBundleIdentifier}`,
153 activationRule: {
154 supportsText: true,
155 supportsWebUrlWithMaxCount: 1,
156 supportsImageWithMaxCount: 8,
157 supportsMovieWithMaxCount: 8,
158 supportsFileWithMaxCount: 8,
159 },
160 },
161 android: {
162 enabled: true,
163 singleShareMimeTypes: ["*/*"],
164 multipleShareMimeTypes: ["*/*"],
165 },
166 },
167];
168
169// These aliases match the fonts' PostScript names on iOS. Register the same
170// names on Android so React Native and the native composer use one set of
171// family names without waiting for runtime font loading.
172
173const config: ExpoConfig = {
174 name: variant.appName,
175 slug: "t3-code",
176 platforms: ["ios", "android"],
177 scheme: variant.scheme,
178 version: "1.1.1",
179 runtimeVersion: {
180 // Development manifests resolve on every launch, so avoid fingerprint's
181 // expensive native-project calculation there. Preview and production stay
182 // fingerprinted so OTAs only reach binaries with matching native projects.
183 policy: runtimeVersionPolicy,
184 },
185 orientation: "portrait",
186 icon: variant.assets.appIcon,
187 userInterfaceStyle: "automatic",
188 updates: {
189 enabled: repoEnv.T3CODE_MOBILE_UPDATES_ENABLED !== "0",
190 url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
191 checkAutomatically: "ON_LOAD",
192 fallbackToCacheTimeout: 0,
193 },
194 ios: {
195 icon: variant.assets.iosIcon,
196 supportsTablet: true,
197 // Multitasking-capable iPad apps cannot rotate programmatically, so the
198 // showcase capture build requires full screen (see infoPlist below).
199 requireFullScreen: process.env.T3_SHOWCASE_CAPTURE_BUILD === "1",
200 bundleIdentifier: iosBundleIdentifier,
201 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
202 // does not fall back to a personal team (which cannot sign app groups,
203 // Sign in with Apple, or push notification entitlements).
204 appleTeamId: "ARK85ZXQ4Z",
205 associatedDomains: [
206 `applinks:${variant.relyingParty}`,
207 `webcredentials:${variant.relyingParty}`,
208 ],
209 entitlements: {
210 "keychain-access-groups": [`$(AppIdentifierPrefix)${variant.iosBundleIdentifier}`],
211 },
212 infoPlist: {
213 NSAppTransportSecurity: {
214 NSAllowsArbitraryLoads: true,
215 },
216 NSLocalNetworkUsageDescription:
217 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
218 NSPhotoLibraryAddUsageDescription: "Allow T3 Code to save images to your photo library.",
219 ITSAppUsesNonExemptEncryption: false,
220 // The App Store screenshot harness rotates the iPad interface from
221 // inside the app (CI denies osascript the Accessibility access that
222 // Simulator menu scripting needs), and iPadOS ignores programmatic
223 // orientation requests for multitasking-capable apps — so the capture
224 // build opts out of multitasking and declares landscape support.
225 ...(process.env.T3_SHOWCASE_CAPTURE_BUILD === "1"
226 ? {
227 "UISupportedInterfaceOrientations~ipad": [
228 "UIInterfaceOrientationPortrait",
229 "UIInterfaceOrientationPortraitUpsideDown",
230 "UIInterfaceOrientationLandscapeLeft",
231 "UIInterfaceOrientationLandscapeRight",
232 ],
233 }
234 : {}),
235 },
236 },
237 android: {
238 icon: variant.assets.appIcon,
239 package: variant.androidPackage,
240 ...(repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE
241 ? { googleServicesFile: repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE }
242 : {}),
243 adaptiveIcon: {
244 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
245 ...(variant.assets.androidAdaptiveBackgroundImage
246 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
247 : {}),
248 foregroundImage: variant.assets.androidAdaptiveForeground,
249 monochromeImage: variant.assets.androidMonochromeIcon,
250 },
251 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
252 // JS back handling survives it via react-native's Android 16 shim plus
253 // withAndroidPredictiveBackCompat on Android 13-15.
254 predictiveBackGestureEnabled: true,
255 },
256 web: {
257 favicon: variant.assets.appIcon,
258 },
259 plugins: [
260 "expo-asset",
261 [
262 "expo-font",
263 {
264 ios: {
265 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
266 },
267 android: {
268 fonts: [
269 {
270 fontFamily: "DMSans-Regular",
271 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
272 },
273 {
274 fontFamily: "DMSans-Medium",
275 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
276 },
277 {
278 fontFamily: "DMSans-Bold",
279 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
280 },
281 ],
282 },
283 },
284 ],
285 "expo-secure-store",
286 "expo-sqlite",
287 ...(isIosPersonalTeamBuild
288 ? [sharingPlugin]
289 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
290 [
291 "expo-notifications",
292 {
293 icon: variant.assets.androidNotificationIcon,
294 color: variant.assets.androidNotificationColor,
295 mode: APP_VARIANT === "development" ? "development" : "production",
296 },
297 ],
298 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
299 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
300 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
301 "expo-web-browser",
302 [
303 "expo-quick-actions",
304 {
305 // Adaptive launcher-shortcut icon; referenced by resource name from
306 // the shortcut items set in src/features/shortcuts.
307 androidIcons: {
308 shortcut_icon: {
309 foregroundImage: variant.assets.androidAdaptiveForeground,
310 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
311 ...(variant.assets.androidAdaptiveBackgroundImage
312 ? { backgroundImage: variant.assets.androidAdaptiveBackgroundImage }
313 : {}),
314 },
315 },
316 },
317 ],
318 [
319 "expo-audio",
320 {
321 microphonePermission: "Allow T3 Code to use your microphone for voice input.",
322 recordAudioAndroid: false,
323 enableBackgroundPlayback: false,
324 enableBackgroundRecording: false,
325 },
326 ],
327 [
328 "expo-camera",
329 {
330 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
331 microphonePermission: false,
332 barcodeScannerEnabled: true,
333 recordAudioAndroid: false,
334 },
335 ],
336 ["expo-image-picker", { photosPermission: false, microphonePermission: false }],
337 [
338 "expo-splash-screen",
339 {
340 image: variant.assets.splashIcon,
341 resizeMode: "contain",
342 backgroundColor: "#ffffff",
343 imageWidth: 220,
344 dark: {
345 image: variant.assets.splashIcon,
346 backgroundColor: "#0a0a0a",
347 },
348 android: {
349 // Android 12+ masks the splash icon to a circle over the central two thirds of
350 // its 288dp canvas, so the iOS export's corners get cut. A full-canvas image of
351 // the composed adaptive layers puts the wordmark in the same frame the launcher
352 // icon uses.
353 image: variant.assets.androidSplashIcon,
354 imageWidth: 288,
355 dark: { image: variant.assets.androidSplashIcon },
356 },
357 },
358 ],
359 [
360 "expo-build-properties",
361 {
362 android: {
363 // Keep the supported floor explicit and covered by native notification tests.
364 minSdkVersion: 24,
365 },
366 ios: {
367 deploymentTarget: "18.0",
368 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
369 extraPods: [
370 { name: "GoogleUtilities", modular_headers: true },
371 { name: "RecaptchaInterop", modular_headers: true },
372 ],
373 },
374 },
375 ],
376 "./plugins/withIosCocoaPodsUuidCache.cjs",
377 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
378 // first, so registering earlier makes this plugin's mods run AFTER
379 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
380 // would delete the asset catalog) and its xcodeproj mod creates the widget
381 // target (which must exist before the compile phase can be attached).
382 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
383 "./plugins/withIosSceneLifecycle.cjs",
384 "./plugins/withAndroidCleartextTraffic.cjs",
385 "./plugins/withAndroidGradleHeap.cjs",
386 "./plugins/withAndroidModernPopupMenu.cjs",
387 "./plugins/withAndroidModernAlertDialog.cjs",
388 "./plugins/withAndroidPredictiveBackCompat.cjs",
389 "./plugins/withAndroidTabletOrientation.cjs",
390 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
391 ],
392 extra: {
393 appVariant: APP_VARIANT,
394 iosPersonalTeamBuild: isIosPersonalTeamBuild,
395 relay: {
396 url: repoEnv.T3CODE_RELAY_URL ?? null,
397 },
398 clerk: {
399 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
400 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
401 },
402 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
403 // under their exact env-var names (not nested), and its config plugin reads
404 // the iOS URL scheme at prebuild to register it in Info.plist.
405 // Unset values must be omitted (not null): the public manifest serializes
406 // null to {}, which is truthy and would defeat Clerk's fallback checks.
407 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
408 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
409 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
410 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
411 observability: {
412 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
413 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
414 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
415 },
416 eas: {
417 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
418 },
419 },
420 owner: "pingdotgg",
421};
422
423export default config;