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

Is there any documentation for this project? #120

Open
TheMartas29 opened this issue Aug 31, 2021 · 2 comments
Open

Is there any documentation for this project? #120

TheMartas29 opened this issue Aug 31, 2021 · 2 comments

Comments

@TheMartas29
Copy link

I would like to ask if there is some sort of documentation for this project or perhaps can someone answer my questions?

I need to create "group" in the xcode project an add files in it. Then add these files into "compile sources" in "build phases". Is it possible to do this? I tried to create group with pbxCreateGroup() function and to add it in Xcode project I used addPbxGroupFunction(). But non of this seems to work. Also I tried to add the files directly to project with addFile() and addHeaderFile() / addSourceFile() functions but without success. I have to admit that first time I ran the script the files were added into "compile sources" in "build phases" but I wasn't able to do this again. Also I'm not really sure what the myProj.parse() does and how should I use it.

I know it is a lot of things but hopefully someone could help me.

script that I used:

project.parse(function(err) {
    if(err) console.log(err);

    var group = project.pbxCreateGroup("ASIHTTPRequest");

    files.forEach(file => {
        console.log(file);

        if (file.indexOf(".h") >= 0) {
                project.addFile(file, group);
                project.addHeaderFile(file);
                fs.writeFileSync(_PROJECT_FILE_PATH, project.writeSync());
        }
        else {
                project.addFile(file, group);
                project.addSourceFile(file);
                fs.writeFileSync(_PROJECT_FILE_PATH, project.writeSync());
        }
    })

    project.addPbxGroup([_PROJECT_FILE_PATH], "ASIHTTPRequest", _PROJECT_FILE_PATH);
    fs.writeFileSync(_PROJECT_FILE_PATH, project.writeSync());
})
@SMzig
Copy link

SMzig commented Oct 19, 2022

Hello @TheMartas29 any solution for this issue?

@TheMartas29
Copy link
Author

TheMartas29 commented Oct 19, 2022

Yeah, I guess I was able to do it with this code:

var project = xcode.project(_PBXPROJ_PATH);
if (!fs.existsSync(PROJECT_PATH + "groupName")) {
    fs.mkdir(path.join(PROJECT_PATH, "groupName"), err => {
        if (err) console.log(err);
    })
}
fse.copySync(RESOURCES_PATH, PROJECT_PATH + "groupName/");

project.parse(function (err) {  
    var files = fs.readdirSync(PROJECT_PATH + "groupName/");
    var group = project.pbxCreateGroup('groupName', 'projectName/groupName');
    var classesKey = project.findPBXGroupKey({name: 'CustomTemplate'}); //idk what CustomTemplate means
    project.addToPbxGroup(group, classesKey);

    files.forEach(file => {
        if (file.indexOf(".h") >= 0) {
            project.addHeaderFile(file, null, group);
        } else {
            project.addSourceFile(file, null, 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

2 participants