xcpretty / xcode-install

🔽 Install and update your Xcodes
https://fastlane.tools
MIT License
2.59k stars 243 forks source link

After upgrade to Sierra, simulator is wrongly displayed in `xcversion simulator` #196

Open bartoszkosiorek opened 7 years ago

bartoszkosiorek commented 7 years ago

Hi. I upgraded one machine from Continous Integration system from Yosemite (with iOS Simulator 8.1) to Sierra, and install Xcode 8.2.1 with command: $ /usr/local/bin/xcversion install "8.2.1"

Next I would like to have installed Xcode in default location, as it is done with Apple Store.

  1. I'm removing symbolic link $ rm -rf /Applications/Xcode.app

  2. And moving Xcode to desired location:

    $ cd /Applications
    $ mv -f Xcode-8.2.1.app Xcode.app
    $ xcode-select -s /Applications/Xcode.app

After that Xcode is working perfectly fine. Previous "iOS SImulator 8.1" was replaced with "iOS SImulator 10.2" (see screenshot in attachment) screen shot 2017-01-17 at 17 25 09

I could check that the 10.2 simulator is installed with command:

$ xcrun instruments -s devices
Known Devices:
plsrvmp-qbs01 [911534F1-5B7E-589F-B418-F944FC935E3A]
Apple TV 1080p (10.1) [DAC5163F-52BF-4DD5-B58D-CBCDAEB44017] (Simulator)
Apple Watch - 38mm (3.1) [B63F6DED-7501-4922-B20F-AD4706D61D0C] (Simulator)
Apple Watch - 42mm (3.1) [F06805A5-9032-42D2-95F7-241AB17AEE55] (Simulator)
iPad Air (10.2) [74969546-1815-42EC-A5FD-19F55230F199] (Simulator)
iPad Air 2 (10.2) [CC4A4E0E-6A33-41CC-AAFE-344224799C73] (Simulator)
iPad Pro (12.9 inch) (10.2) [689AE031-178C-49C0-8341-B007FC3AEF70] (Simulator)
iPad Pro (9.7 inch) (10.2) [671C8274-DD4F-4F06-B634-F6A1A21B3CA5] (Simulator)
iPad Retina (10.2) [32DA1C92-F35D-45AA-B3FC-6D3453BE6922] (Simulator)
iPhone 4s (8.1) [E101C3A0-84E8-478B-8B8A-5E37B1D908EF] (Simulator)
iPhone 5 (10.2) [D5867EE6-B4E5-4750-AC1A-6A1C184BABA3] (Simulator)
iPhone 5s (10.2) [998E2536-591D-4BF2-B813-407C0B4B4998] (Simulator)
iPhone 6 (10.2) [9C75D48D-509B-4FE3-8C09-5B3487A01058] (Simulator)
iPhone 6 Plus (10.2) [FBF49C22-ACC0-4066-9225-67F11E7146F5] (Simulator)
iPhone 6s (10.2) [5D2F670A-CC6F-4B81-9CD9-4A03769B88CC] (Simulator)
iPhone 6s Plus (10.2) [259A1F83-3E1D-413A-B24A-C6770C96DCCF] (Simulator)
iPhone 7 (10.2) [3706AF41-A64A-4F3D-8669-EE9D32792855] (Simulator)
iPhone 7 (10.2) + Apple Watch Series 2 - 38mm (3.1) [CB27D504-4629-46E7-BBA3-977191EC7C17] (Simulator)
iPhone 7 Plus (10.2) [C37AC72A-FED1-4A91-805E-1A714085EC59] (Simulator)
iPhone 7 Plus (10.2) + Apple Watch Series 2 - 42mm (3.1) [DD858CA0-8286-4379-A3BB-5D4CFCF1A100] (Simulator)
iPhone SE (10.2) [B5022728-FF65-4C81-9A41-DE56F8B6905B] (Simulator)

Unfortunately diversion simulators is still mention that iOS 8.1 Simulator is installed. Also there is no word about iOS 10.2 Simulator, that it is available and installed:

