Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

xctool does not respect the 'OS' or 'platform' fields in the -destination option. #205

Closed
fpotter opened this issue Oct 11, 2013 · 19 comments

Comments

@fpotter
Copy link
Contributor

fpotter commented Oct 11, 2013

When running application tests, xctool should start the simulator named in the -destination parameter.

e.g., if you pass xcodebuild -destination "name=iPad Retina", it will start the iPad Retina simulator. Or, if you pass -destination "name=iPhone Retain (3.5-inch)", it will start the 3.5in retina simulator.

Making this happen is tricky, since the private framework we use for starting the simulator (iPhoneSimulatorRemoteClient.framework) doesn't expose methods for setting the device name.

We might want to switch to using DVTiPhoneSimulatorRemoteClient.framework which is much like the current framework we use, but with more options.

Or, we could try and trick iPhoneSimulatorRemoteClient.framework into sending the right messages we need. When watching Xcode.app post distributed notifications to the simulator, we can see that it's passing stuff like deviceInfo=iPhone Retina (4-inch) in the com.apple.iphonesimulator.startSession message (see https://gist.github.com/fpotter/6941760). We might be able to swizzle our way into making iPhoneSimulatorRemoteClient.framework do the same thing.

To validate that a device name is correct, we should look for a corresponding .deviceinfo bundle under /Applications/Xcode.app/Contents/Developer/Library/PrivateFrameworks/SimulatorHost.framework/Versions/A/Resources/Devices.

@ryanrhee
Copy link
Contributor

A PR for building universal binaries is up: #211

@ryanrhee
Copy link
Contributor

A PR for using * DVTiPhoneSimulatorRemoteClient.framework* is up: #212

@ghost ghost assigned ryanrhee Oct 15, 2013
@ryanrhee
Copy link
Contributor

@fpotter My SimulatorHost.framework is actually in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/SimulatorHost.framework. Was your path a mistake, or are there multiple system configurations that need to be accounted for?

@fpotter
Copy link
Contributor Author

fpotter commented Oct 15, 2013

@ryanrhee Oh, my mistake! Your path is right.

@ryanrhee
Copy link
Contributor

@fpotter looking for a corresponding .deviceinfo bundle isn't going to work. Check this out -
iPhone (Retina 3.5-inch).deviceinfo is actually named iPhone Retina (3.5-inch). We'll have to peek into the respective info.plist files, and grab the value for the displayName key.

This really makes me want to have a separate configure step or something that figures this stuff out and saves the results. Parsing through all these files on every run might cost us a couple of seconds.

@fpotter
Copy link
Contributor Author

fpotter commented Oct 18, 2013

Oh that's lame - it was so close to being that easy.

This really makes me want to have a separate configure step or something that figures this stuff out and saves the results.

What do you mean by that? Like a machine-wide configure step for xctool?

@ryanrhee
Copy link
Contributor

Yeah, like after installing, doing some sort of initialization to do some one-time set up that doesn't change very often. Anyway, that can come later. It seems like we're not losing too much time from this.

@fpotter
Copy link
Contributor Author

fpotter commented Oct 18, 2013

Yeah, sounds good. It's only a few files - I bet it still runs super fast.

@ryanrhee
Copy link
Contributor

A PR that enables 64-bit application tests via -destination is up: #217.

Looks like the combination of #211 and #217 will make tests run on all possible -destinations.

@blakewatters
Copy link
Contributor

It looks like #211 and #217 have already been landed, but I am not getting the correct simulators run via -destination. Regardless of the input its always the iOS 7 Simulator.

Is there outstanding work on this issue?

@fpotter
Copy link
Contributor Author

fpotter commented Nov 13, 2013

@blakewatters Can you share the command line you're using to select the sim and iOS version? I don't think we knew about this specific bug... but let's fix it.

@blakewatters
Copy link
Contributor

@fpotter sure:

/Users/blake/Projects/xctool/xctool.sh -workspace TAFlights.xcworkspace -scheme TAFlightsUnitTests -sdk iphonesimulator test -test-sdk iphonesimulator -destination "platform='iOS Simulator',OS=6.1,name='iPhone Retina (4-inch)’”

Always gets the 7.0 Simulator

@blakewatters
Copy link
Contributor

To expand a bit, the equivalent xcodebuild invocation of:

/usr/bin/xcodebuild -workspace TAFlights.xcworkspace -scheme TAFlightsUnitTests -sdk iphonesimulator test -destination platform='iOS Simulator',OS=6.1,name='iPhone Retina (4-inch)’

works as expected

@fpotter
Copy link
Contributor Author

fpotter commented Nov 13, 2013

Yeah, we only look at the name portion so far. We need to respect the OS part, too.

https://github.com/facebook/xctool/blob/master/xctool/xctool/RunTestsAction.m#L347

sheesh... being a front-end for Xcode 4's xcodebuild was easy... but the Xcode 5 changes are a lot of work 😢

@blakewatters
Copy link
Contributor

@fpotter I spent a couple of minutes spinning through the code and its not obvious to me how the destination argument is used once it passes into the RunTestsAction. Adding the parsing out of the OS is argument is easy enough, but I am having trouble figuring out where it needs to wired in downstream. What’s actually responsible for firing up the Simulator?

@blakewatters
Copy link
Contributor

man I must be blind or missing something, but I can’t see how the deviceName gets piped down

@fpotter
Copy link
Contributor Author

fpotter commented Nov 14, 2013

The SimulatorLauncher guyt handles that stuff.

Over here --
https://github.com/facebook/xctool/blob/master/xctool/xctool/OCUnitIOSAppTestRunner.m#L218
And, here --
https://github.com/facebook/xctool/blob/master/xctool/xctool/OCUnitIOSAppTestRunner.m#L172

And, then we're mucking with plists over here --
https://github.com/facebook/xctool/blob/master/xctool/xctool/SimulatorLauncher.m#L27

Presumably there's another plist key for OS version which we should also be setting.

@x2on
Copy link
Contributor

x2on commented Dec 10, 2013

But with Xcode 5 you don't have to handle plists, you can use the -device argument

@ExtremeMan
Copy link
Contributor

Support of OS and name fields in -destination option is now added.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants