移动 Swift iOS 应用程序以支持 Apple TV 作为新目标

Moving Swift iOS app to support Apple TV as a new Target

也许有人可以提供帮助,我正在尝试移动我的应用程序以促进 Apple TV 的新目标。 我创建了新的 Storyboard 并以与 iOS 应用程序中相同的方式链接所有内容。当我尝试启动应用程序时,在执行 AppDelegate 之后(在进入初始控制器的 viewDidLoad 之前。

有什么想法吗?

 2015-09-19 12:24:44.629 App TV[46733:3797033] *** Terminating app due to uncaught exception 'CALayerInvalid', reason: 'layer <CATransformLayer: 0x7fc1e0d51fc0> is a part of cycle in its layer tree'
    *** First throw call stack:
    (
    0   CoreFoundation                      0x000000010e850105 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010f271deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e85003d +[NSException raise:format:] + 205
    3   QuartzCore                          0x0000000111d2f74a _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 102
    4   QuartzCore                          0x0000000111d2f795 _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 177
    5   QuartzCore                          0x0000000111d2f795 _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 177
    6   QuartzCore                          0x0000000111d2f795 _ZN2CA5Layer30ensure_transaction_recursivelyEPNS_11TransactionE + 177
    7   QuartzCore                          0x0000000111d37439 _ZN2CA5Layer15insert_sublayerEPNS_11TransactionEP7CALayerm + 389
    8   QuartzCore                          0x0000000111d3782a -[CALayer addSublayer:] + 193
    9   UIKit                               0x000000010d2ce424 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1512
    10  UIKit                               0x000000010d5b1b56 -[UIButton initWithCoder:] + 1424
    11  UIKit                               0x000000010d79dd62 UINibDecoderDecodeObjectForValue + 705
    12  UIKit                               0x000000010d79da98 -[UINibDecoder decodeObjectForKey:] + 278
    13  UIKit                               0x000000010d5d1315 -[UIRuntimeConnection initWithCoder:] + 134
    14  UIKit                               0x000000010d5d1a77 -[UIRuntimeEventConnection initWithCoder:] + 60
    15  UIKit                               0x000000010d79dd62 UINibDecoderDecodeObjectForValue + 705
    16  UIKit                               0x000000010d79df23 UINibDecoderDecodeObjectForValue + 1154
    17  UIKit                               0x000000010d79da98 -[UINibDecoder decodeObjectForKey:] + 278
    18  UIKit                               0x000000010d5d0555 -[UINib instantiateWithOwner:options:] + 1255
    19  UIKit                               0x000000010d3ad7f2 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
    20  UIKit                               0x000000010d3ae11e -[UIViewController loadView] + 178
    21  UIKit                               0x000000010d3ae47d -[UIViewController loadViewIfRequired] + 139
    22  UIKit                               0x000000010d3aec7e -[UIViewController view] + 27
    23  UIKit                               0x000000010d289484 -[UIWindow addRootViewControllerViewIfPossible] + 61
    24  UIKit                               0x000000010d289b81 -[UIWindow _setHidden:forced:] + 302
    25  UIKit                               0x000000010d29b558 -[UIWindow makeKeyAndVisible] + 43
    26  UIKit                               0x000000010d216063 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
    27  UIKit                               0x000000010d21c5a8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1755
    28  UIKit                               0x000000010d219783 -[UIApplication workspaceDidEndTransaction:] + 188
    29  FrontBoardServices                  0x000000011097b7ac -[FBSSerialQueue _performNext] + 192
    30  FrontBoardServices                  0x000000011097bb1a -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    31  CoreFoundation                      0x000000010e77c1b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    32  CoreFoundation                      0x000000010e7720dc __CFRunLoopDoSources0 + 556
    33  CoreFoundation                      0x000000010e771593 __CFRunLoopRun + 867
    34  CoreFoundation                      0x000000010e770fa8 CFRunLoopRunSpecific + 488
    35  UIKit                               0x000000010d2190d5 -[UIApplication _run] + 402
    36  UIKit                               0x000000010d21de09 UIApplicationMain + 171
    37  App TV                  0x000000010d0b8fdd main + 109
    38  libdyld.dylib                       0x00000001149699e9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

您可以通过激活异常断点来通知异常发生的位置,然后您将能够看到发生了什么。

您可以通过 Xcode 上的断点导航器,然后点击左下角的加号按钮来完成此操作。

有趣的事情发生了,显然新的 Apple TV(第 4 代/tvOS v9.0)无法处理按钮上的 'Word Wrap',将其设置为 'Truncate Middle' 后它启动正常。可能是测试版中的问题。

在 Xcode 7.2 上,我遇到了同样的错误,原因是将按钮上的换行符设置为 'Character Wrap'。更改为 'Truncate Middle' 停止了崩溃。