`XUPorter` can help you to add files and frameworks to your Xcode 4 project after it is generated by Unity 3D automatically and dramatically. Lot of changes from [XCodeEditor-for-Unity](https://github.com/dcariola/XCodeEditor-for-Unity).
Add all files of the repo to your Unity project's Editor Folder: {$ProjectFolder}/Assets/Editor/XUPorter or you can download [this unity package](https://www.dropbox.com/s/lo2wu7gur64py7a/XUPorter.unitypackage) and import to your project.
Some demos are contained in /Mods folder, they are just a tutorial to help you getting start. Please feel free to delete or substitute all files in that folder as soon as you know how to use `XUPorter`. [A simplified MiniJSON](https://github.com/prime31/UIToolkit/blob/master/Assets/Plugins/MiniJSON.cs) is now used in `XUPorter`, but I put it into a namespace, so there is no worry of conflicting, even if you are already using a same JSON wrapper.
`XUPorter` require Unity 3.5 or higher and Xcode 4 to work properly. I have tested for Xcode 5 DP and it can work well now too.
## Usage
After the Unity's building phase, OnPostProcessBuild in XCodePostProcess.cs will be called and Xcode project file will be modified. All .projmods (which is in JSON) will be treated as Xcode patch setting files (In the demos, all .projmods files are in /Mods folder). `XUPorter` will find and read all projmods files in /Assets and modify Xcode project file as settings.
In these setting files, specify the fields using a json pattern.
* group:The group name in Xcode to which files and folders will added by this projmods file
* libs:The name of libs should be added in Xcode Build Phases, libz.dylib for example. If you want to import a .a lib to Xcode, add it as a file(in "files")
* frameworks:The name of framework should be added in Xcode Build Phases, Security.framework for example. If you want to add a third party framework, add it using a relative path to `files` section instead of here.
* headerpaths:Header Search Paths in Build Setting of Xcode
* files:Files which should be added
* folders:Folders which should be added. All file and folders(recursively) will be added
* excludes:Regular expression pattern. Matched files will not be added.
* compiler_flags: Compiler flags which should be added, e.g. "-Wno-vexing-parse"
* linker_flags: Linker flags which should be added, e.g. "-ObjC"
* embed_binaries: Optional fields, support XCode 6+ `Embed Framework` feature. Notice: The frameworks must added already in `frameworks` or `files` fields.
* plist: edit the Info.plist file, only the urltype is supported currently. in url type settings, `name` and `schemes` are required, while `role` is optional and is `Editor` by default.
Use : for folders and files to add compiler flags to those files. For example: `path/to/my/folder:-fobjc-arc` or `path/to/my/file.m:-fobjc-arc`. You can add multiple compiler flags by using , to seperate them, too.
One example, the following file will add all files in /iOS/KKKeychain to the Xcode group `KKKeychain` and add the `Security.framework` to Xcode project.
Thanks for all contributors of this project. Especially [@pronebird](https://github.com/pronebird) and [@MatthewMaker](https://github.com/MatthewMaker)'s great effort!
## LICENSE
This code is distributed under the terms and conditions of the MIT license.
Copyright (c) 2012 Wei Wang @onevcat
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,
//Xcode uses space as the delimiter here, so if there's a space in the filename, we *must* quote. Escaping with slash may work when you are in the Xcode UI, in some situations, but it doesn't work here.
if(currentPath.Contains(@" "))quoted=true;
if(quoted){
//if it ends in "/**", it wants to be recursive, and the "/**" needs to be _outside_ the quotes
/// <para>This will initialize sdk to report native exception such as obj-c, c/c++, java exceptions, and also enable c# exception handler to report c# exception logs</para>
/// </summary>
/// <param name="appId">App identifier.</param>
publicstaticvoidInitWithAppId(stringappId)
{
if(IsInitialized){
DebugLog(null,"BuglyAgent has already been initialized.");
return;
}
if(string.IsNullOrEmpty(appId)){
return;
}
// init the sdk with app id
InitBuglyAgent(appId);
DebugLog(null,"Initialized with app id: {0}",appId);
// Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback)
_RegisterExceptionHandler();
}
/// <summary>
/// Only Enable the C# exception handler.
///
/// <para>
/// You can call it when you do not call the 'InitWithAppId(string)', but you must make sure initialized the sdk in elsewhere,
/// such as the native code in associated Android or iOS project.
/// </para>
///
/// <para>
/// Default Level is <c>LogError</c>, so the LogError, LogException will auto report.
/// </para>
///
/// <para>
/// You can call the method <code>BuglyAgent.ConfigAutoReportLogLevel(LogSeverity)</code>
/// to change the level to auto report if you known what are you doing.
/// </para>
///
/// </summary>
publicstaticvoidEnableExceptionHandler()
{
if(IsInitialized){
DebugLog(null,"BuglyAgent has already been initialized.");
return;
}
DebugLog(null,"Only enable the exception handler, please make sure you has initialized the sdk in the native code in associated Android or iOS project.");
// Register the LogCallbackHandler by Application.RegisterLogCallback(Application.LogCallback)
_RegisterExceptionHandler();
}
/// <summary>
/// Registers the log callback handler.
///
/// If you need register logcallback using Application.RegisterLogCallback(LogCallback),
// Config auto quit the application make sure only the first one c# exception log will be report, please don't set TRUE if you do not known what are you doing.
BuglyAgent.ConfigAutoQuitApplication(false);
// If you need register Application.RegisterLogCallback(LogCallback), you can replace it with this method to make sure your function is ok.
BuglyAgent.RegisterLogCallback(null);
// Init the bugly sdk and enable the c# exception handler.
BuglyAgent.InitWithAppId(BuglyAppID);
// TODO Required. If you do not need call 'InitWithAppId(string)' to initialize the sdk(may be you has initialized the sdk it associated Android or iOS project),
// please call this method to enable c# exception handler only.
BuglyAgent.EnableExceptionHandler();
// TODO NOT Required. If you need to report extra data with exception, you can set the extra handler