You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "9t96 (via GitHub)" <gi...@apache.org> on 2023/07/03 18:50:39 UTC
[GitHub] [cordova-node-xcode] 9t96 opened a new issue, #138: Overwrite an existe build phase script
9t96 opened a new issue, #138:
URL: https://github.com/apache/cordova-node-xcode/issues/138
As the title says. Is there a function or a workaround to overwrite an existant build phase script?
As far as is know is not posible with this package to remove an existant build phase, so as an alternative i want to overwrite some of the script for already added build phases.
Thanks in advance :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-node-xcode] breautek commented on issue #138: Overwrite an existent build phase script
Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on issue #138:
URL: https://github.com/apache/cordova-node-xcode/issues/138#issuecomment-1620167615
After parsing the pbx file, the entire file is represented as a large JSON structure.
So if you want to modify/manipulate it, you can traverse the data structure to find the build phase you're looking for. Once you have the build phase object, should be able to reference the id for other API calls.
If you want to simply remove it, it does seem there is no `delete` counterpart of https://github.com/apache/cordova-node-xcode/blob/659a4e7cfe945a13b3968c0d8c5439683f6d0932/lib/pbxProject.js#L872
But likewise, as a stopgap, the data structure could be directly manipulated, but you'll have to clean all the references of the build phase from the data structure. I think you can reference the `addBuildPhase` API to see where these references occurs. I think a PR would be welcome for a `deleteBuildPhase` API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-node-xcode] 9t96 commented on issue #138: Overwrite an existent build phase script
Posted by "9t96 (via GitHub)" <gi...@apache.org>.
9t96 commented on issue #138:
URL: https://github.com/apache/cordova-node-xcode/issues/138#issuecomment-1620330400
Well, this is how i solved. I delete the build phase with unwanted script and then add new build phase with wanted script. I think could be improved but is doing the job for now..
``` var xcode = require('xcode');
var fs = require('fs');
const xcodeProjPath = 'platforms/ios/T-Play.xcodeproj';
module.exports = function (ctx) {
console.log("Build phase sentry");
const projectPath = xcodeProjPath + '/project.pbxproj';
const myProj = xcode.project(projectPath);
myProj.parse(function(err) {
let keyToReplace = '';
var buildPhases = myProj.hash.project.objects['PBXShellScriptBuildPhase'];
for (var key in buildPhases) {
//Find build phase by name
if (buildPhases[key].name?.includes('strip unused archs')) {
keyToReplace = key;
delete myProj.hash.project.objects['PBXShellScriptBuildPhase'][keyToReplace];
fs.writeFileSync(projectPath, myProj.writeSync());
}
}
var options = { shellPath: '/bin/sh', shellScript: '' };
//Read the new script from file
fs.readFile('./hooks/buildPhaseScript.sh','utf8', function(err, data){
if (err) {
console.error(err);
return;
}
// Display the file content
options.shellScript = data;
myProj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Sentry strip unused archs', myProj.getFirstTarget().uuid, options);
fs.writeFileSync(projectPath, myProj.writeSync());
});
});
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org