Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read xcode(8.2.1) project #121

Open
wajahatch888 opened this issue Jan 8, 2017 · 2 comments
Open

Unable to read xcode(8.2.1) project #121

wajahatch888 opened this issue Jan 8, 2017 · 2 comments

Comments

@wajahatch888
Copy link

wajahatch888 commented Jan 8, 2017

I am using following code to read xcode project and add one header file But it fails.

var xcode = require('xcode'),
    fs = require('fs'),
    projectPath = '/Users/Wajahat/Desktop/JASONETTE-iOS/app/Jasonette.xcodeproj/project.pbxproj',
    myProj = xcode.project(projectPath);

// parsing is async, in a different process
myProj.parse(function (err) {
    myProj.addHeaderFile('testheader.h');
   
   

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

I am getting following error

TypeError: Cannot read property 'path' of null
at correctForPath (/Users/Wajahat/Desktop/electron-quick-start-master/node_modules/xcode/lib/pbxProject.js:1586:38)
at correctForPluginsPath (/Users/Wajahat/Desktop/electron-quick-start-master/node_modules/xcode/lib/pbxProject.js:1572:12)
at pbxProject.addPluginFile (/Users/Wajahat/Desktop/electron-quick-start-master/node_modules/xcode/lib/pbxProject.js:89:5)
at pbxProject.addHeaderFile (/Users/Wajahat/Desktop/electron-quick-start-master/node_modules/xcode/lib/pbxProject.js:197:21)
at pbxProject. (/Users/Wajahat/Desktop/electron-quick-start-master/xcodetest.js:9:12)
at emitTwo (events.js:106:13)
at pbxProject.emit (events.js:191:7)
at pbxProject. (/Users/Wajahat/Desktop/electron-quick-start-master/node_modules/xcode/lib/pbxProject.js:31:18)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)

Can anybody tell what i am doing wrong? Thanks in advance.

@hypery2k
Copy link

try first to parse, e.g.

var xcodeProject = xcode.project(projectPath);
xcodeProject.parseSync();
var buildPhase = xcodeProject.addBuildPhase(...

@imhotep
Copy link
Collaborator

imhotep commented Jan 25, 2017

@hypery2k apologies for the slow reply. You need to specify a group to add the header to otherwise it your header is added to a group named "Plugins" which you probably don't have in your project?

myProj.addHeader(path, opt, group)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants