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