$ xcversion simulators 
Xcode 8.2.1 (/Applications/Xcode.app)
iOS 8.1 Simulator (installed)
iOS 8.2 Simulator (not installed)
iOS 8.3 Simulator (not installed)
iOS 8.4 Simulator (not installed)
iOS 9.0 Simulator (not installed)
iOS 9.1 Simulator (not installed)
iOS 9.2 Simulator (not installed)
iOS 9.3 Simulator (not installed)
iOS 10.0 Simulator (not installed)
iOS 10.1 Simulator (not installed)
tvOS 9.0 Simulator (not installed)
tvOS 9.1 Simulator (not installed)
tvOS 9.2 Simulator (not installed)
tvOS 10.0 Simulator (not installed)
watchOS 2.0 Simulator (not installed)
watchOS 2.1 Simulator (not installed)
watchOS 2.2 Simulator (not installed)

How I could install iOS 8.1 Simulator with xcversion ?

brentleyjones commented 7 years ago

Currently xcversion simulators is not listing the 10.3 simulators for Xcode 8.3. I assume it's because they either aren't listed at the current download locations, or we need a new URL: https://github.com/KrauseFx/xcode-install/blob/11e949075818c5291c0ac10c354564d3090afada/lib/xcode/install.rb#L471-L479

timsutton commented 7 years ago

I still get the same bplist if I do this:

curl https://devimages-cdn.apple.com/downloads/xcode/simulators/index-8.3.0-DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C.dvtdownloadableindex

Currently the iOS simulator installed? test is done based on whether an InstallPrefix like /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS <foo> exists - but since Xcode 8.3 ships with iOS 10.3's simulator, I'd guess that XcodeInstall doesn't pick up its installed state.

Xcode normally bundles the "current" simulator in the app bundle, and it's previous versions of the simulator which are offered as downloads, and which would be installed into that path at /L/Developer. Xcode therefore doesn't need to offer a download or "check state" for the version of the simulator which is "current" for a given release.

brentleyjones commented 7 years ago

We should find a way to have it list them. I use xcversion simulators and a script to determine if a required simulator is installed for CI. When you run multiple versions of Xcode things get funny.

timsutton commented 7 years ago

I think that in order to include the versions that a given Xcode already ships with, you'll need to then parse the contents of /Applications/Xcode.app/Contents/Developer/Platforms/*Simulator.platform bundles.

timsutton commented 7 years ago

e.g. /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/SDKSettings.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CanonicalName</key>
    <string>appletvsimulator10.2</string>
    <key>CustomProperties</key>
    <dict/>
    <key>DefaultDeploymentTarget</key>
    <string>10.2</string>
    <key>DefaultProperties</key>
    <dict>
        <key>AD_HOC_CODE_SIGNING_ALLOWED</key>
        <string>YES</string>
        <key>CODE_SIGNING_REQUIRED</key>
        <string>YES</string>
        <key>CODE_SIGN_ENTITLEMENTS</key>
        <string></string>
        <key>DEAD_CODE_STRIPPING</key>
        <string>YES</string>
        <key>DEFAULT_COMPILER</key>
        <string>com.apple.compilers.llvm.clang.1_0</string>
        <key>DEPLOYMENT_TARGET_SUGGESTED_VALUES</key>
        <array>
            <string>9.0</string>
            <string>9.1</string>
            <string>9.2</string>
            <string>10.0</string>
            <string>10.1</string>
            <string>10.2</string>
        </array>
        <key>ENTITLEMENTS_REQUIRED</key>
        <string>YES</string>
        <key>PLATFORM_NAME</key>
        <string>appletvsimulator</string>
        <key>SUPPORTED_DEVICE_FAMILIES</key>
        <string>3</string>
        <key>TVOS_DEPLOYMENT_TARGET</key>
        <string>10.2</string>
    </dict>
    <key>DisplayName</key>
    <string>Simulator - tvOS 10.2</string>
    <key>DocSetFeedName</key>
    <string>tvOS 10.2</string>
    <key>DocSetFeedURL</key>
    <string>http://developer.apple.com/rss/com.apple.adc.documentation.AppleTVOS10_2.atom</string>
    <key>IsBaseSDK</key>
    <string>YES</string>
    <key>MaximumDeploymentTarget</key>
    <string>10.2.99</string>
    <key>MinimalDisplayName</key>
    <string>Simulator - 10.2</string>
    <key>Toolchains</key>
    <array>
        <string>com.apple.dt.toolchain.AppleTVOS10_2</string>
    </array>
    <key>Version</key>
    <string>10.2</string>
