The purpose of this project is to allow editing an XCode 4 project.
This project is based upon the python project Mod PBXProj by Calvin Rien (http://the.darktable.com/). Due to the recent addiction of PostProcessBuild attribute to Unity, I found much useful having a C# version of the library.
Clone this repo somewhere under Assets/Editor in your project. If your project is not yet checked into git, then you'll need to do the appropriate setup and add this as a submodule (google: git-submodule).
If you already use git for your project, then just add this as a submodule.
You can use the XCProject class in any part of your editor and postprocess code. Taking advantage of the great powers of the new PostProcessBuild attribute, I suggest to use a small cs static class to run through all the projmods files in your asses folder and simply apply them to the newly created xcode project.
using UnityEditor;
public static class XCodePostProcess
{
[PostProcessBuild]
public static void OnPostProcessBuild( BuildTarget target, string path )
{
// Create a new project object from build target
XCodeEditor.XCProject project = new XCodeEditor.XCProject( targetPath );
// Find and run through all projmods files to patch the project
var files = System.IO.Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
foreach( var file in files ) {
project.ApplyMod( file );
}
// Finally save the xcode project
project.Save();
}
}The projmods file is a simple text file containing a JSON object. It will be used to pass the parameters to the ApplyMod method. This is the file I use for the GameCenter plugin as a brief example:
{
"group": "GameCenter",
"libs": [],
"frameworks": ["GameKit.framework"],
"headerpaths": ["Editor/iOS/GameCenter/**"],
"files": ["Editor/iOS/GameCenter/GameCenterBinding.m",
"Editor/iOS/GameCenter/GameCenterController.h",
"Editor/iOS/GameCenter/GameCenterController.mm",
"Editor/iOS/GameCenter/GameCenterManager.h",
"Editor/iOS/GameCenter/GameCenterManager.m"],
"folders": [],
"excludes": ["^.*.meta$", "^.*.mdown^", "^.*.pdf$"]
}- group: all files and folders will be parented to this group;
- libs: add libraries to build phase;
- frameworks: add frameworks to the project;
- headerpaths: add header paths to build phase;
- files: add single files to the project;
- folders: create a subgroup and add all files to the project (recursive);
- excludes: file mask to exclude;
Note: all paths are relative to projmods location
This project is based on "XCode Editor for Unity" by Daniele Cariola. You can find original project at https://github.com/dcariola/XCodeEditor-for-Unity
The project is licensed under MIT license. See License.md for full license text.
If you want to fix a bug, implement a new feature or improve documentation or tests, you are welcome to submit a pull request.
Before implementing a new feature please discuss it with author to make sure that he shares your point of view and your pull request will be merged.