alunny / node-xcode

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

addFramework throws Cannot read property 'children' of null error #43

Open ldeluca opened 9 years ago

ldeluca commented 9 years ago

I am using the simple example from the xcode npm module readme file:

var xcode = require('xcode'),
            fs = require('fs'),
            projectPath = 'test.xcodeproj/project.pbxproj',
            myProj = xcode.project(projectPath);

        // parsing is async, in a different process
        myProj.parse(function (err) {
            //myProj.addHeaderFile('foo.h');
            //myProj.addSourceFile('foo.m');
                var path2files = "test.framework";
            myProj.addFramework(path2files);

            fs.writeFileSync(projectPath, myProj.writeSync());
            console.log('new project written');
        });

If I comment out .addFramework I get the 'new project written' message. but if i leave it in I get an error. The file is in the same location where i'm running my npm module from. I tried playing with the path variable (which is why it's a var) but no luck.

error:

/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/sdk/node_modules/xcode/lib/pbxProject.js:328
pluginsGroup.children.push(pbxGroupChild(file));
            ^

TypeError: Cannot read property 'children' of null at pbxProject.addToFrameworksPbxGroup (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/sdk/node_modules/xcode/lib/pbxProject.js:328:17) at pbxProject.addFramework (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/sdk/node_modules/xcode/lib/pbxProject.js:194:10) at pbxProject. (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/sdk/sdk.js:645:12) at pbxProject.emit (events.js:110:17) at pbxProject. (/Users/ldeluca/.nvm/v0.11.14/lib/node_modules/sdk/node_modules/xcode/lib/pbxProject.js:30:18) at ChildProcess.emit (events.js:110:17) at handleMessage (child_process.js:323:10) at Pipe.channel.onread (child_process.js:351:11)

soflare commented 9 years ago

To workaround, create a group named "Frameworks".