</dict>
</plist>
jpsim commented 7 years ago

simctl list will also list simulators, which we could use.

bartoszkosiorek commented 7 years ago

You could get list of deviced with command:

$ xcrun simctl list devices
== Devices ==
-- iOS 10.2 --
    iPhone 5 (F852B612-D9C6-4453-ADC3-0BE6DB12B8B6) (Shutdown)
    iPhone 5s (AC719A6A-9C93-4C6C-87C7-A819626E093F) (Shutdown)
    iPhone 6 (BED0A972-7E9C-4055-9DC6-6D36C5A4888A) (Shutdown)
    iPhone 6 Plus (8C74B13F-DE31-41C3-B024-90C4345B3C28) (Shutdown)
    iPhone 6s (49DCCC27-6DE0-478F-A5AF-4ADFCA53F3ED) (Shutdown)
    iPhone 6s Plus (B0C1F36F-8B9B-4111-8F9C-9E1A8C45252A) (Shutdown)
    iPhone 7 (16A92259-6C7A-4698-8524-86F3A9035D3A) (Shutdown)
    iPhone 7 Plus (D753E4E1-E840-4B55-8022-1A7C28BCD524) (Shutdown)
    iPhone SE (1640508F-FD6E-4730-80A2-C2D4D963198C) (Shutdown)
    iPad Retina (A288AF1A-B38D-4EAD-BE54-61741CCAF66F) (Shutdown)
    iPad Air (8E806449-FDD7-45A0-BB96-F6B079D0B759) (Shutdown)
    iPad Air 2 (3357B90C-E4AA-49F9-9AD0-690E6ABEE4C2) (Shutdown)
    iPad Pro (9.7 inch) (B6EF21C6-B02A-4DC1-ABFC-BF24354107E0) (Shutdown)
    iPad Pro (12.9 inch) (DAF530C6-3A1E-462E-8C97-8F21A3DD4BCD) (Shutdown)
-- tvOS 10.1 --
    Apple TV 1080p (02FD0259-781F-41AE-96C1-9965619F9EE0) (Shutdown)
-- watchOS 3.1 --
    Apple Watch - 38mm (E6B10197-CB56-4416-B9D0-DAD94B978815) (Shutdown)
    Apple Watch - 42mm (8795974B-F9EB-4740-99C6-12A7EB30E3E2) (Shutdown)
    Apple Watch Series 2 - 38mm (370E3B41-9AE8-430B-9CE7-28E604A730BB) (Shutdown)
    Apple Watch Series 2 - 42mm (ADA682CE-E279-4356-90F8-9E4739F612B9) (Shutdown)

To get device types:

$ xcrun simctl list devicetypes
== 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)
iPhone 7 (com.apple.CoreSimulator.SimDeviceType.iPhone-7)
iPhone 7 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus)
iPhone SE (com.apple.CoreSimulator.SimDeviceType.iPhone-SE)
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)
iPad Pro (9.7-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-)
iPad Pro (12.9-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro)
Apple TV 1080p (com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p)
Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
Apple Watch Series 2 - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm)
Apple Watch Series 2 - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm)

And to get list of Simulators runtimes, you could specify:

$ xcrun simctl list runtimes
== Runtimes ==
iOS 10.2 (10.2 - 14C89) (com.apple.CoreSimulator.SimRuntime.iOS-10-2)
tvOS 10.1 (10.1 - 14U591) (com.apple.CoreSimulator.SimRuntime.tvOS-10-1)
watchOS 3.1 (3.1 - 14S471a) (com.apple.CoreSimulator.SimRuntime.watchOS-3-1)
timsutton commented 7 years ago

And we get more easily-parseable output with --json:

➜  ~ xcrun simctl list --json runtimes
{
  "runtimes" : [
    {
      "buildversion" : "14E269",
      "availability" : "(available)",
      "name" : "iOS 10.3",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-10-3",
      "version" : "10.3"
    },
    {
      "buildversion" : "14W260",
      "availability" : "(available)",
      "name" : "tvOS 10.2",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-10-2",
      "version" : "10.2"
    },
    {
      "buildversion" : "14V243",
      "availability" : "(available)",
      "name" : "watchOS 3.2",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-3-2",
      "version" : "3.2"
    }
  ]
}