Skip to content

Commit a16f091

Browse files
committed
Merge pull request dcariola#6 from erbridge/readme_usage
Merging from erbridge: Copy usage instructions from the blog
2 parents 529948b + a160bf7 commit a16f091

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

Readme.mdown

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,62 @@ Clone this repo somewhere under Assets/Editor in your project. If your project i
1414
If you already use git for your project, then just add this as a submodule.
1515

1616

17+
## USAGE
18+
19+
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.
20+
21+
```cs
22+
using UnityEditor;
23+
24+
public static class XCodePostProcess
25+
{
26+
[PostProcessBuild]
27+
public static void OnPostProcessBuild( BuildTarget target, string path )
28+
{
29+
// Create a new project object from build target
30+
XCodeEditor.XCProject project = new XCodeEditor.XCProject( targetPath );
31+
32+
// Find and run through all projmods files to patch the project
33+
var files = System.IO.Directory.GetFiles( Application.dataPath, "*.projmods", SearchOption.AllDirectories );
34+
foreach( var file in files ) {
35+
project.ApplyMod( file );
36+
}
37+
38+
// Finally save the xcode project
39+
project.Save();
40+
}
41+
}
42+
```
43+
44+
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:
45+
46+
```json
47+
{
48+
"group": "GameCenter",
49+
"libs": [],
50+
"frameworks": ["GameKit.framework"],
51+
"headerpaths": ["Editor/iOS/GameCenter/**"],
52+
"files": ["Editor/iOS/GameCenter/GameCenterBinding.m",
53+
"Editor/iOS/GameCenter/GameCenterController.h",
54+
"Editor/iOS/GameCenter/GameCenterController.mm",
55+
"Editor/iOS/GameCenter/GameCenterManager.h",
56+
"Editor/iOS/GameCenter/GameCenterManager.m"],
57+
"folders": [],
58+
"excludes": ["^.*.meta$", "^.*.mdown^", "^.*.pdf$"]
59+
}
60+
```
61+
62+
- group: all files and folders will be parented to this group;
63+
- libs: add libraries to build phase;
64+
- frameworks: add frameworks to the project;
65+
- headerpaths: add header paths to build phase;
66+
- files: add single files to the project;
67+
- folders: create a subgroup and add all files to the project (recursive);
68+
- excludes: file mask to exclude;
69+
70+
Note: all paths are relative to projmods location
71+
72+
1773
## LICENSE
1874

1975
This code is distributed under the terms and conditions of the MIT license.
@@ -24,4 +80,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
2480

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

27-
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.
83+
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.

0 commit comments

Comments
 (0)