run method

  1. @override
Future? run()
override

Executes the iOS application build process with platform validation.

This method orchestrates the complete iOS build workflow with mandatory macOS platform checking and comprehensive build execution:

Platform Validation

  • macOS Requirement: Enforces macOS-only execution due to iOS development constraints
  • Error Handling: Returns exit code 1 if executed on non-macOS platforms
  • User Feedback: Provides clear error messaging for platform incompatibility

Build Execution Flow

  1. Platform Check: Validates Platform.isMacOS before proceeding
  2. Argument Processing: Parses iOS-specific build arguments and global settings
  3. Environment Setup: Validates Xcode installation and iOS SDK availability
  4. Build Configuration: Processes signing, provisioning, and export settings
  5. Xcode Build: Executes build process with specified parameters
  6. Archive & Export: Creates xcarchive and exports IPA with chosen method

Parameters

  • Uses argResults - iOS-specific argument results from CLI parsing
  • Uses globalResults - Global configuration and environment variables

Returns

Returns a Future that completes with:

  • 0 - Build completed successfully on macOS
  • 1 - Platform validation failed (non-macOS system)
  • >1 - Build failed with specific error code
  • null - Build process encountered unexpected termination

Error Scenarios

Platform Errors:

  • Non-macOS execution returns immediately with code 1
  • Clear error message logged for user guidance

Build Errors:

  • Missing or invalid Xcode installation
  • Incorrect signing configuration or missing certificates
  • Invalid provisioning profiles or entitlements
  • Insufficient disk space for build artifacts
  • Network issues during dependency resolution

Example Usage

final command = Command();
final result = await command.run();

switch (result) {
  case 0:
    logger.logInfo('iOS build completed successfully');
    break;
  case 1:
    logger.logError('iOS builds require macOS platform');
    break;
  default:
    logger.logError('Build failed with exit code: $result');
}

macOS Validation

The platform check ensures iOS development requirements are met:

  • Xcode development environment availability
  • iOS SDK and build tools access
  • Code signing and provisioning capabilities
  • Simulator and device deployment support

Implementation

@override
Future? run() async {
  // Enforce macOS platform requirement for iOS development
  if (!Platform.isMacOS) {
    logger.logError("This command is only supported on macOS.");
    return 1;
  }

  // Execute iOS build process with validated environment
  return Arguments.fromArgResults(argResults!, globalResults).build();
}