Quickstart-unity: Failed to add Crashlytics Run Script

Created on 29 Apr 2020  路  11Comments  路  Source: firebase/quickstart-unity

Please fill in the following fields:

Unity editor version: 2018.4.21f1
Firebase Unity SDK version: 6.14
Source you installed the SDK (.unitypackage or Unity Package Manager): UPM
Firebase plugins in use (Auth, Database, etc.): Analytics, Crashlytics
Additional SDKs you are using (Facebook, AdMob, etc.): irrelevant
Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): iOS/Android
Scripting Runtime (Mono, and/or IL2CPP): IL2CPP

Please describe the issue here:

After a successful build, I get the following error message:
Failed to add Crashlytics Run Script: 'Object reference not set to an instance of an object'

I have managed to understand the issue by looking at decompiled versions of Firebase.Crashlytics.Editor.dll, which brings up the question why this code is not public like all other Firebase apps (and like Fabric was).

There seems to be a bug on iOSPostBuild preventing proper flow on Unity < 2019.
There is a logic to select the name of a method to be used by reflection depending on the Unity version - it chooses between AppendShellScriptBuildPhase(<2019) or AddShellScriptBuildPhase (>=2019).
However, the actual call to GetMethod() shares the same Type[] argument, which is invalid for Unity 2018's AppendShellScriptBuildPhase. Instead of (string,string,string,string) this method expects (IEnumerable<string>,string,string,string).

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
Haven't tried.

What's the issue repro rate? (eg 100%, 1/5 etc)
100%

crashlytics needs-info bug

Most helpful comment

Thanks folks - I confirmed what you are seeing in terms of which methods exist in Unity 2018. We're going to try to have a fix out for the next release of the Unity SDK.

All 11 comments

Hi,

It's possible that the External Dependency Manager (EDM) is not enabled properly.
This workaround may help:

  1. Find all libraries (.dll) under Assets/ExternalDependencyManager/Editor/
  2. In Inspector window, check "Editor" platform and click "Apply"

Let me know if this makes sense and helps.


Hey @tiagomartines11. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

Hey @tiagomartines11 - looking here it seems that both types of that script are acceptable: https://bitbucket.org/Unity-Technologies/xcodeapi/src/fbd0cb184b437b751ac0e2213779c310aaba0952/Xcode/PBXProject.cs?at=stable&fileviewer=file-view-default#lines-1313

If you look at old commits, it seems to have both versions of the API dating back to 2017. How did you determine there was only the (IEnumerable<string>,string,string,string) version in Unity 2018.4.21f1?

To double check, I did a successful build on Unity 2018.4.23f1, but it is possible there are differences between this version and the one you're on, 2018.4.21f1

Hi @samedson, thanks for looking into this. I'm using Rider as my IDE, and it disassembles DLLs upon request. I have looked into the /Applications/Unity/2018.4.21f1/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll file, which is the loaded assembly (at least on Unity Editor on a Mac) that should contain those methods, and that's where I found that it was missing as per the issue description. It also makes sense, given that the error on the output is a null reference after that reflection call.

I have just downloaded 2018.4.23f1 and I can confirm the same .dll still doesn't contain the function, and it is also failing.

At this point, if you can validate that your .dll contains a AppendShellScriptBuildPhase(string,string,string,string), it might be a Windows vs. Mac situation 馃

FYI, my Unity 2018.4.23f1 (Mac) dll contains:

AddShellScriptBuildPhase(string, string, string, string)
AddShellScriptBuildPhase(string, string, string, string, List<string>)
AppendShellScriptBuildPhase(IEnumerable<string>, string, string, string)
AppendShellScriptBuildPhase(IEnumerable<string>, string, string, string, List<string>)

Hello,

