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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to