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: "0.1.0",
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 bundleIdentifier: iosBundleIdentifier,
185 // Pin code signing to the T3 Tools team so non-interactive `expo run:ios`
186 // does not fall back to a personal team (which cannot sign app groups,
187 // Sign in with Apple, or push notification entitlements).
188 appleTeamId: "ARK85ZXQ4Z",
189 associatedDomains: [
190 `applinks:${variant.relyingParty}`,
191 `webcredentials:${variant.relyingParty}`,
192 ],
193 infoPlist: {
194 NSAppTransportSecurity: {
195 NSAllowsArbitraryLoads: true,
196 },
197 NSLocalNetworkUsageDescription:
198 "Allow T3 Code to connect to T3 Code servers on your local network or tailnet.",
199 ITSAppUsesNonExemptEncryption: false,
200 },
201 },
202 android: {
203 icon: variant.assets.appIcon,
204 package: variant.androidPackage,
205 adaptiveIcon: {
206 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
207 foregroundImage: variant.assets.androidAdaptiveForeground,
208 monochromeImage: variant.assets.androidMonochromeIcon,
209 },
210 // Opts into OnBackInvokedCallback-based back dispatch (Android 13+).
211 // JS back handling survives it via react-native's Android 16 shim plus
212 // withAndroidPredictiveBackCompat on Android 13-15.
213 predictiveBackGestureEnabled: true,
214 },
215 web: {
216 favicon: variant.assets.appIcon,
217 },
218 plugins: [
219 "expo-asset",
220 [
221 "expo-font",
222 {
223 ios: {
224 fonts: [dmSansFonts.regular, dmSansFonts.medium, dmSansFonts.bold],
225 },
226 android: {
227 fonts: [
228 {
229 fontFamily: "DMSans-Regular",
230 fontDefinitions: [{ path: dmSansFonts.regular, weight: 400 }],
231 },
232 {
233 fontFamily: "DMSans-Medium",
234 fontDefinitions: [{ path: dmSansFonts.medium, weight: 500 }],
235 },
236 {
237 fontFamily: "DMSans-Bold",
238 fontDefinitions: [{ path: dmSansFonts.bold, weight: 700 }],
239 },
240 ],
241 },
242 },
243 ],
244 "expo-secure-store",
245 "expo-sqlite",
246 ...(isIosPersonalTeamBuild
247 ? [sharingPlugin]
248 : ["./plugins/withShareExtensionDisplayName.cjs", sharingPlugin]),
249 [
250 "expo-notifications",
251 {
252 icon: variant.assets.androidNotificationIcon,
253 color: variant.assets.androidNotificationColor,
254 mode: APP_VARIANT === "development" ? "development" : "production",
255 },
256 ],
257 // appleSignIn must be gated here: withoutIosPersonalTeamCapabilities.cjs runs before
258 // plugins earlier in this array, so it cannot strip the entitlement Clerk would add.
259 ["@clerk/expo", { theme: "./clerk-theme.json", appleSignIn: !isIosPersonalTeamBuild }],
260 "expo-web-browser",
261 [
262 "expo-quick-actions",
263 {
264 // Adaptive launcher-shortcut icon; referenced by resource name from
265 // the shortcut items set in src/features/shortcuts.
266 androidIcons: {
267 shortcut_icon: {
268 foregroundImage: variant.assets.androidAdaptiveForeground,
269 backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
270 },
271 },
272 },
273 ],
274 [
275 "expo-camera",
276 {
277 cameraPermission: "Allow T3 Code to access your camera so you can scan pairing QR codes.",
278 barcodeScannerEnabled: true,
279 recordAudioAndroid: false,
280 },
281 ],
282 [
283 "expo-splash-screen",
284 {
285 image: variant.assets.splashIcon,
286 resizeMode: "contain",
287 backgroundColor: "#ffffff",
288 imageWidth: 220,
289 dark: {
290 image: variant.assets.splashIcon,
291 backgroundColor: "#0a0a0a",
292 },
293 },
294 ],
295 [
296 "expo-build-properties",
297 {
298 ios: {
299 deploymentTarget: "18.0",
300 // AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
301 extraPods: [
302 { name: "GoogleUtilities", modular_headers: true },
303 { name: "RecaptchaInterop", modular_headers: true },
304 ],
305 },
306 },
307 ],
308 "./plugins/withIosCocoaPodsUuidCache.cjs",
309 // Must be listed BEFORE expo-widgets: same-type mods run last-registered-
310 // first, so registering earlier makes this plugin's mods run AFTER
311 // expo-widgets' — its dangerous mod wipes ios/ExpoWidgetsTarget/ (which
312 // would delete the asset catalog) and its xcodeproj mod creates the widget
313 // target (which must exist before the compile phase can be attached).
314 ...(!isIosPersonalTeamBuild ? ["./plugins/withWidgetLogoAsset.cjs", widgetsPlugin] : []),
315 "./plugins/withIosSceneLifecycle.cjs",
316 "./plugins/withAndroidCleartextTraffic.cjs",
317 "./plugins/withAndroidGradleHeap.cjs",
318 "./plugins/withAndroidModernPopupMenu.cjs",
319 "./plugins/withAndroidModernAlertDialog.cjs",
320 "./plugins/withAndroidPredictiveBackCompat.cjs",
321 ...(isIosPersonalTeamBuild ? ["./plugins/withoutIosPersonalTeamCapabilities.cjs"] : []),
322 ],
323 extra: {
324 appVariant: APP_VARIANT,
325 iosPersonalTeamBuild: isIosPersonalTeamBuild,
326 relay: {
327 url: repoEnv.T3CODE_RELAY_URL ?? null,
328 },
329 clerk: {
330 publishableKey: repoEnv.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY ?? null,
331 jwtTemplate: repoEnv.EXPO_PUBLIC_CLERK_JWT_TEMPLATE ?? null,
332 },
333 // Native Google sign-in credentials. @clerk/expo reads these from `extra`
334 // under their exact env-var names (not nested), and its config plugin reads
335 // the iOS URL scheme at prebuild to register it in Info.plist.
336 // Unset values must be omitted (not null): the public manifest serializes
337 // null to {}, which is truthy and would defeat Clerk's fallback checks.
338 EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_WEB_CLIENT_ID,
339 EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_CLIENT_ID,
340 EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_ANDROID_CLIENT_ID,
341 EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME: repoEnv.EXPO_PUBLIC_CLERK_GOOGLE_IOS_URL_SCHEME,
342 observability: {
343 tracesUrl: repoEnv.EXPO_PUBLIC_OTLP_TRACES_URL ?? "https://api.axiom.co/v1/traces",
344 tracesDataset: repoEnv.EXPO_PUBLIC_OTLP_TRACES_DATASET ?? null,
345 tracesToken: repoEnv.EXPO_PUBLIC_OTLP_TRACES_TOKEN ?? null,
346 },
347 eas: {
348 projectId: "d763fcb8-d37c-41ea-a773-b54a0ab4a454",
349 },
350 },
351 owner: "pingdotgg",
352};
353
354export default config;