@@ -403,7 +403,21 @@ pbxProject.prototype.buildPhaseObject = function (name, group) {
403403pbxProject . prototype . updateProductName = function ( name ) {
404404 var config = this . pbxXCBuildConfigurationSection ( ) ;
405405 propReplace ( config , 'PRODUCT_NAME' , '"' + name + '"' ) ;
406- } ;
406+ }
407+
408+ // a JS getter. hmmm
409+ pbxProject . prototype . __defineGetter__ ( "productName" , function ( ) {
410+ var configurations = nonComments ( this . pbxXCBuildConfigurationSection ( ) ) ,
411+ config , productName ;
412+
413+ for ( config in configurations ) {
414+ productName = configurations [ config ] . buildSettings [ 'PRODUCT_NAME' ] ;
415+
416+ if ( productName ) {
417+ return stripSurroundingQuotes ( productName ) ;
418+ }
419+ }
420+ } ) ;
407421
408422// helper recursive prop search+replace
409423function propReplace ( obj , prop , value ) {
@@ -493,4 +507,21 @@ function correctForResourcesPath(file, project) {
493507 return file ;
494508}
495509
510+ function nonComments ( obj ) {
511+ var keys = Object . keys ( obj ) ,
512+ newObj = { } , i = 0 ;
513+
514+ for ( i ; i < keys . length ; i ++ ) {
515+ if ( ! COMMENT_KEY . test ( keys [ i ] ) ) {
516+ newObj [ keys [ i ] ] = obj [ keys [ i ] ] ;
517+ }
518+ }
519+
520+ return newObj ;
521+ }
522+
523+ function stripSurroundingQuotes ( str ) {
524+ return str . replace ( / ^ " ( .* ) " $ / , "$1" ) ;
525+ }
526+
496527module . exports = pbxProject ;
0 commit comments