fix(settings): read the build number from expo-application
The row said '1.0.0 (dev)' on a build stamped 2026081502. Constants.nativeBuildVersion is deprecated in SDK 57 and returns nothing — not an error, not a throw, just undefined, so the fallback fired and the screen reported the opposite of the truth with complete confidence. A deprecation that quietly returns undefined is the worst kind: everything looks like it is working. expo-application is the documented replacement and reads the value from the bundle at runtime, which is the number OAS stamps before signing. Also removes the last use of expo-constants here, and with it the '1.0.0' half — the marketing string that has never changed and cannot tell two builds apart. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import type { ImageSourcePropType } from 'react-native';
|
||||
import { View, Text, Pressable, ScrollView, Image } from 'react-native';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import Constants from 'expo-constants';
|
||||
import * as Application from 'expo-application';
|
||||
|
||||
import { useTheme } from '../ui/useTheme';
|
||||
import { Card } from '../ui/Card';
|
||||
@@ -91,7 +91,15 @@ export type SettingsScreenProps = {
|
||||
* that is not exactly ten digits is shown verbatim instead of being mangled into a fake date.
|
||||
*/
|
||||
function buildLabel(): string {
|
||||
const raw = Constants.nativeBuildVersion ?? '';
|
||||
/*
|
||||
`expo-application`, NOT `Constants.nativeBuildVersion`.
|
||||
|
||||
That property is deprecated in SDK 57 and returns nothing — which is not an error, just an empty
|
||||
string, so the row rendered a confident "1.0.0 (dev)" on a build that had been stamped 2026081502.
|
||||
A deprecation that returns undefined rather than throwing is the worst kind: the screen looked like
|
||||
it was working and was reporting the opposite of the truth.
|
||||
*/
|
||||
const raw = Application.nativeBuildVersion ?? '';
|
||||
if (!/^\d{10}$/.test(raw)) return raw ? `dev (${raw})` : 'dev';
|
||||
return `${raw.slice(0, 4)}.${raw.slice(4, 6)}.${raw.slice(6, 8)}.${raw.slice(8)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user