Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): xcode parseSync #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

**5.1.0-dev-1.0**
* Fix iOS xcodeProject
* every plugin can change project.pbxproj file,
* async operations can be exist with random queue, (promise/callback and etc.)
* every part with xcode.project should be existed only in one task (micro)

**v5.1.0**
* Replace requireCordovaModule() with require() due to breaking changes in [email protected]. Resolves [#152](https:/dpa99c/cordova-custom-config/issues/152).

Expand Down
64 changes: 32 additions & 32 deletions hooks/applyCustomConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,38 +774,38 @@ var applyCustomConfig = (function(){
*/
function updateIosPbxProj(xcodeProjectPath, configItems) {
var xcodeProject = xcode.project(xcodeProjectPath);
xcodeProject.parse(function(err){
if(err){
// shell is undefined if android platform has been removed and added with a new package id but ios stayed the same.
var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(err);
if(typeof shell !== "undefined" && shell !== null){
shell.echo(msg);
} else{
logger.error(msg + ' - Maybe you forgot to remove/add the ios platform?');
}
}else{
_.each(configItems, function (item) {
switch(item.type){
case "XCBuildConfiguration":
var buildConfig = xcodeProject.pbxXCBuildConfigurationSection();
var replaced = updateXCBuildConfiguration(item, buildConfig, "replace");
if(!replaced){
updateXCBuildConfiguration(item, buildConfig, "add");
}
break;
case "xcodefunc":
if (typeof (xcodeProject[item.func]) === "function") {
xcodeProject[item.func].apply(xcodeProject, item.args);
}
break;
}
});
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
logger.verbose("Wrote file " + xcodeProjectPath);
}
asyncOperationsRemaining--;
checkComplete();
});
try {
xcodeProject.parseSync();
} catch (err) {
// shell is undefined if android platform has been removed and added with a new package id but ios stayed the same.
var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(err);
if(typeof shell !== "undefined" && shell !== null){
shell.echo(msg);
} else{
logger.error(msg + ' - Maybe you forgot to remove/add the ios platform?');
}
}
_.each(configItems, function (item) {
switch(item.type){
case "XCBuildConfiguration":
var buildConfig = xcodeProject.pbxXCBuildConfigurationSection();
var replaced = updateXCBuildConfiguration(item, buildConfig, "replace");
if(!replaced){
updateXCBuildConfiguration(item, buildConfig, "add");
}
break;
case "xcodefunc":
if (typeof (xcodeProject[item.func]) === "function") {
xcodeProject[item.func].apply(xcodeProject, item.args);
}
break;
}
});
fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8');
logger.verbose("Wrote file " + xcodeProjectPath);

asyncOperationsRemaining--;
checkComplete();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.1.0",
"version": "5.1.0-dev-1.0",
"name": "cordova-custom-config",
"cordova_name": "cordova-custom-config",
"description": "Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml.",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-custom-config"
version="5.1.0">
version="5.1.0-dev-1.0">

<name>cordova-custom-config</name>
<description>Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml</description>
Expand Down