Skip to content

Commit 9157c10

Browse files
Googlera-maurice
authored andcommitted
Initial import of the Firebase Unity SDK - 388549025 Update Installations to handle newer swig versions by amaurice <[email protected]>
- 388275326 Crashlytics Unity Upload UnityFramework dSYM file and set... by Googler <[email protected]> PiperOrigin-RevId: 388549025
1 parent a8fbd6a commit 9157c10

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

docs/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ Support
163163

164164
Release Notes
165165
-------------
166+
### Unreleased:
167+
- Changes
168+
- Crashlytics: Upload UnityFramework symbols in addition to the main app
169+
dSYM file to improve symbolication
170+
([#673](https://github.com/firebase/quickstart-unity/issues/673)).
171+
166172
### 8.2.0:
167173
- Changes
168174
- Firestore: Removed `Equals` and `GetHashCode` methods from `Query`,

editor/crashlytics/src/iOSPostBuild.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,23 @@ private static void PrepareProject(string projectPath, IFirebaseConfigurationSto
9494
var pbxProject = new UnityEditor.iOS.Xcode.PBXProject();
9595
pbxProject.ReadFromFile(projectPath);
9696

97-
string targetGuid = iOSPostBuild.GetMainUnityProjectTargetGuid(pbxProject);
9897
string completeRunScriptBody = GetRunScriptBody(configurationStorage);
9998

99+
string appGUID = iOSPostBuild.GetMainUnityProjectTargetGuid(pbxProject);
100+
SetupGUIDForSymbolUploads(pbxProject, completeRunScriptBody, appGUID);
101+
102+
// In older versions of Unity there is no separate framework GUID, so this can
103+
// be empty or null.
104+
string frameworkGUID = iOSPostBuild.GetUnityFrameworkTargetGuid(pbxProject);
105+
if (!String.IsNullOrEmpty(frameworkGUID)) {
106+
SetupGUIDForSymbolUploads(pbxProject, completeRunScriptBody, frameworkGUID);
107+
}
108+
109+
pbxProject.WriteToFile(projectPath);
110+
}
111+
112+
private static void SetupGUIDForSymbolUploads(UnityEditor.iOS.Xcode.PBXProject pbxProject,
113+
string completeRunScriptBody, string targetGuid) {
100114
try {
101115
// Use reflection to append a Crashlytics Run Script
102116
BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public;
@@ -117,8 +131,6 @@ private static void PrepareProject(string projectPath, IFirebaseConfigurationSto
117131
} finally {
118132
// Set debug information format to DWARF with DSYM
119133
pbxProject.SetBuildProperty(targetGuid, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym");
120-
121-
pbxProject.WriteToFile(projectPath);
122134
}
123135
}
124136

@@ -140,6 +152,28 @@ internal static iOSBuildPhaseMethodCall GetBuildPhaseMethodCall(string unityVers
140152
}
141153
}
142154

155+
private static string GetUnityFrameworkTargetGuid(UnityEditor.iOS.Xcode.PBXProject project) {
156+
// var project = (UnityEditor.iOS.Xcode.PBXProject)projectObj;
157+
MethodInfo getUnityFrameworkTargetGuid =
158+
project.GetType().GetMethod("GetUnityFrameworkTargetGuid");
159+
160+
// Starting in Unity 2019.3, TargetGuidByName is deprecated
161+
// Use reflection to call the GetUnityFrameworkTargetGuid method if it exists (it was added
162+
// ub 2019.3).
163+
if (getUnityFrameworkTargetGuid != null) {
164+
return (string)getUnityFrameworkTargetGuid.Invoke(project, new object[] {});
165+
} else {
166+
// Hardcode the main target name "UnityFramework" because there isn't a way to get the
167+
// Unity Framework target name.
168+
string targetName = "UnityFramework";
169+
MethodInfo targetGuidByName = project.GetType().GetMethod("TargetGuidByName");
170+
if (targetGuidByName != null) {
171+
return (string)targetGuidByName.Invoke(project, new object[] { (object)targetName });
172+
} else {
173+
return "";
174+
}
175+
}
176+
}
143177

144178
/// <summary>
145179
/// Get the main Unity project's target GUID

installations/src/swig/installations.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ static CppInstanceManager<Installations> g_installations_instances;
175175

176176
// Replace the default Dispose() method to remove references to this instance
177177
// from the map of FirebaseInstallations instances.
178+
#if SWIG_VERSION >= 0x040000
179+
%typemap(csdisposing, methodname="Dispose",
180+
parameters="bool disposing", methodmodifiers="public")
181+
#else
178182
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public")
183+
#endif
179184
firebase::installations::Installations {
180185
lock (installationsByAppCPtr) {
181186
if (appProxy != null) {

0 commit comments

Comments
 (0)