I also have the exact same problem on the same versions and on mac. I checked multiple unity 2018.4 versions and they all have the same problem.
@samedson Yes, it's true the commits end in 2017, but I think it's because the ones from 2018 and on are private. If you decompile the UnityEditor.iOS.Extensions.Xcode.dll for versions 2017 and 2018, the method

 internal void AppendShellScriptBuildPhase(
      string targetGuid,
      string name,
      string shellPath,
      string shellScript)
    {
      PBXShellScriptBuildPhaseData scriptBuildPhaseData = PBXShellScriptBuildPhaseData.Create(name, shellPath, shellScript);
      this.shellScripts.AddEntry(scriptBuildPhaseData);
      this.nativeTargets[targetGuid].phases.AddGUID(scriptBuildPhaseData.guid);
    }

is missing from 2018, which causes Crashlytics to crash during Unity build. I'm not sure if this happens on windows as well but it seems strange for the code to be so different between platforms.
I think all that needs to be done to fix this problem is to change the

    System.Type[] types = new System.Type[4]
    {
      typeof (string),
      typeof (string),
      typeof (string),
      typeof (string)
    };

in iOSPostBuild.cs for Unity 2018 to match the parameters for the only AppendShellScriptBuildPhase that exists in the 2018 version of the dll.
Or otherwise changing

internal static string GetAddRunScriptMethodName(string unityVersion)
{
  string str = "AppendShellScriptBuildPhase";
  if (VersionInfo.GetUnityMajorVersion(unityVersion) >= 2019)
    str = "AddShellScriptBuildPhase";
  return str;
}

to be '>= 2018' instead of 2019 might also work, this needs to be checked more.

Thank you,
Radu

Hi,

We have the exact same issue.

Unity editor version: 2018.4.23f1 (was also reproduced on 2018.4.12f1)
Firebase Unity SDK version: 6.15.0
Source you installed the SDK (.unitypackage or Unity Package Manager): .unitypackage
Firebase plugins in use (Auth, Database, etc.): Analytics, Crashlytics
Additional SDKs you are using (Facebook, AdMob, etc.): irrelevant
Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): iOS/Android
Scripting Runtime (Mono, and/or IL2CPP): IL2CPP

Thanks folks - I confirmed what you are seeing in terms of which methods exist in Unity 2018. We're going to try to have a fix out for the next release of the Unity SDK.

Hi folks,

Many changes in Crashlytics are included in 6.15.0.
https://firebase.google.com/support/release-notes/unity#crashlytics

Could you try to update to the latest (6.15.2 by today) and see if the issue is resolved?

@samedson Could you confirm this?

Hello,
I was testing on 6.15.1 and now I updated to 6.15.2 and the error is still present. It crashes when adding Crashlytics and gives the same error as last time:

Failed to add Crashlytics Run Script: 'Object reference not set to an instance of an object'. You can manually fix this by adding a Run Script Build Phase to your Xcode project with the following script:
chmod u+x "${PROJECT_DIR}/Pods/FirebaseCrashlytics/run"
chmod u+x "${PROJECT_DIR}/Pods/FirebaseCrashlytics/upload-symbols"
"${PROJECT_DIR}/Pods/FirebaseCrashlytics/run" -gsp "${PROJECT_DIR}/GoogleService-Info.plist"
UnityEngine.Debug:LogWarning(Object)
Firebase.Crashlytics.Editor.iOSPostBuild:PrepareProject(String, IFirebaseConfigurationStorage) (at Z:/tmp/tmp.lWK8bRBkuT/firebase/crashlytics/client/unity/editor/src/iOSPostBuild.cs:105)
Firebase.Crashlytics.Editor.iOSPostBuild:OnPostprocessBuild(BuildTarget, String) (at Z:/tmp/tmp.lWK8bRBkuT/firebase/crashlytics/client/unity/editor/src/iOSPostBuild.cs:68)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

I assume the same problem is still present.

Thank you,
Radu

Good news. 6.16.0 is release and it should resolve the run script issue as well. (see release note)

I'll close this issue for now. If the issue remains, please report a new bug using bug template

Was this page helpful?
0 / 5 - 0 ratings