or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build-cache.mdconfiguration.mdindex.mdpaths.mdsdk-version.md
tile.json

sdk-version.mddocs/

SDK Version Resolution

Automatic detection and validation of Expo SDK versions from configuration files or installed packages, ensuring compatibility and proper versioning.

Capabilities

SDK Version Detection

Resolve the Expo SDK version for a project from configuration or installed packages.

/**
 * Resolve the Expo SDK Version from input config or installed expo package
 * First checks the provided config, then falls back to package version detection
 * @param projectRoot - Project root directory
 * @param exp - Optional config object with sdkVersion
 * @returns SDK version string (e.g., "51.0.0")
 * @throws ConfigError if expo package not found or invalid
 */
function getExpoSDKVersion(
  projectRoot: string,
  exp?: Pick<ExpoConfig, 'sdkVersion'>
): string;

Usage Examples:

import { getExpoSDKVersion } from "@expo/config";

// Get SDK version from project
const sdkVersion = getExpoSDKVersion("/path/to/expo-project");
// Result: "51.0.0" (from installed expo package or config)

// Use specific config
const configWithSDK = { sdkVersion: "50.0.0" };
const specifiedVersion = getExpoSDKVersion("/path/to/project", configWithSDK);
// Result: "50.0.0" (uses provided version)

// Auto-detect from installed expo package
const autoVersion = getExpoSDKVersion("/path/to/project", {});
// Reads from node_modules/expo/package.json

SDK Version Resolution Logic

The SDK version resolution follows this priority order:

  1. Explicit Configuration: If exp.sdkVersion is provided, use it directly
  2. Package Detection: Read version from installed expo package
  3. Version Normalization: Convert package version to SDK version format

Package Version to SDK Version Mapping

The function converts npm package versions to SDK versions:

  • Package version 51.0.15 → SDK version 51.0.0
  • Package version 50.1.2 → SDK version 50.0.0
  • Package version 49.0.21 → SDK version 49.0.0

The major version number is preserved, while minor and patch are normalized to .0.0.

Error Handling

SDK version resolution may fail with specific error conditions:

// Thrown when expo package is not installed
throw new ConfigError(
  "Cannot determine the project's Expo SDK version because the module `expo` is not installed. Install it with `npm install expo` and try again.",
  'MODULE_NOT_FOUND'
);

// Thrown when expo package.json is invalid
throw new ConfigError(
  "Cannot determine the project's Expo SDK version because the module `expo` has an invalid package.json (missing `version` field). Try reinstalling node modules and trying again.",
  'MODULE_NOT_FOUND'
);

Error Handling Examples:

import { getExpoSDKVersion, ConfigError } from "@expo/config";

try {
  const sdkVersion = getExpoSDKVersion("/path/to/project");
  console.log("SDK Version:", sdkVersion);
} catch (error) {
  if (error instanceof ConfigError) {
    switch (error.code) {
      case 'MODULE_NOT_FOUND':
        console.log("Please install expo: npm install expo");
        break;
      default:
        console.log("Configuration error:", error.message);
    }
  }
}

Integration with Configuration

SDK version resolution is automatically integrated into the main configuration system:

import { getConfig } from "@expo/config";

// SDK version is automatically resolved and included
const config = getConfig("/path/to/project");
console.log("Auto-resolved SDK:", config.exp.sdkVersion);

// Skip SDK version validation for incomplete projects
const configNoSDK = getConfig("/path/to/project", {
  skipSDKVersionRequirement: true
});
// Won't throw if expo package missing

SDK Version Types

// Part of ExpoConfig interface
interface ExpoConfig {
  /** Expo SDK version (e.g., "51.0.0", "UNVERSIONED") */
  sdkVersion?: string;
  // ... other config properties
}

// Error codes related to SDK version resolution
type ConfigErrorCode = 
  | 'MODULE_NOT_FOUND'  // expo package not found
  | 'INVALID_CONFIG'    // invalid package.json
  // ... other error codes

Version Compatibility

Different SDK versions may have different configuration requirements:

  • SDK 37+: Defaults to 'bare' workflow detection
  • SDK <37: Defaults to 'managed' workflow for backward compatibility
  • UNVERSIONED: Used for development versions and custom builds

The SDK version affects:

  • Default workflow detection (managed vs bare)
  • Available configuration options
  • Plugin compatibility
  • Build target selection