Go implement of Parser utility for xcodeproj project files, Allows you to edit xcodeproject f 77D0 iles and write them back out.
It's heavily mimicked and inspired by cordova-node-xcode.
Warning: this project was not fully tested, use it at yout own risk.
package main
import (
"log"
"github.com/soapywu/pbxproj/pbxproj"
)
func main() {
// Create a new project
projectPath := "project.pbxproj"
project := pbxproj.NewPbxProject(projectPath)
// Parse the project
err := project.Parse()
if err != nil {
log.Fatal(err)
}
// Dump the project structure as JSON
// project.Dump(os.Stdout)
// Add some files
err = project.AddHeaderFile("foo.h")
if err != nil {
log.Println(err)
}
err = project.AddSourceFile("foo.m")
if err != nil {
log.Println(err)
}
err = project.AddFramework("FooKit.framework")
if err != nil {
log.Println(err)
}
// Dump the modify project structure as JSON
// project.Dump(os.Stdout)
// Write the project back out
// pbxproj.NewPbxWriter(&project).Write("project.pbxproj")
_ = pbxproj.NewPbxWriter(&project).Write("modifiedProject.pbxproj")
}
The .pbxProj parser(pegparser/pbxproj.go) is generated from the grammar in pegparser/pbxproj.peg by pigeon.
If there's a problem parsing, you need to edit the grammar in pbxproj.peg and regenerate the parser.
# install the pigeon tool
$ go get -u github.com/mna/pigeon
$ pigeon -o pegparser/pbxproj.go pegparser/pbxproj.peg
Apache V2