alunny / node-xcode

tools and utilities for working with xcode/ios projects
Apache License 2.0
226 stars 105 forks source link

looking for an example #42

Open ldeluca opened 9 years ago

ldeluca commented 9 years ago

I keep getting an error when trying the xcode npm module. I simplified everything down and here is my code:

var projectPath = 'myapp.xcodeproj/project.pbxproj', myProj = xcode.project(path.resolve(projectPath)); //var hardcoded = path.resolve('myapp', 'node_modules','com.test','CDVCamera.m'); //var hardcoded = "myapp" +"/node_modules/"+"com.test"+"/CDVCamera.m"; //var hardcoded = 'Plugins/' + 'com.test' + "/CDVCamera.m"; var hardcoded = fixPathSep(path.relative('Plugins','com.test', 'CDVCamera.m')); console.log('hardcoded is: ' + hardcoded); myProj.addSourceFile(hardcoded);

and everything fails on the myProj.addSourceFile method

TypeError: Cannot read property 'project' of undefined at pbxProject.pbxGroupByName (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/ibm-sdk/node_modules/xcode/lib/pbxProject.js:403:27) at correctForPluginsPath (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/ibm-sdk/node_modules/xcode/lib/pbxProject.js:700:17) at pbxProject.addPluginFile (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/ibm-sdk/node_modules/xcode/lib/pbxProject.js:88:5) at pbxProject.addSourceFile (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/ibm-sdk/node_modules/xcode/lib/pbxProject.js:112:21)

marcobonati commented 7 years ago

Before myProj.addSourceFile you need to add myProj.parseSync();

epetre commented 6 years ago

ok, had the same issue. Wish that was in the main example or at least addressed in the README.md