我正在开发 Xamarin.Forms 应用。我可以在 iPhone X 中部署和启动该应用程序,但该应用程序在 iPhone 12 Pro Max 中崩溃。两款 iPhone 均搭载 iOS 14.7。
我使用的是 Microsoft Visual Studio Professional 2019 版本 16.10.4 和 Xamarin.Forms 5.0.0.2083。
这是输出窗口的内容,带有原生报告。你知道发生了什么吗?
2021-07-28 09:01:34.162 Xamarin.PreBuilt.iOS[6171:3005548] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 6
2021-07-28 09:01:34.165 Xamarin.PreBuilt.iOS[6171:3005548] Xamarin.iOS: Processing: 'start profiler: no'
2021-07-28 09:01:34.165 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Profiler not loaded (disabled)
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.iOS.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/System.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Mono.Security.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS.exe [External]
Thread started: #2
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS.Library.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/netstandard.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/System.Core.dll [External]
2021-07-28 09:01:34.402 Xamarin.PreBuilt.iOS[6171:3005529] Content folder: /var/mobile/Containers/Data/Application/FBF79CC9-237C-400B-AFA4-619FA7E20CCC/Documents/MyApp.iOS.content
Thread started: #3
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
2021-07-28 09:01:34.653 Xamarin.PreBuilt.iOS[6171:3005529] Forms app path /var/mobile/Containers/Data/Application/FBF79CC9-237C-400B-AFA4-619FA7E20CCC/Documents/MyApp.iOS.content/MyApp.iOS.exe
2021-07-28 09:01:34.654 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Unable to locate assembly 'Xamarin.Forms.Platform.iOS' (culture: '')
2021-07-28 09:01:34.654 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Unable to locate assembly 'Xamarin.Forms.Platform.iOS' (culture: '')
2021-07-28 09:01:34.654 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Unable to locate assembly 'Xamarin.Forms.Core' (culture: '')
2021-07-28 09:01:34.655 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Unable to locate assembly 'Xamarin.Forms.Core' (culture: '')
Loaded assembly: /private/var/mobile/Containers/Data/Application/FBF79CC9-237C-400B-AFA4-619FA7E20CCC/Documents/MyApp.iOS.content/MyApp.iOS.exe
2021-07-28 09:01:34.656 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Unable to locate assembly 'MyApp' (culture: '')
2021-07-28 09:01:34.656 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.iOS: Unable to locate assembly 'MyApp' (culture: '')
Loaded assembly: /private/var/mobile/Containers/Data/Application/FBF79CC9-237C-400B-AFA4-619FA7E20CCC/Documents/MyApp.iOS.content/Xamarin.Forms.Platform.iOS.dll [External]
Loaded assembly: /private/var/mobile/Containers/Data/Application/FBF79CC9-237C-400B-AFA4-619FA7E20CCC/Documents/MyApp.iOS.content/Xamarin.Forms.Core.dll [External]
Loaded assembly: /private/var/mobile/Containers/Data/Application/FBF79CC9-237C-400B-AFA4-619FA7E20CCC/Documents/MyApp.iOS.content/MyApp.dll
2021-07-28 09:01:34.682 Xamarin.PreBuilt.iOS[6171:3005529] Xamarin.Forms AppDelegate name: AppDelegate
=================================================================
Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Native stacktrace:
=================================================================
0x10037c120 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_dump_native_crash_info
0x100372cbc - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_handle_native_crash
0x10037fa60 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_sigsegv_signal_handler_debug
0x1ee4e029c - /usr/lib/system/libsystem_platform.dylib : <redacted>
0x1a239b5ec - /usr/lib/system/libdyld.dylib : <redacted>
0x1a238b008 - /usr/lib/system/libdyld.dylib : <redacted>
0x1a239b418 - /usr/lib/system/libdyld.dylib : <redacted>
0x1a238b948 - /usr/lib/system/libdyld.dylib : <redacted>
0x1a239bf30 - /usr/lib/system/libdyld.dylib : <redacted>
0x1a239b9c0 - /usr/lib/system/libdyld.dylib : <redacted>
0x1a239d928 - /usr/lib/system/libdyld.dylib : <redacted>
0x1a238eecc - /usr/lib/system/libdyld.dylib : <redacted>
0x100528970 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : do_icall
0x100527010 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : do_icall_wrapper
0x10051da8c - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : interp_exec_method_full
0x10051beb0 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E89227
89cf8 - /usr/lib/system/libdyld.dylib : <redacted>
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x10671b3a0):0x10671b390 e2 59 00 10 1f 20 03 d5 1c 07 00 94 e7 ff ff 17 .Y... ..........
0x10671b3a0 ff c3 00 d1 fd 7b 02 a9 fd 83 00 91 a0 ff ff 10 .....{..........
0x10671b3b0 1f 20 03 d5 e1 03 00 91 1a 07 00 94 a0 01 00 34 . .............4
0x10671b3c0 e8 07 40 f9 08 0d 40 b9 1f 09 00 71 1f 20 03 d5 ..@...@....q. ..
=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at ObjCRuntime.Dlfcn:_dlopen <0x00026>
at ObjCRuntime.Dlfcn:dlopen <0x00010>
at Xamarin.PreBuilt.iOS.Applications:LoadFrameworks <0x0009e>
at Xamarin.PreBuilt.iOS.Applications:Main <0x00202>
at <Module>:runtime_invoke_direct_void_string[] <
0x00092>
=================================================================
9/MyApp.iOS.app/Xamarin.PreBuilt.iOS : interp_runtime_invoke
0x100382d3c - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_jit_runtime_invoke
0x1004312c0 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_runtime_invoke_checked
0x100436564 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_runtime_exec_main_checked
0x1003678f4 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : mono_jit_exec
0x100519984 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : xamarin_main
0x10032fc34 - /private/var/containers/Bundle/Application/3B617F18-EB5B-40B3-96D4-18688E892279/MyApp.iOS.app/Xamarin.PreBuilt.iOS : main
0x1a23
The app has been terminated.
编辑 1:
添加有关评论问题的更多详细信息。我正在使用配对的 Mac 并使用 USB 数据线连接到 iPhone。
1) 关闭手机,然后重新打开。 之后我可以将应用程序部署到,但调试器断开连接(再次启用运行按钮),所以我不能在输出窗口中调试或读取日志。
2) 从手机上手动卸载(删除)应用程序。 经过测试 1) 和 2) 结果相同:调试器断开连接。
3) 这是调试版还是发布版?请显示您设置的构建选项。我正在调试:
4) 如果您在选择 iPhone 12 Pro Max 的 iPhone 模拟器上运行应用程序,会发生什么? 使用 iPhone 14 Pro Max iOS 14.5 模拟器我收到关于库的错误(日志中的 MyLibrary) :
Native linking failed. Please review the build log. MyApp.iOS
warning: ignoring file /Users/macuser/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/16c7bc9b0e8af1f53dbbdd4467006ec97d5efb9ff993c29d61d5200ba9ab2640/obj/iPhoneSimulator/Debug/mtouch-cache/Curve25519.framework/Curve25519, building for iOS Simulator-x86_64 but attempting to link with file built for iOS-arm64 MyApp.iOS
Native linking failed, undefined Objective-C class: SwiftFrameworkProxy. The symbol '_OBJC_CLASS_$_SwiftFrameworkProxy' could not be found in any of the libraries or frameworks linked with your application. MyApp.iOS
warning: ignoring file /Users/macuser/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/16c7bc9b0e8af1f53dbbdd4467006ec97d5efb9ff993c29d61d5200ba9ab2640/obj/iPhoneSimulator/Debug/mtouch-cache/SwiftFrameworkProxy.framework/SwiftFrameworkProxy, building for iOS Simulator-x86_64 but attempting to link with file built for iOS-arm64 MyApp.iOS
warning: ignoring file /Users/macuser/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/16c7bc9b0e8af1f53dbbdd4467006ec97d5efb9ff993c29d61d5200ba9ab2640/obj/iPhoneSimulator/Debug/mtouch-cache/SwiftProtobuf.framework/SwiftProtobuf, building for iOS Simulator-x86_64 but attempting to link with file built for iOS-arm64 MyApp.iOS
warning: ignoring file /Users/macuser/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/16c7bc9b0e8af1f53dbbdd4467006ec97d5efb9ff993c29d61d5200ba9ab2640/obj/iPhoneSimulator/Debug/mtouch-cache/MyLibrary.framework/MyLibrary, building for iOS Simulator-x86_64 but attempting to link with file built for iOS-arm64 MyApp.iOS
linker command failed with exit code 1 (use -v to see invocation) MyApp.iOS
5) 您构建的 Mac 上的 XCode 是否是最新版本? Xcode 版本 12.5.1 (12E507),当前的最新版本。