一旦与 Xcode 断开连接,应用程序将不会 运行

App wont run once disconnected from Xcode

我的应用程序在连接到 Xcode 时运行正常。 (我使用的是 Xcode 10.1) 但是,一旦我断开设备并再次启动应用程序(通过点击图标),启动画面就会出现并且应用程序会关闭。这不是真正的崩溃,因为应用程序在有线连接时工作正常。我还在我的应用程序中集成了 Crashlytics,并且它的仪表板上也没有崩溃。

我尝试过的事情:

  1. 清理并构建代码。
  2. 重启设备。
  3. 转到 window -> 设备和模拟器并尝试检查设备 日志(如 所建议的那样),但我在那里没有找到任何东西。

日志如下:

Date/Time: 2018-12-07 12:36:24 +0500 End time: 2018-12-07 12:36:26 +0500 OS Version: iPhone OS 12.0.1 (Build 16A404) Architecture: arm64 Report Version: 27 Incident Identifier: 4DAE256F-7C3C-4CF5-A670-BD0FA2498CA5

Data Source: Microstackshots Shared Cache: 0x8fe0000 5D8B6846-4668-3CAC-9CC4-4A762D54BE9E

Command: Cuufy Path:
/private/var/containers/Bundle/Application/EDAA1D65-BB6F-4722-8619-FDFED10DC045/Cuufy.app/Cuufy Identifier: com.cuufyLLC.cuufy Version: 1.3 (1) Beta Identifier: A032A60E-406C-442D-836A-80540F61ADCA PID: 2478

Event: wakeups Action taken: none Wakeups: 45001 wakeups over the last 141 seconds (318 wakeups per second average), exceeding limit of 150 wakeups per second over 300 seconds Wakeups limit: 45000 Limit duration: 300s Wakeups caused: 45001 Duration: 1.99s Steps: 3

Hardware model: iPhone9,1 Active cpus: 2 Boot args:

Heaviest stack for the target process: 3 ??? (libsystem_pthread.dylib + 49392) [0x189ad20f0] 3 ??? (libdispatch.dylib + 73472) [0x1898a0f00] 3 ??? (libdispatch.dylib + 38752) [0x189898760] 3 ??? (libdispatch.dylib + 35864) [0x189897c18] 3 ??? (libdispatch.dylib + 398468) [0x1898f0484] 3 ??? (libdispatch.dylib + 394952) [0x1898ef6c8] 3 ??? (<38F5549F-536E-3252-B54B-8CA43AD79EB0> + 59736) [0x101a6e958] 2 ??? (<38F5549F-536E-3252-B54B-8CA43AD79EB0> + 61980) [0x101a6f21c] 2 ??? (libsystem_c.dylib + 480420) [0x1899c24a4] 1 ??? (libsystem_kernel.dylib + 144424) [0x189a4d428]

Powerstats for: Cuufy [2478] UUID:
907E938F-A407-382A-BFE9-BB62948993A1 Path:
/private/var/containers/Bundle/Application/EDAA1D65-BB6F-4722-8619-FDFED10DC045/Cuufy.app/Cuufy Architecture: arm64 Parent: UNKNOWN [1] UID:
501 Footprint: 202.73 MB Start time: 2018-12-07 12:36:24 +0500 End time: 2018-12-07 12:36:26 +0500 Num samples: 3 (100%) CPU Time: 1.501s Primary state: 2 samples Frontmost App, Non-Suppressed, User mode, Effective Thread QoS User Initiated, Requested Thread QoS User Initiated, Override Thread QoS Unspecified User Activity: 0 samples Idle, 0 samples Active, 3 samples Unknown Power Source: 0 samples on Battery, 0 samples on AC, 3 samples Unknown 3 _pthread_wqthread + 311 (libsystem_pthread.dylib + 49392) [0x189ad20f0] 3 _dispatch_workloop_worker_thread + 599 (libdispatch.dylib + 73472) [0x1898a0f00] 3 _dispatch_lane_invoke$VARIANT$mp + 431 (libdispatch.dylib + 38752) [0x189898760] 3 _dispatch_lane_serial_drain$VARIANT$mp + 591 (libdispatch.dylib + 35864) [0x189897c18] 3 _dispatch_client_callout + 15 (libdispatch.dylib + 398468) [0x1898f0484] 3 _dispatch_call_block_and_release + 23 (libdispatch.dylib + 394952) [0x1898ef6c8] 3 thunk for @escaping @callee_guaranteed -> () (WebSocket.swift:0) (WebSocket.swift:0 in Starscream + 59736) [0x101a6e958] 2 closure #1 in FoundationStream.connect (WebSocket.swift:209) (WebSocket.swift:209 in Starscream + 61980) [0x101a6f21c] 2 usleep + 63 (libsystem_c.dylib + 480420) [0x1899c24a4] 1 __semwait_signal + 8 (libsystem_kernel.dylib + 144424) [0x189a4d428] 1 1 nanosleep + 211 (libsystem_c.dylib + 480720) [0x1899c25d0] 1 __semwait_signal + 23 (libsystem_kernel.dylib + 144440) [0x189a4d438] 1 _pthread_exit_if_canceled + 0 (libsystem_pthread.dylib + 52556) [0x189ad2d4c] 1 closure #1 in FoundationStream.connect (WebSocket.swift:216) (WebSocket.swift:216 in Starscream + 62020) [0x101a6f244] 1 CFWriteStreamCopyError + 0 (CoreFoundation + 772364) [0x189e5690c]

Binary Images: 0x100524000 - ??? Cuufy <907E938F-A407-382A-BFE9-BB62948993A1> /private/var/containers/Bundle/Application/EDAA1D65-BB6F-4722-8619-FDFED10DC045/Cuufy.app/Cuufy 0x101a60000 - ??? ??? <38F5549F-536E-3252-B54B-8CA43AD79EB0> Starscream 0x18988f000 - 0x1898fffff libdispatch.dylib /usr/lib/system/libdispatch.dylib 0x18994d000 - 0x1899cbfff libsystem_c.dylib <40DD5C3B-586A-38EB-9F52-74D994ECD9D2> /usr/lib/system/libsystem_c.dylib 0x189a2a000 - 0x189a54fff libsystem_kernel.dylib <982CCBAD-717D-3A28-946E-BA07918897A3> /usr/lib/system/libsystem_kernel.dylib 0x189ac6000 - 0x189ad6fff libsystem_pthread.dylib /usr/lib/system/libsystem_pthread.dylib 0x189d9a000 - 0x18a0fffff CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation

我认为这与 Starscream Websocket 库的使用and/or 设备的网络连接有关。

虽然设备在模拟器中是 运行,但它使用您的 Mac(Book/Pro/etc) 的网络连接;当它自己是 运行 时,它使用设备的 wifi/cellular 连接。

因此,我认为由于设备连接,您将面临一些高延迟。

  • 检查网络连接
  • 尝试禁用(评论)Starscrem 用法并检查应用程序是否正在启动
  • 检查 UI 在显示任何内容之前是否正在等待网络数据

在启动画面的代码中,我试图访问方案集的环境变量,我在这些方案的基础上设置了一些视图。当设备用电线连接时这些变量是可访问的,但当设备未连接时返回 nil (如果有人能解决这个问题,我将不胜感激) 因此,为了解决这个问题,我删除了方案并改为创建目标,设置自定义标志(以我之前使用环境变量所做的工作为基础),然后按照 this 问题的第二个答案中所述访问它们。