run method
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
- Platform Check: Validates
Platform.isMacOSbefore proceeding - Argument Processing: Parses iOS-specific build arguments and global settings
- Environment Setup: Validates Xcode installation and iOS SDK availability
- Build Configuration: Processes signing, provisioning, and export settings
- Xcode Build: Executes build process with specified parameters
- 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 macOS1- Platform validation failed (non-macOS system)>1- Build failed with specific error codenull- 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();
}