Skip to content

Latest commit

 

History

History
83 lines (58 loc) · 3.87 KB

Readme.mdown

File metadata and controls

83 lines (58 loc) · 3.87 KB

XCode Editor for Unity

OVERVIEW

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.

INSTALLATION

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.

USAGE

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

LICENSE

This code is distributed under the terms and conditions of the MIT license.

Copyright (c) 2012 Daniele Cariola

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.