CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-expo-modules-autolinking

Scripts that autolink Expo modules.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

platform-support.mddocs/

Platform Support

Platform-specific implementations for iOS, Android, macOS, tvOS, and devtools with native build system integration and cross-platform module resolution.

Capabilities

Platform Implementation Loading

Dynamic loading of platform-specific linking implementations based on target platform.

/**
 * Get platform-specific linking implementation
 * @param platform - Target platform identifier
 * @returns Platform-specific implementation module
 * @throws Error if platform is not supported
 */
function getLinkingImplementationForPlatform(
  platform: SupportedPlatform
): PlatformImplementation;

// Overloaded signatures for type safety
function getLinkingImplementationForPlatform(
  platform: 'ios' | 'macos' | 'tvos' | 'apple'
): ApplePlatformImplementation;

function getLinkingImplementationForPlatform(
  platform: 'android'
): AndroidPlatformImplementation;

function getLinkingImplementationForPlatform(
  platform: 'devtools'
): DevToolsPlatformImplementation;

Usage Examples:

import { getLinkingImplementationForPlatform } from "expo-modules-autolinking";

// Get iOS implementation
const iosImpl = getLinkingImplementationForPlatform("ios");

// Get Android implementation
const androidImpl = getLinkingImplementationForPlatform("android");

// Get DevTools implementation
const devtoolsImpl = getLinkingImplementationForPlatform("devtools");

// Error handling for unsupported platforms
try {
  const unknownImpl = getLinkingImplementationForPlatform("unknown-platform");
} catch (error) {
  console.error("Platform not supported:", error.message);
}

Apple Platforms (iOS, macOS, tvOS)

iOS Module Descriptor

iOS-specific module descriptor with Pod specifications and Swift module configuration.

interface ModuleDescriptorIos extends CommonNativeModuleDescriptor {
  /** Swift native module class names */
  modules: string[];
  /** Pod specifications with directory information */
  pods: ModuleIosPodspecInfo[];
  /** Platform-specific flags and configuration */
  flags: Record<string, any> | undefined;
  /** Swift product module names for imports */
  swiftModuleNames: string[];
  /** AppDelegate lifecycle event subscribers */
  appDelegateSubscribers: string[];
  /** React delegate handler implementations */
  reactDelegateHandlers: string[];
  /** Whether module is debug-only */
  debugOnly: boolean;
}

interface ModuleIosPodspecInfo {
  /** Pod name in CocoaPods */
  podName: string;
  /** Directory containing podspec file */
  podspecDir: string;
}

Apple Platform Configuration

Configuration options specific to Apple platforms (iOS, macOS, tvOS).

interface RawModuleConfigApple {
  /** Swift native module class names */
  modules?: string[];
  /** AppDelegate lifecycle event subscriber class names */
  appDelegateSubscribers?: string[];
  /** React delegate handler class names */
  reactDelegateHandlers?: string[];
  /** Podspec relative path (string or array for multiple) */
  podspecPath?: string | string[];
  /** Swift product module name (string or array for multiple) */
  swiftModuleName?: string | string[];
  /** Whether module is debug-only (default: false) */
  debugOnly?: boolean;
}

interface AppleCodeSignEntitlements {
  /** App Groups entitlements for shared data access */
  appGroups?: string[];
}

Usage Examples:

// iOS module configuration
const iosModuleConfig: RawModuleConfigApple = {
  modules: ["MyExpoModule", "MyOtherModule"],
  appDelegateSubscribers: ["MyAppDelegateSubscriber"],
  reactDelegateHandlers: ["MyReactDelegateHandler"],
  podspecPath: ["MyModule.podspec", "MyOtherModule.podspec"],
  swiftModuleName: ["MyModule", "MyOtherModule"],
  debugOnly: false
};

// Debug-only module for development
const debugModuleConfig: RawModuleConfigApple = {
  modules: ["DebugUtilities"],
  podspecPath: "DebugUtilities.podspec",
  debugOnly: true
};

Android Platform

Android Module Descriptor

Android-specific module descriptor with Gradle project and plugin information.

interface ModuleDescriptorAndroid extends CommonNativeModuleDescriptor {
  /** Gradle project configurations */
  projects?: ModuleAndroidProjectInfo[];
  /** Gradle plugin configurations */
  plugins?: ModuleAndroidPluginInfo[];
}

interface ModuleAndroidProjectInfo {
  /** Gradle project name */
  name: string;
  /** Source directory containing build.gradle */
  sourceDir: string;
  /** Android native module names */
  modules: string[];
  /** Maven publication information */
  publication?: AndroidPublication;
  /** AAR project descriptors */
  aarProjects?: AndroidGradleAarProjectDescriptor[];
  /** Script to determine publication usage */
  shouldUsePublicationScriptPath?: string;
}

interface ModuleAndroidPluginInfo {
  /** Gradle plugin ID */
  id: string;
  /** Source directory for plugin */
  sourceDir: string;
}

Android Configuration

Comprehensive Android platform configuration with Gradle integration.

interface RawAndroidConfig {
  /** Gradle project configurations */
  projects?: Array<{
    name: string;
    path: string;
    modules?: string[];
    publication?: AndroidPublication;
    gradleAarProjects?: AndroidGradleAarProjectDescriptor[];
    shouldUsePublicationScriptPath?: string;
  }>;
  /** Gradle plugin descriptors */
  gradlePlugins?: AndroidGradlePluginDescriptor[];
}

interface AndroidGradlePluginDescriptor {
  /** Gradle plugin ID */
  id: string;
  /** Artifact group */
  group: string;
  /** Relative path to gradle plugin directory */
  sourceDir: string;
  /** Whether to apply to root project (default: true) */
  applyToRootProject?: boolean;
}

