设备上的 Xcode 11 实时预览失败,但应用程序运行正常

Dra*_*rok 5 xcode ios

我想在真实设备上预览我的视图,但是当我单击按钮时 Xcode 失败:

无法在此文件中预览 - 发生意外错误

单击“诊断”按钮显示以下错误:

UVIntegration.ConcreteHardwareDevice.(unknown context at $13f0b5314).(unknown context at $13f0b531c).InstallError.failedToInstall(Error Domain=com.apple.dtdevicekit Code=-402620394 "Unable to install "AppName"" UserInfo={NSLocalizedDescription=Unable to install "AppName", NSUnderlyingError=0x7fe0360a1c50 {Error Domain=com.apple.dtdevicekit Code=-402620394 "The executable was signed with invalid entitlements." UserInfo={NSLocalizedFailureReason=The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016)., com.apple.dtdevicekit.stacktrace=(

----------------------------------------

GenericHumanReadableError: unexpected error occurred

failedToInstall(Error Domain=com.apple.dtdevicekit Code=-402620394 "Unable to install "AppName"" UserInfo={NSLocalizedDescription=Unable to install "AppName", NSUnderlyingError=0x7fe0360a1c50 {Error Domain=com.apple.dtdevicekit Code=-402620394 "The executable was signed with invalid entitlements." UserInfo={NSLocalizedFailureReason=The entitlements specified in your application’s Code Signing Entitlements file are invalid, not permitted, or do not match those specified in your provisioning profile. (0xE8008016)., com.apple.dtdevicekit.stacktrace=(
    0   DTDeviceKitBase                     0x00000001217c66e7 DTDKCreateNSError + 109
    1   DTDeviceKitBase                     0x00000001217c6de9 DTDK_AMDErrorToNSError + 792
    2   DTDeviceKitBase                     0x000000012180656a __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 164
    3   DVTFoundation                       0x0000000106e95c12 DVTInvokeWithStrongOwnership + 73
    4   DTDeviceKitBase                     0x0000000121806301 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1589
    5   IDEiOSSupportCore                   0x000000012168ea25 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.352 + 4523
    6   DVTFoundation                       0x0000000106fc6e7a __DVT_CALLING_CLIENT_BLOCK__ + 7
    7   DVTFoundation                       0x0000000106fc8552 __DVTDispatchAsync_block_invoke + 809
    8   libdispatch.dylib                   0x00007fff72809583 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x00007fff7280a50e _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x00007fff7280face _dispatch_lane_serial_drain + 597
    11  libdispatch.dylib                   0x00007fff72810452 _dispatch_lane_invoke + 363
    12  libdispatch.dylib                   0x00007fff72819a9e _dispatch_workloop_worker_thread + 598
    13  libsystem_pthread.dylib             0x00007fff72a6371b _pthread_wqthread + 290
    14  libsystem_pthread.dylib             0x00007fff72a6357b start_wqthread + 15
), DVTRadarComponentKey=487927, NSLocalizedDescription=The executable was signed with invalid entitlements.}}})
Run Code Online (Sandbox Code Playgroud)

以上表明我的配置设置是错误的,但是如果我单击“运行”按钮,则该应用程序已部署并在我的设备上运行得非常好。

我究竟做错了什么?

Dra*_*rok 1

我终于成功了!

虽然应用程序捆绑包中的所有内容都是正确的(这就是应用程序在设备上运行得绝对正常的原因),但 Tests 和 UITests 捆绑包选择了错误的团队进行签名,在我更改这些团队后,我收到错误消息,指出捆绑包 ID 为我的测试包无法注册到我们的团队。我更改了捆绑包 ID,现在我可以在设备上预览我的应用程序了!