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

标签 ios xamarin.ios mono visual-studio-mac

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

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

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

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

我使用 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,不幸的是)似乎没有很多直接的答案。我已经尝试了一些简单的操作,例如重新启动 Visual Studio for Mac,或者从我的设备中删除应用程序并清理/重建解决方案,但这些操作似乎没有帮助。

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

最佳答案

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

最后,我发现我在“系统”“登录” key 链上都有“Apple 全局开发者关系证书颁发机构”,并且配置为“始终信任”,当它应该只在我的“登录”钥匙串(keychain)中并配置为“系统默认值”时。

纠正这些问题后,我再次尝试,但问题仍然存在。重启我的 mac 后它终于消失了。

关于ios - Xamarin.iOS 应用程序因缺少 Mono 运行时而崩溃;没有找到合适的图片;代码签名阻止了 mmap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47488669/

相关文章:

ios - Xcode:应用程序图标始终位于项目根目录中

ios - 通过 CocoaPods 安装 Facebook iOS SDK

c# - 使用 Monotouch 更改 UISearchBar 上 “Cancel” 按钮的文本?

android studio : linux, windows,性能不佳

php - 邀请 Facebook 好友使用来自 Objective C 或 PHP 的应用程序

ios - 重力Cocos2D?

.net - 单声道 - 在 'Sub Main' 中找不到 ''

mono - 使用 Mono 创建计算机 ID

xcode - 尝试存档以发布 Xamarin.Forms.iOS 时出现未知错误

c# - 如何在 MonoTouch 中绑定(bind)这些?