@@ -58368,6 +58368,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
5836858368exports.log = log;
5836958369exports.DeepEqual = DeepEqual;
5837058370exports.matchRegexPattern = matchRegexPattern;
58371+ exports.getPathsWithGlob = getPathsWithGlob;
5837158372exports.getFirstPathWithGlob = getFirstPathWithGlob;
5837258373exports.getFileContents = getFileContents;
5837358374const core = __nccwpck_require__(2186);
@@ -58439,6 +58440,14 @@ function matchRegexPattern(string, pattern, group) {
5843958440 }
5844058441 return group ? (_a = match.groups) === null || _a === void 0 ? void 0 : _a[group] : match[1];
5844158442}
58443+ async function getPathsWithGlob(globPattern) {
58444+ const globber = await glob.create(globPattern);
58445+ const files = await globber.glob();
58446+ if (files.length === 0) {
58447+ throw new Error(`No file found at: ${globPattern}`);
58448+ }
58449+ return files;
58450+ }
5844258451async function getFirstPathWithGlob(globPattern) {
5844358452 const globber = await glob.create(globPattern);
5844458453 const files = await globber.glob();
@@ -58596,10 +58605,9 @@ async function GetProjectDetails(credential, xcodeVersion) {
5859658605 const platform = await getSupportedPlatform(projectPath);
5859758606 core.info(`Platform: ${platform}`);
5859858607 if (platform !== 'macOS') {
58599- const platformInstalled = await isSdkPlatformInstalled(platform);
5860058608 const platformSdkVersion = await getPlatformSdkVersion(buildSettings);
58601- const hasSimulators = await checkSimulatorsAvailable (platform);
58602- if (!platformInstalled || !hasSimulators ) {
58609+ const platformSdk = await getSdkInfo (platform, platformSdkVersion );
58610+ if (!platformSdk ) {
5860358611 await downloadPlatformAndSdk(platform, platformSdkVersion);
5860458612 }
5860558613 }
@@ -58754,27 +58762,6 @@ async function GetProjectDetails(credential, xcodeVersion) {
5875458762 infoPlistContent = await (0, utilities_1.getFileContents)(infoPlistPath);
5875558763 return projectRef;
5875658764}
58757- async function checkSimulatorsAvailable(platform) {
58758- const destinationArgs = ['simctl', 'list', 'devices', '--json'];
58759- if (!core.isDebug()) {
58760- core.info(`[command]${xcrun} ${destinationArgs.join(' ')}`);
58761- }
58762- let output = '';
58763- await (0, exec_1.exec)(xcrun, destinationArgs, {
58764- listeners: {
58765- stdout: (data) => {
58766- output += data.toString();
58767- }
58768- },
58769- silent: !core.isDebug()
58770- });
58771- const response = JSON.parse(output);
58772- const devices = response.devices;
58773- const platformDevices = Object.keys(devices)
58774- .filter(key => key.toLowerCase().includes(platform.toLowerCase()))
58775- .flatMap(key => devices[key]);
58776- return platformDevices.length > 0;
58777- }
5877858765async function getSupportedPlatform(projectPath) {
5877958766 const projectFilePath = `${projectPath}/project.pbxproj`;
5878058767 core.debug(`.pbxproj file path: ${projectFilePath}`);
@@ -58833,30 +58820,23 @@ async function getPlatformSdkVersion(buildSettingsOutput) {
5883358820 core.info(`Platform SDK version: ${platformSdkVersion}`);
5883458821 return platformSdkVersion;
5883558822}
58836- async function isSdkPlatformInstalled(platform) {
58837- const output = await execXcodeBuild(['-showsdks']);
58838- core.info(`SDKs available:\n${output}`);
58839- const sdkMap = {
58840- 'iOS': 'iphoneos',
58841- 'tvOS': 'appletvos',
58842- 'watchOS': 'watchos',
58843- 'visionOS': 'xros',
58844- };
58845- const sdkString = sdkMap[platform];
58846- if (!sdkString) {
58847- return false;
58848- }
58849- return output.includes(`-sdk ${sdkString}`);
58823+ async function getSdkInfo(platform, version) {
58824+ const output = await execXcodeBuild(['-showsdks', '-json']);
58825+ core.info(`Installed SDKs:\n${output}`);
58826+ const installedSdks = JSON.parse(output);
58827+ const sdk = installedSdks.find(sdk => sdk.platform.toLowerCase() === platform.toLowerCase() && sdk.sdkVersion.toString() === version);
58828+ core.info(`Found SDK:\n${sdk ? JSON.stringify(sdk) : ''}`);
58829+ return sdk || null;
5885058830}
5885158831async function downloadPlatformAndSdk(platform, version) {
5885258832 const downloadDir = `${process.env.RUNNER_TEMP}/xcodes/${platform}-${version}`;
58853- await execXcodeBuild(['-downloadPlatform', platform, '-buildVersion', version, '-exportPath', downloadDir]);
58854- const dmgPath = await (0, utilities_1.getFirstPathWithGlob)(`${downloadDir}/**/*.dmg`);
58855- if (!dmgPath) {
58856- throw new Error(`Failed to find downloaded .dmg for platform ${platform} version ${version}`);
58833+ await execXcodeBuild(['-downloadPlatform', platform, '-exportPath', downloadDir, '-buildVersion', version]);
58834+ const dmgPaths = await (0, utilities_1.getPathsWithGlob)(`${downloadDir}/**/*.dmg`);
58835+ core.info(`Downloaded DMG paths:\n${dmgPaths.join('\n')}`);
58836+ for (const dmgPath of dmgPaths) {
58837+ await fs.promises.access(dmgPath, fs.constants.R_OK);
58838+ await execXcodeBuild(['-importPlatform', dmgPath]);
5885758839 }
58858- await fs.promises.access(dmgPath, fs.constants.X_OK);
58859- await execXcodeBuild(['-importPlatform', dmgPath]);
5886058840}
5886158841async function getProjectScheme(projectPath) {
5886258842 let scheme = core.getInput('scheme');
0 commit comments