【问题标题】:WatchOS not listed in run destination in Xcode 7WatchOS 未在 Xcode 7 的运行目标中列出
【发布时间】:2015-12-23 12:56:19
【问题描述】:

我按照本教程 (http://code.tutsplus.com/tutorials/create-a-native-apple-watch-app-for-watchos-2--cms-24201) 创建了一个演示 watchOS 2 应用程序。我无法让它在模拟器中运行,因为 watchOS 模拟器未列在运行目标中。

在本教程中,运行目标会显示在其他地方:

我已经用尽了所有可以在 Internet 上找到的可能的解决方案。

我错过了什么?或者,是 Xcode 的问题吗?

我在 OS X 10.10.5 上运行 Xcode 7 (7A220)。

谢谢。

更新:

检查日志,CoreSimulator 似乎无法与设备建立连接。

这里是system.log:

Sep 26 00:37:04 Chertan kernel[0]: memorystatus_thread: idle exiting pid 4789 [com.apple.CoreSi]
Sep 26 00:37:04 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: com.apple.CoreSimulator.CoreSimulatorService 179~1 starting.
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/26A5557E-A18E-463D-A983-2D97A2C5826A/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/36049C9F-D5B2-454D-80C7-14BC8C0BBC5F/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/42A77066-16B7-4393-A705-293ACAA30912/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/50BAB20D-DF79-4728-800C-6A989333A600/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/680A57B1-A08C-43C6-878F-0C9DD05584C0/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/7CB45BED-2A19-48E3-9EC7-827FFFB8B5E1/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/ABDD6B28-7831-4576-B704-A1FE57F4559C/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/BEC6C8F1-DB9F-4348-A0ED-01642077570D/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/C2725678-5BC4-4D1B-9630-37162685DBA8/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/C85E5433-0176-4091-B27E-9FEA89C6439C/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/ED850CEF-AD0E-4808-8425-8597DB197249/device.plist
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 --- last message repeated 5 times ---
Sep 26 00:37:05 Chertan.local com.apple.CoreSimulator.CoreSimulatorService[4817]: Notification is missing xpc_notification key: {
        notification = "availableDevices_changed";
    }

还有CoreSimulator.log:

Sep 26 00:37:04 Chertan.local CoreSimulatorService[4817] <Notice>: com.apple.CoreSimulator.CoreSimulatorService 179~1 starting.
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/26A5557E-A18E-463D-A983-2D97A2C5826A/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/36049C9F-D5B2-454D-80C7-14BC8C0BBC5F/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/42A77066-16B7-4393-A705-293ACAA30912/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/50BAB20D-DF79-4728-800C-6A989333A600/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/680A57B1-A08C-43C6-878F-0C9DD05584C0/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/7CB45BED-2A19-48E3-9EC7-827FFFB8B5E1/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/ABDD6B28-7831-4576-B704-A1FE57F4559C/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/BEC6C8F1-DB9F-4348-A0ED-01642077570D/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/C2725678-5BC4-4D1B-9630-37162685DBA8/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/C85E5433-0176-4091-B27E-9FEA89C6439C/device.plist
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/ED850CEF-AD0E-4808-8425-8597DB197249/device.plist
Sep 26 00:37:05 Chertan.local com.apple.dt.Xcode[3447] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 Chertan.local com.apple.ibtool[4661] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 Chertan.local com.apple.ibtool[4656] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 Chertan.local com.apple.ibtool[4661] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 Chertan.local com.apple.ibtool[4656] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 Chertan.local com.apple.iphonesimulator[4688] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:05 Chertan.local CoreSimulatorService[4817] <Warning>: Notification is missing xpc_notification key: {
        notification = "availableDevices_changed";
    }
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Notice>: com.apple.CoreSimulator.CoreSimulatorService 179~1 starting.
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/26A5557E-A18E-463D-A983-2D97A2C5826A/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/36049C9F-D5B2-454D-80C7-14BC8C0BBC5F/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/42A77066-16B7-4393-A705-293ACAA30912/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/50BAB20D-DF79-4728-800C-6A989333A600/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Notice>: SimDevice : iPhone 6 (52D0F6E4-1431-4181-9CA8-C28F2BDFB640) : state={ Booted } deviceType={ SimDeviceType : com.apple.CoreSimulator.SimDeviceType.iPhone-6 } runtime={ SimRuntime : 9.0 (13A340) - com.apple.CoreSimulator.SimRuntime.iOS-9-0 } found in an inconsistent state: Loaded: 0 Running: 0 ... shutting down
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/680A57B1-A08C-43C6-878F-0C9DD05584C0/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/7CB45BED-2A19-48E3-9EC7-827FFFB8B5E1/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/ABDD6B28-7831-4576-B704-A1FE57F4559C/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/BEC6C8F1-DB9F-4348-A0ED-01642077570D/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/C2725678-5BC4-4D1B-9630-37162685DBA8/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/C85E5433-0176-4091-B27E-9FEA89C6439C/device.plist
Sep 26 00:37:32 Chertan.local CoreSimulatorService[4831] <Error>: Unable to load device.plist: /Users/adrian/Library/Developer/CoreSimulator/Devices/ED850CEF-AD0E-4808-8425-8597DB197249/device.plist
Sep 26 00:37:32 Chertan.local com.apple.ibtool[4656] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:32 Chertan.local com.apple.dt.Xcode[3447] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:32 Chertan.local com.apple.ibtool[4656] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:32 Chertan.local com.apple.ibtool[4661] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.
Sep 26 00:37:32 Chertan.local com.apple.ibtool[4661] <Warning>: CoreSimulatorService connection interrupted.  Resubscribing to notifications.

【问题讨论】:

    标签: ios-simulator ios9 xcode7 watchos-2


    【解决方案1】:

    我使用终端命令 xcrun simctl 解决了这个问题。这是输出:

    $ xcrun simctl list
    
    == Device Types ==
    iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
    iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
    iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
    iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
    iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
    iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
    iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
    iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
    iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
    iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
    iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
    Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
    Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
    == Runtimes ==
    iOS 9.0 (9.0 - 13A340) (com.apple.CoreSimulator.SimRuntime.iOS-9-0)
    watchOS 2.0 (2.0 - 13S343) (com.apple.CoreSimulator.SimRuntime.watchOS-2-0)
    == Devices ==
    -- iOS 9.0 --
        iPhone 6 (21272670-640D-436E-8DD4-F4014D2F63DC) (Booted)
    -- watchOS 2.0 --
    == Device Pairs ==
    

    由于某些我不知道的原因,Xcode 7 和 Simulator 无法正确识别和设置 watchOS 2.0 设备。

    $ xcrun simctl create "Apple Watch 38mm" com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm com.apple.CoreSimulator.SimRuntime.watchOS-2-0
    

    输出:

    EF648CAD-2C4B-4BD5-9C36-9D1DB3E3CD29
    

    那么,

    $ xcrun simctl boot EF648CAD-2C4B-4BD5-9C36-9D1DB3E3CD29
    
    $ xcrun simctl pair EF648CAD-2C4B-4BD5-9C36-9D1DB3E3CD29 21272670-640D-436E-8DD4-F4014D2F63DC
    

    这创建了一个新的配对设备 ID:

    AA86202A-A141-40AD-B3A6-61F755C39534
    
    $ xcrun simctl list
    == Device Types ==
    iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
    iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
    iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
    iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
    iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
    iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
    iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
    iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
    iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
    iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
    iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
    Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
    Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
    == Runtimes ==
    iOS 9.0 (9.0 - 13A340) (com.apple.CoreSimulator.SimRuntime.iOS-9-0)
    watchOS 2.0 (2.0 - 13S343) (com.apple.CoreSimulator.SimRuntime.watchOS-2-0)
    == Devices ==
    -- iOS 9.0 --
        iPhone 6 (21272670-640D-436E-8DD4-F4014D2F63DC) (Booted)
    -- watchOS 2.0 --
        Apple Watch 38mm (EF648CAD-2C4B-4BD5-9C36-9D1DB3E3CD29) (Booted)
    == Device Pairs ==
    AA86202A-A141-40AD-B3A6-61F755C39534 (connected)
        Watch: Apple Watch 38mm (EF648CAD-2C4B-4BD5-9C36-9D1DB3E3CD29) (Booted)
        Phone: iPhone 6 (21272670-640D-436E-8DD4-F4014D2F63DC) (Booted)
    

    现在,我已经创建了一个设备对并进行了连接。返回 Xcode,我在运行目标中列出了配对设备:

    【讨论】:

    • 在开始运行应用程序之前,请退出 Xcode 和所有模拟器并使用 simctl 命令关闭设备。关闭所有设备后,启动您的 Xcode 并运行您的应用程序。
    【解决方案2】:

    这通常表示 Xcode.app 无法与 CoreSimulatorService 通信。在 Xcode 6.x 中存在很多问题。在 7.0 中进行了改进,但在某些情况下您可能会遇到问题。

    如果你有这样的问题,最简单的方法是使用大锤并重新启动。

    1. 不要重命名 Xcode.app,因为这是进入此状态的主要原因。
    2. 如果您确实重命名了 Xcode.app,请重新启动以进入干净状态。

    如果重启后仍有问题,可能会提示 ~/Library/Logs/CoreSimulator/CoreSimulator.log 和 /var/log/system.log 中出了什么问题。

    【讨论】:

    • 检查了日志,CoreSimulator 似乎无法与设备建立连接。
    • 请用您怀疑的确切日志行更新您的问题。
    • 我没有重命名 Xcode.app 并多次重新启动 OS X,这也无济于事。我清除了 CoreSimulator 中的日志和设备并准备好它们,但仍然无法正常工作。
    • Sep 26 11:06:46 Chertan location[5486]:删除 /Users/adrian/Library/Developer/CoreSimulator/Devices/21272670-640D-436E-8DD4-F4014D2F63DC/data/Library/Caches /locationd/glgps_nvs.bin 如果存在 Sep 26 11:07:18 Chertan partnerappd[5480]: (Error) WatchKit: __67 -[SPTransport service:account:identifier:didSendWithSuccess:error:]_block_invoke 标识符 (36967883-123B-443A-8F71-BF2CD2B23D4F), serviceName ((null)), success: 0 error, domain: com.apple.identityservices.error,代码:23
    • 9 月 26 日 11:07:18 Chertan companionappd[5480]:(注)WatchKit:在安装程序队列中运行 __96-[SPCompanionAppInstaller sendInstallationDataWithPath:dataType:name:info:installer:completion:]_block_invoke_2会话 1 Sep 26 11:07:18 Chertan companionappd[5480]:(注意)WatchKit:在会话 1 的安装程序队列中运行 __96-[SPCompanionAppInstaller sendInstallationDataWithPath:dataType:name:info:installer:completion:]_block_invoke337
    猜你喜欢
    • 2018-08-17
    • 2015-11-15
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 2015-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多