sentry-unity icon indicating copy to clipboard operation
sentry-unity copied to clipboard

iOS app crash due to `dyld[1746]: Library not loaded: '@rpath/Sentry.framework/Sentry' `

Open michaelhly opened this issue 2 years ago • 9 comments

Environment

iOS 15.7 XCode 13.4.1 macOS Monterey 12.5.1

How do you use Sentry? Sentry SaaS (sentry.io)

Which version of the SDK? 0.23.0

How did you install the package? (Git-URL, Assetstore) Git-URL via UPM

Which version of Unity? Unity 2021.3.6f1

Is this happening in Unity (editor) or on a player like Android, iOS, Windows? iOS

Steps to Reproduce

  1. Install Sentry to Unity project via UPM

  2. Set up Sentry via Wizard

  3. Build Unity project targeting iOS platform Screen Shot 2022-09-13 at 5 24 34 PM

  4. XCode build is sucessful

  5. App crashes on immediately boot

Expected Result

App should not crash immediately on boot

Actual Result

App crashes immediately after successful build:

dyld`__abort_with_payload:
    0x101948b0c <+0>:  mov    x16, #0x209
    0x101948b10 <+4>:  svc    #0x80
->  0x101948b14 <+8>:  b.lo   0x101948b34               ; <+40>
    0x101948b18 <+12>: pacibsp 
    0x101948b1c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x101948b20 <+20>: mov    x29, sp
    0x101948b24 <+24>: bl     0x101909f64               ; cerror_nocancel
    0x101948b28 <+28>: mov    sp, x29
    0x101948b2c <+32>: ldp    x29, x30, [sp], #0x10
    0x101948b30 <+36>: retab  
    0x101948b34 <+40>: ret    
dyld[1746]: Library not loaded: '@rpath/Sentry.framework/Sentry'
  Referenced from: '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/UnityFramework.framework/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/System/Library/Frameworks/Sentry.framework/Sentry' (no such file)
Library not loaded: '@rpath/Sentry.framework/Sentry'
  Referenced from: '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/UnityFramework.framework/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/CDCAFA71-2AB9-4BA7-82FA-499E19B0D326/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/System/Library/Frameworks/Sentry.framework/Sentry' (no such file)
(lldb) 

Any logs or screenshots

Screen Shot 2022-09-13 at 5 28 05 PM Screen Shot 2022-09-13 at 5 27 55 PM Screen Shot 2022-09-13 at 5 27 50 PM Screen Shot 2022-09-13 at 5 27 44 PM Screen Shot 2022-09-13 at 5 27 40 PM Screen Shot 2022-09-13 at 5 27 33 PM

I've tried with Native iOS enabled and disabled

michaelhly avatar Sep 13 '22 22:09 michaelhly

Thanks for raising. Any logs in the Unity Console by any chance, of Sentry failing to do its thing?

Could you please attach a repro? The xcode project it generates would help. It seems like the Sentry native (cocoa) SDK isn't getting added to the final xcode project, somehow. But yet, it's compiling, and we refer to it from main.m.

In CI we build an app from Unity 2021.3 and launch on an emulator, and capture events. So we'd need a repro to see how your app is behaving different than the app we build in CI.

Btw, did you upgrade between SDK versions? Or is that a fresh install of Sentry's SDK?

bruno-garcia avatar Sep 13 '22 22:09 bruno-garcia

Hi, I toggled Embed & Sign on Sentry.framework inside the UnityFramework and I'm getting some signing related error:

Screen Shot 2022-09-13 at 5 40 53 PM

Here is what I'm getting from XCode:

dyld[1873]: Library not loaded: '@rpath/Sentry.framework/Sentry'
  Referenced from: '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/UnityFramework.framework/Frameworks/Sentry.framework/Sentry' (code signature in <2A413EDD-AA30-30A7-A238-EACDC253CDF0> '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/UnityFramework.framework/Frameworks/Sentry.framework/Sentry' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/System/Library/Frameworks/Sentry.framework/Sentry' (no such file)
Library not loaded: '@rpath/Sentry.framework/Sentry'
  Referenced from: '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/Sentry.framework/Sentry' (no such file), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/UnityFramework.framework/Frameworks/Sentry.framework/Sentry' (code signature in <2A413EDD-AA30-30A7-A238-EACDC253CDF0> '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.app/Frameworks/UnityFramework.framework/Frameworks/Sentry.framework/Sentry' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.), '/private/var/containers/Bundle/Application/5F5C595D-139F-4791-B039-FFB7F9DE4CE8/My.a
(lldb) 

In particular: entry.framework/Sentry' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.)

I tried add hoc signing with codesign but getting the same results ...

Any logs in the Unity Console by any chance, of Sentry failing to do its thing?

I didn't see any ... Unity build was successful ..

Could you please attach a repro?

I'll try to find some time and attach a repro ...

Sentry native (cocoa) SDK

I have sentry native SDK installed separately on a non-Unity iOS target

In CI we build an app from Unity 2021.3 and launch on an emulator

I am on an m1 mac book so I cannot use an emulator. Since Unity does not have support for arm64 simulator SDKs right now.

Btw, did you upgrade between SDK versions? Or is that a fresh install of Sentry's SDK?

Fresh install of Sentry's Unity SDK

michaelhly avatar Sep 13 '22 22:09 michaelhly

In particular: entry.framework/Sentry' not valid for use in process: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.)

Not to say it's a solution, but a work around, to unblock you, could be to use Disable Library Validation as pointed out in this thread: https://github.com/opencv/opencv/issues/15645#issuecomment-554495051

Thanks for all the other info. The repro could help further.

bruno-garcia avatar Sep 13 '22 22:09 bruno-garcia

Hi @michaelhly. Did the workaround work for you? A repro would be highly appreciated!

bitsandfoxes avatar Oct 11 '22 15:10 bitsandfoxes

Same thing happen to me

VadymTykhoniuk avatar Oct 13 '22 09:10 VadymTykhoniuk

I have sentry native SDK installed separately on a non-Unity iOS target

Do I read that correctly: You're embedding the Unity game within another App?

bitsandfoxes avatar Oct 13 '22 11:10 bitsandfoxes

I have sentry native SDK installed separately on a non-Unity iOS target

Do I read that correctly: You're embedding the Unity game within another App?

We're using Unity as a library

michaelhly avatar Oct 13 '22 23:10 michaelhly

We're using Unity as a library

The SDK does not really support this use case. There might be a workaround by disabling the Native SDKs and simply relying on the .NET layer to avoid conflicts.

bitsandfoxes avatar Oct 14 '22 15:10 bitsandfoxes

I wonder if installing the Sentry Cocoa SDK separately in the main application would work in this scenario? I mean, it would work for the app, but would Sentry-Unity find it and use it for the library components?

mattjohnsonpint avatar Oct 14 '22 15:10 mattjohnsonpint

would Sentry-Unity find it and use it for the library components

It does not due to the way is it set up right now.

  • The Unity SDK propagates all the relevant options to the native layer at build time (e.g. DNS, release, environment, debug).
  • Based on that it does not try to interact with the native layer if the native support has been disabled at build time (e.g. no scope sync)

It would be really nice to have tho.

bitsandfoxes avatar Oct 17 '22 10:10 bitsandfoxes

@bitsandfoxes it's something that we really to have, but for now it's preventing us from purchasing license

VadymTykhoniuk avatar Oct 18 '22 08:10 VadymTykhoniuk

We're going to follow up on this in: https://github.com/getsentry/sentry-unity/issues/1009 Getting it to work at the very least with native support disabled is definitely something we're interested in.

bitsandfoxes avatar Oct 18 '22 15:10 bitsandfoxes