interface AndroidGradleAarProjectDescriptor {
  /** Gradle project name */
  name: string;
  /** Path to AAR file */
  aarFilePath: string;
}

Android Maven Repository

Maven repository configuration with authentication support.

interface AndroidMavenRepository {
  /** Maven repository URL */
  url: string;
  /** Repository access credentials */
  credentials?: AndroidMavenRepositoryCredentials;
  /** Authentication scheme */
  authentication?: 'basic' | 'digest' | 'header';
}

type AndroidMavenRepositoryCredentials =
  | AndroidMavenRepositoryPasswordCredentials
  | AndroidMavenRepositoryHttpHeaderCredentials
  | AndroidMavenRepositoryAWSCredentials;

interface AndroidMavenRepositoryPasswordCredentials {
  username: string;
  password: string;
}

interface AndroidMavenRepositoryHttpHeaderCredentials {
  name: string;
  value: string;
}

interface AndroidMavenRepositoryAWSCredentials {
  accessKey: string;
  secretKey: string;
  sessionToken?: string;
}

Usage Examples:

// Android module configuration
const androidConfig: RawAndroidConfig = {
  projects: [
    {
      name: "my-expo-module",
      path: "./android",
      modules: ["MyExpoModule", "MyOtherModule"],
      publication: {
        id: "my-expo-module",
        group: "com.mycompany",
        version: "1.0.0",
        repository: "https://maven.mycompany.com/releases"
      }
    }
  ],
  gradlePlugins: [
    {
      id: "com.mycompany.expo-plugin",
      group: "com.mycompany",
      sourceDir: "./gradle-plugin",
      applyToRootProject: true
    }
  ]
};

// Maven repository with authentication
const mavenRepo: AndroidMavenRepository = {
  url: "https://private-maven.company.com/releases",
  credentials: {
    username: "maven-user",
    password: "maven-password"
  },
  authentication: "basic"
};

DevTools Platform

DevTools Module Descriptor

DevTools-specific module descriptor for development tool integrations.

interface ModuleDescriptorDevTools {
  /** Package name */
  packageName: string;
  /** Package root directory */
  packageRoot: string;
  /** Web resource root directory */
  webpageRoot: string;
}

DevTools Configuration

Configuration for development tools integration.

interface DevToolsConfig {
  /** Web resource root directory for CLI DevTools */
  webpageRoot: string;
}

Usage Examples:

// DevTools module configuration
const devtoolsConfig: DevToolsConfig = {
  webpageRoot: "./web-resources"
};

// DevTools module descriptor
const devtoolsModule: ModuleDescriptorDevTools = {
  packageName: "my-devtools-extension",
  packageRoot: "/path/to/package",
  webpageRoot: "/path/to/web-resources"
};

Cross-Platform Types

Common Module Descriptor

Base interface shared across all platform-specific descriptors.

interface CommonNativeModuleDescriptor {
  /** Package name identifier */
  packageName: string;
  /** Core features required by this module */
  coreFeatures?: string[];
}

type ModuleDescriptor =
  | ModuleDescriptorAndroid
  | ModuleDescriptorIos
  | ModuleDescriptorDevTools;

Supported Platforms

type SupportedPlatform =
  | 'apple'      // Generic Apple platform
  | 'ios'        // iOS specific
  | 'android'    // Android specific
  | 'web'        // Web platform
  | 'macos'      // macOS specific
  | 'tvos'       // tvOS specific
  | 'devtools'   // Development tools
  | (string & {}); // Allow custom platform strings

Extra Dependencies

Platform-specific extra dependencies for build systems.

type ExtraDependencies = AndroidMavenRepository[] | ApplePod[];

interface ApplePod {
  name: string;
  version?: string;
  configurations?: string[];
  modular_headers?: boolean;
  source?: string;
  path?: string;
  podspec?: string;
  testspecs?: string[];
  git?: string;
  branch?: string;
  tag?: string;
  commit?: string;
}

Platform-Specific Integration

iOS/Apple Integration

  • CocoaPods Integration: Automatic Podfile generation and dependency resolution
  • Swift Package Manager: Support for SPM-based modules
  • Xcode Integration: Project configuration and build settings management
  • App Delegate Integration: Automatic registration of lifecycle subscribers
  • React Delegate Integration: Seamless React Native integration

Android Integration

  • Gradle Integration: Automatic build.gradle configuration and dependency resolution
  • AAR Support: Prebuilt AAR project integration
  • Maven Integration: Private and public Maven repository support
  • Plugin System: Gradle plugin automatic application and configuration
  • ProGuard/R8 Integration: Obfuscation and optimization compatibility

DevTools Integration

  • CLI Integration: Development server and tool integration
  • Web Resource Serving: Static web resource hosting for development tools
  • Hot Reload Support: Development-time module reloading
  • Debug Integration: Debugging tool and inspector integration

Platform Detection Example:

import { getLinkingImplementationForPlatform, SupportedPlatform } from "expo-modules-autolinking";

function configureForPlatform(platform: SupportedPlatform) {
  const impl = getLinkingImplementationForPlatform(platform);
  
  switch (platform) {
    case 'ios':
    case 'macos':
    case 'tvos':
    case 'apple':
      return configureApplePlatform(impl);
    case 'android':
      return configureAndroidPlatform(impl);
    case 'devtools':
      return configureDevToolsPlatform(impl);
    default:
      throw new Error(`Unsupported platform: ${platform}`);
  }
}

docs

cli-commands.md

dependency-management.md

index.md

module-discovery.md

platform-support.md

react-native-integration.md

tile.json