in appcenter-link-scripts/src/ios/AppCenterConfig.js [40:86]
function addConfigToProject(file) {
return new Promise(((resolve, reject) => {
debug(`Trying to add ${file} to XCode project`);
const globString = 'ios/*.xcodeproj/project.pbxproj';
const projectPaths = glob.sync(globString, { ignore: 'node_modules/**' });
if (projectPaths.length !== 1) {
reject(new Error(`
Could not locate the xcode project to add AppCenter-Config.plist file to.
Looked in paths -
${JSON.stringify(projectPaths)}`));
return;
}
const projectPath = projectPaths[0];
debug(`Adding ${file} to ${projectPath}`);
const project = xcode.project(projectPath);
project.parse((err) => {
if (err) {
reject(err);
return;
}
try {
const relativeFilePath = path.relative(path.resolve(projectPath, '../..'), file);
const plistPbxFile = project.addFile(relativeFilePath, project.getFirstProject().firstProject.mainGroup);
if (plistPbxFile === null) {
debug(`Looks like ${file} was already added to ${projectPath}`);
resolve(file);
return;
}
plistPbxFile.uuid = project.generateUuid();
plistPbxFile.target = project.getFirstTarget().uuid;
project.addToPbxBuildFileSection(plistPbxFile);
project.addToPbxResourcesBuildPhase(plistPbxFile);
fs.writeFileSync(projectPath, project.writeSync());
debug(`Added ${file} to ${projectPath}`);
} catch (e) {
reject(e);
}
resolve(file);
});
}));
}