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