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