xdl
Version:
The Expo Development Library
61 lines (59 loc) • 1.8 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getDeveloperDiskImagePath = getDeveloperDiskImagePath;
exports.getXCodePath = getXCodePath;
function _fs() {
const data = _interopRequireDefault(require("fs"));
_fs = function () {
return data;
};
return data;
}
function _process() {
const data = require("../../utils/process");
_process = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2021 Expo, Inc.
* Copyright (c) 2018 Drifty Co.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
async function getXCodePath() {
try {
const {
stdout
} = await (0, _process().execFile)('xcode-select', ['-p'], {
encoding: 'utf8'
});
if (stdout) {
return stdout.trim();
}
} catch {
// ignore
}
throw new Error('Unable to get Xcode location. Is Xcode installed?');
}
async function getDeveloperDiskImagePath(version) {
const xCodePath = await getXCodePath();
const versionDirs = await _fs().default.promises.readdir(`${xCodePath}/Platforms/iPhoneOS.platform/DeviceSupport/`);
const versionPrefix = version.match(/\d+\.\d+/);
if (versionPrefix === null) {
throw new Error(`Invalid iOS version: ${version}`);
}
// Can look like "11.2 (15C107)"
for (const dir of versionDirs) {
if (dir.includes(versionPrefix[0])) {
return `${xCodePath}/Platforms/iPhoneOS.platform/DeviceSupport/${dir}/DeveloperDiskImage.dmg`;
}
}
throw new Error(`Unable to find Developer Disk Image path for SDK ${version}. Do you have the right version of Xcode?`);
}
//# sourceMappingURL=xcode.js.map
;