Xamarin.iOS 应用程序因缺少 Mono 运行时而崩溃;没有找到合适的图片;代码签名阻止了 mmap

Xamarin.iOS app crashes on missing Mono runtime; no suitable image found; code signing blocked mmap

我正在尝试为 iOS 构建一个带有关联应用程序扩展的 Xamarin Forms 应用程序。我的解决方案结构是这样的:

MyProject
  \BitThicket.MyProject                    -- Forms project
  \BitThicket.MyProject.Core               -- NET Standard 2.0 class library
  \BitThicket.MyProject.iOS                -- iOS project
  \BitThicket.MyProject.Extensions.Intents -- Intents project

每个项目都是从一个模板创建的,我做了很少的更改 - 崩溃发生在启动时,所以我的代码 none 无论如何都达到了。

我的目标是 iOS 11.1,并且我设置了有效的签名证书和配置文件。我能够构建应用程序并将其部署到设备(我的 iPhone 7+)从 Visual Studio for Mac (7.2.2)。但是,当调试器尝试为我启动应用程序时,显示空白启动视图,然后应用程序崩溃。调试器从不连接。顺便说一句,当应用程序在设备上手动启动时,它会以同样的方式崩溃。

我使用 Xcode 检索了设备日志,崩溃如下所示:

Incident Identifier: 948709A2-74AA-4E16-BEEA-072CFCF4AB38
CrashReporter Key:   ######################################
Hardware Model:      iPhone9,2
Process:             BitThicket.Turns.iOS [2457]
Path:                /private/var/containers/Bundle/Application/#####-##############-############/BitThicket.Turns.iOS.app/BitThicket.Turns.iOS
Identifier:          com.bitthicket.Turns
Version:             1.0 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.bitthicket.Turns [818]


Date/Time:           2017-11-24 09:41:15.3743 -0600
Launch Time:         2017-11-24 09:41:15.3041 -0600
OS Version:          iPhone OS 11.1.2 (15B202)
Baseband Version:    3.21.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, Library not loaded: @rpath/Mono.framework/Mono | Referenced from: /var/containers/Bundle/Application/########-####-####-####-############/BitThicket.Turns.iOS.app/BitThicket.Turns.iOS | Reason: no suitable image found.  Did find: | /private/var/containers/Bundle/Application/########-####-####-####-############/BitThicket.Turns.iOS.app/Frameworks/Mono.framework/Mono: code signing blocked mmap() of '/private/var/containers/Bundle/Application/########-####-####-####-############/BitThicket.Turns.iOS.app/Frameworks/Mono.framework/Mono'
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 Crashed:
0   dyld                            0x0000000106722f1c __abort_with_payload + 8
1   dyld                            0x00000001067226f4 abort_with_payload_wrapper_internal + 100
2   dyld                            0x0000000106722720 fcntl + 0
3   dyld                            0x00000001066f8498 dyld::fastBindLazySymbol+ 17560 (ImageLoader**, unsigned long) + 0
4   dyld                            0x00000001066fb714 dyld::_main+ 30484 (macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 7376
5   dyld                            0x00000001066f521c _dyld_start + 68

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000006   x1: 0x0000000000000001   x2: 0x000000016d50a470   x3: 0x00000000000000a5
    x4: 0x000000016d50a070   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x00000000000002f0
    x8: 0x0000000000000020   x9: 0x0000000000000009  x10: 0x6f6e6f4d2f736b72  x11: 0x6f77656d6172662e
   x12: 0x726f77656d617246  x13: 0x2e6f6e6f4d2f736b  x14: 0x726f77656d617266  x15: 0x00276f6e6f4d2f6b
   x16: 0x0000000000000209  x17: 0x000000008000001f  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016d50a070  x21: 0x00000000000000a5  x22: 0x000000016d50a470  x23: 0x0000000000000001
   x24: 0x0000000000000006  x25: 0x00000001028f4000  x26: 0x0000000106736000  x27: 0x0000000106735f88
   x28: 0x000000016d50ba70   fp: 0x000000016d50a040   lr: 0x00000001067226f4
    sp: 0x000000016d50a000   pc: 0x0000000106722f1c cpsr: 0x00000000

Binary Images:
0x1028f4000 - 0x103e43fff BitThicket.Turns.iOS arm64  <###########################> /var/containers/Bundle/Application/########-####-####-####-############/BitThicket.Turns.iOS.app/BitThicket.Turns.iOS
0x1066f4000 - 0x106733fff dyld arm64  <##########################> /usr/lib/dyld

EOF

有人知道是什么原因造成的吗?在 Xamarin 论坛或其他地方(包括 SO,不幸的是)似乎没有很多直接的答案。我已经尝试了一些简单的事情,比如为 Mac 重新启动 Visual Studio,或者从我的设备中删除应用程序和 clean/rebuild 解决方案,但这些事情似乎没有帮助。

在终止描述中,它听起来像是试图加载单声道,但 mmap 以某种方式被代码签名阻止了 - 但我真的不明白如何。该应用程序已构建并部署到我的设备上,因此代码签名似乎正在运行。

进一步挖掘后,我发现了几个看起来相似的问题示例,最常见的方法因素似乎是签名证书配置不正确。我仍然对根本原因感到好奇 - 为什么背后的 "why"。

最后,我发现我在 "System" "login" 钥匙链上都有 "Apple Worldwide Developer Relations Certificate Authority",并且配置了对于 "Always Trust",当它应该只在我的 "login" 钥匙串中并配置为 "System Defaults".

纠正这些问题后,我再次尝试,但问题仍然存在。重启我的 mac.

后它终于消失了