Skip to content

Commit

Permalink
Switch from SDMMobileDevice to FBSimulatorControl for iOS device inst…
Browse files Browse the repository at this point in the history
…allation

Summary:
We currently use a third party helper program, SDMMobileDevice to handle the actual loading of the .app file to an iOS device.  This has bit-rotted a bit and has issues with the latest MacOS and iOS versions.

Switch to FBSimulatorControl (which also supports devices, despite the name).  This is owned by us and actively maintained, unlike the former.

Test Plan:
With a wildcard provisioning profile installed, and a device connected:

```
ant test -Dtest.class=InstallCommandIntegrationTest
```

`DemoApp` should be built and installed on the device without any errors.

Reviewed By: Coneko

fbshipit-source-id: c3d7ff2
  • Loading branch information
ryu2 authored and facebook-github-bot committed Mar 16, 2017
1 parent 8828f0e commit d9fe768
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 210 deletions.
6 changes: 3 additions & 3 deletions docs/command/install.soy
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ Builds and installs the APK for an <code>android_binary</code> or target.
</p>

<p>
For device support, you need to first install the <code>iOSConsole</code> utility
from the <a href="https://github.com/samdmarshall/SDMMobileDevice">SDMMobileDevice
library</a> and set {call buckconfig.apple_device_helper_path /} to its location.
For device support, you need to first build the <code>fbsimctl</code> utility
from <a href="https://github.com/facebook/FBSimulatorControl/">FBSimulatorControl</a> and
set {call buckconfig.apple_device_helper_path /} to its location.
</p>

<h3>Parameters</h3>
Expand Down
8 changes: 4 additions & 4 deletions docs/concept/buckconfig.soy
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ $ buck targets --resolve-alias app#src_jar
{call buckconfig.entry}
{param section: 'apple' /}
{param name: 'device_helper_path' /}
{param example_value: 'third-party/iOSConsole/iOSConsole' /}
{param example_value: 'third-party/fbsimctl/fbsimctl' /}
{param description}
If you want to have Buck be able to install to devices, you need to provide the path to the{sp}
<a href="https://github.com/samdmarshall/SDMMobileDevice"><code>iOSConsole</code></a> binary.
<a href="https://github.com/facebook/FBSimulatorControl/"><code>fbsimctl</code></a> binary.
{/param}
{/call}

Expand Down Expand Up @@ -587,13 +587,13 @@ $ buck targets --resolve-alias app#src_jar
{param name: 'type' /}
{param example_value: 'RELEASE_PEX' /}
{param description}
Sets the type of the build that buck has been built with. This allows buck to distinguish
Sets the type of the build that buck has been built with. This allows buck to distinguish
different kinds of builds. When you run <code>ant</code> locally, this will be automatically
set to <code>LOCAL_ANT</code>. When you build buck using buck locally, e.g. <code>buck build buck</code>,
this will be automatically set to <code>LOCAL_PEX</code>. If you are deploying buck through
central deployment system, you may want to set build type to <code>RELEASE_PEX</code>:{sp}
<pre>buck build buck --config build.type=RELEASE_PEX</pre>
<p><b>Note:</b> this setting does not affect how buck builds other rules. It only affects
<p><b>Note:</b> this setting does not affect how buck builds other rules. It only affects
the way how <i>buck will build buck</i>.</p>
{/param}
{/call}
Expand Down
8 changes: 4 additions & 4 deletions src/com/facebook/buck/apple/device/AppleDeviceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class AppleDeviceHelper {
private static final Logger LOG = Logger.get(AppleDeviceHelper.class);
private static final Pattern DEVICE_DESCRIPTION_PATTERN =
Pattern.compile("([a-f0-9]{40}) : (.*)$");
Pattern.compile("([a-f0-9]{40}) \\| (.*)");


private final ProcessExecutor processExecutor;
Expand All @@ -59,7 +59,7 @@ public ImmutableMap<String, String> getConnectedDevices() {
ProcessExecutorParams.builder()
.setCommand(
ImmutableList.of(
deviceHelperPath.toString(), "-l"))
deviceHelperPath.toString(), "list"))
.build();
// Must specify that stdout is expected or else output may be wrapped in Ansi escape chars.
Set<ProcessExecutor.Option> options = EnumSet.of(ProcessExecutor.Option.EXPECTING_STD_OUT);
Expand Down Expand Up @@ -107,7 +107,7 @@ public boolean installBundleOnDevice(String udid, Path bundlePath) {
ProcessExecutorParams.builder()
.setCommand(
ImmutableList.of(
deviceHelperPath.toString(), "-d", udid, "-t", bundlePath.toString()))
deviceHelperPath.toString(), "--json", udid, "install", bundlePath.toString()))
.build();
Set<ProcessExecutor.Option> options = EnumSet.of(
ProcessExecutor.Option.PRINT_STD_OUT,
Expand Down Expand Up @@ -144,7 +144,7 @@ public boolean runBundleOnDevice(String udid, String bundleID) {
ProcessExecutorParams.builder()
.setCommand(
ImmutableList.of(
deviceHelperPath.toString(), "-d", udid, "--run", bundleID))
deviceHelperPath.toString(), "--json", udid, "launch", bundleID))
.build();
Set<ProcessExecutor.Option> options = EnumSet.of(
ProcessExecutor.Option.PRINT_STD_OUT,
Expand Down
9 changes: 7 additions & 2 deletions test/com/facebook/buck/cli/InstallCommandIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
import com.facebook.buck.util.environment.Platform;
import com.google.common.collect.ImmutableSet;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -182,8 +184,9 @@ public void appleBundleInstallsInDeviceWithHelperAsPath() throws IOException,
this, "apple_app_bundle", tmp);
workspace.setUp();

assumeTrue(Files.exists(workspace.getPath("fbsimctl/fbsimctl")));
assumeTrue(FakeAppleDeveloperEnvironment.hasDeviceCurrentlyConnected(workspace.getPath(
"iOSConsole/iOSConsole"
"fbsimctl/fbsimctl"
)));


Expand All @@ -193,6 +196,8 @@ public void appleBundleInstallsInDeviceWithHelperAsPath() throws IOException,
result.assertSuccess();
}

// Disabled until fbsimctl builds properly with Buck
@Ignore
@Test
public void appleBundleInstallsInDeviceWithHelperAsTarget() throws IOException,
InterruptedException {
Expand All @@ -204,7 +209,7 @@ public void appleBundleInstallsInDeviceWithHelperAsTarget() throws IOException,
workspace.setUp();

assumeTrue(FakeAppleDeveloperEnvironment.hasDeviceCurrentlyConnected(workspace.getPath(
"iOSConsole/iOSConsole"
"fbsimctl/fbsimctl"
)));


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[cxx]
default_platform = iphonesimulator-x86_64
[apple]
device_helper_path = iOSConsole/iOSConsole
device_helper_path = fbsimctl/fbsimctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

README for fbsimctl
=====================

This test depends on having the fbsimctl binary and its supporting frameworks
present in this directory.

(We may eventually include this as source and build it with Xcode
or Buck, but it would add a few minutes to every build.)

Tested with:
Project URL: https://github.com/facebook/FBSimulatorControl
License: BSD
Upstream Revision: 05dabaabef3c3f27ed792db328fcb62daa20d9d5
Built with Xcode 8.2.1 (8C1002)
Built With: `build.sh fbsimctl build`

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

0 comments on commit d9fe768

Please sign in to comment.