@@ -94,9 +94,23 @@ private static void PrepareProject(string projectPath, IFirebaseConfigurationSto
94
94
var pbxProject = new UnityEditor . iOS . Xcode . PBXProject ( ) ;
95
95
pbxProject . ReadFromFile ( projectPath ) ;
96
96
97
- string targetGuid = iOSPostBuild . GetMainUnityProjectTargetGuid ( pbxProject ) ;
98
97
string completeRunScriptBody = GetRunScriptBody ( configurationStorage ) ;
99
98
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 ) {
100
114
try {
101
115
// Use reflection to append a Crashlytics Run Script
102
116
BindingFlags bindingFlags = BindingFlags . NonPublic | BindingFlags . Instance | BindingFlags . Public ;
@@ -117,8 +131,6 @@ private static void PrepareProject(string projectPath, IFirebaseConfigurationSto
117
131
} finally {
118
132
// Set debug information format to DWARF with DSYM
119
133
pbxProject . SetBuildProperty ( targetGuid , "DEBUG_INFORMATION_FORMAT" , "dwarf-with-dsym" ) ;
120
-
121
- pbxProject . WriteToFile ( projectPath ) ;
122
134
}
123
135
}
124
136
@@ -140,6 +152,28 @@ internal static iOSBuildPhaseMethodCall GetBuildPhaseMethodCall(string unityVers
140
152
}
141
153
}
142
154
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
+ }
143
177
144
178
/// <summary>
145
179
/// Get the main Unity project's target GUID
0 commit comments