import { execAsync } from '../../../utils.js';
import { createModuleLogger } from '../../../logger.js';
const logger = createModuleLogger('XcodeCleaner');
/**
 * Handles cleaning Xcode projects (Single Responsibility: Cleaning)
 */
export class XcodeCleaner {
    /**
     * Clean build artifacts for an Xcode project
     */
    async clean(projectPath, isWorkspace, options = {}) {
        const { scheme, configuration = 'Debug' } = options;
        const projectFlag = isWorkspace ? '-workspace' : '-project';
        let command = `xcodebuild ${projectFlag} "${projectPath}"`;
        if (scheme) {
            command += ` -scheme "${scheme}"`;
        }
        command += ` -configuration "${configuration}" clean`;
        logger.debug({ command }, 'Clean command');
        try {
            await execAsync(command);
            logger.info({ projectPath }, 'Clean succeeded');
        }
        catch (error) {
            logger.error({ error: error.message, projectPath }, 'Clean failed');
            throw new Error(`Clean failed: ${error.message}`);
        }
    }
}
//# sourceMappingURL=XcodeCleaner.js.map