SymolicationEnabler unity post-processor
| /* | |
| The MIT License (MIT) | |
| Copyright (c) 2014 Andrew Fray, Marcelo Oliveira | |
| 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. | |
| */ | |
| using UnityEngine; | |
| using UnityEditor; | |
| using UnityEditor.Callbacks; | |
| using System.IO; | |
| // unity builds by default don't include info to symbolicate iOS crashes. | |
| // this post-processor turns on some flags to enable that. | |
| // https://github.com/agentsim/Symbolicator | |
| // http://www.markj.net/ios-crash-reports-unity3d-symbolicate/ | |
| class SymbolicationEnabler | |
| { | |
| #if UNITY_IPHONE | |
| [PostProcessBuild(1400)] // near the end | |
| public static void OnPostProcessBuild(BuildTarget target, string path) | |
| { | |
| if (target != BuildTarget.iPhone) { | |
| return; // How did we get here? | |
| } | |
| // Adjust dSYM generation | |
| var xcodeProjectPath = Path.Combine(path, "Unity-iPhone.xcodeproj"); | |
| var pbxPath = Path.Combine(xcodeProjectPath, "project.pbxproj"); | |
| var sb = new System.Text.StringBuilder(); | |
| var xcodeProjectLines = File.ReadAllLines(pbxPath); | |
| foreach (var line in xcodeProjectLines) { | |
| // Remove from OTHER_LDFLAGS | |
| if (line.Contains("-Wl,-S,-x")) { | |
| continue; | |
| } | |
| // iOS Default when not present is dwarf-with-dsym | |
| if (line.Contains("DEBUG_INFORMATION_FORMAT")) { | |
| // Replace line to stripping on postprocess deployment flags | |
| sb.AppendLine("\t\t\t\tDEPLOYMENT_POSTPROCESSING = YES;"); | |
| sb.AppendLine("\t\t\t\tSEPARATE_STRIP = YES;"); | |
| sb.AppendLine("\t\t\t\tSTRIP_INSTALLED_PRODUCT = YES;"); | |
| continue; | |
| } | |
| // Defaults to Yes | |
| if (line.Contains("COPY_PHASE_STRIP")) { | |
| continue; | |
| } | |
| // Defaults to Yes | |
| if (line.Contains("GCC_GENERATE_DEBUGGING_SYMBOLS")) { | |
| continue; | |
| } | |
| sb.AppendLine(line); | |
| } | |
| File.WriteAllText(pbxPath, sb.ToString()); | |
| } | |
| #endif | |
| } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Question: Why do this with text processing rather than use Unity's Xcode API? (I guess a reasonable argument could be made that Unity doesn't ship with the API yet, so you didn't want to require a separate download.) |
This comment has been minimized.
This comment has been minimized.
|
Two reasons:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
content forked from https://gist.github.com/Capyvara/5230032. for more on symbolication:
http://www.markj.net/ios-crash-reports-unity3d-symbolicate/
http://docs.unity3d.com/ScriptReference/CrashReport.html