xcpretty / xcode-install

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

Arbitrary simulator is picked for installation #132

Open ghost opened 8 years ago

ghost commented 8 years ago

Issue: When multiple versions of the same simulator runtime are available (e.g. for different Xcode versions), xcversion picks an arbitrary version for download.

For example, for the iOS 8.1 runtime, there are at least two versions available:

  1. For Xcode 6.4, the endpoint https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-6.4.0-7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90.dvtdownloadableindex provides this DMG: https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_1-8.1.1.1354140590.dmg.
  2. For Xcode 7.3, the endpoint https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-7.3.0-ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C.dvtdownloadableindex provides this DMG: https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_1-8.1.1.1434581536.dmg.

In my testing, the command xcversion simulators --install='iOS 8.1' is always installing the Xcode 6.4 version. (I think that this order is determined by the order in which mdfind returns the installed Xcode app bundles, which I believe is undefined.) The problem is that I don't think that the runtime versions are forwards-compatible, since when I do xcrun simctl list runtimes after installing this runtime, with Xcode 7.3 as my selected Xcode, I get output like this:

== Runtimes ==
iOS 8.1 (8.1 - 12B411) (com.apple.CoreSimulator.SimRuntime.iOS-8-1) (unavailable, failed to open liblaunch_sim.dylib)

Thoughts: It appears that the runtime versions are backwards-compatible; that is, for example, if I install the iOS 8.1 simulator using Xcode 7.3, then it will also work with Xcode 6.4. This suggests a couple of possible solutions:

  1. Require an --xcode-version argument for xcversion simulators --install, which allows you to specify "the simulator that is installed must be compatible with this version of Xcode".
  2. Alternatively, just always install the latest runtime version available (across all installed Xcode versions).

There will also be an impact on the output of xcversion simulators, which should not show a simulator as installed for a given Xcode if the installed simulator runtime version is not compatible with that version of Xcode. (I am not sure how one would go about detecting this without switching Xcode versions and looking at the output of xcrun simctl list runtimes, but I haven't investigated it in depth.)

It would also have to be decided what the behaviour should be if xcversion simulators --install is called when the simulator runtime is already installed, but a newer version is required. I would suggest that it should trigger an upgrade to the newer simulator version.

Please let me know if you have any thoughts or questions!

neonichu commented 8 years ago

Thanks for this detailed write-up! This all makes sense and I think installing the latest runtime version is the best option here.

As far as running xcrun simctl list runtimes goes, we could be using the DEVELOPER_DIR environment variable to switch between the installed Xcode versions.