Skip to content

Use devicectl to install and launch *_application targets on a physical device #2527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 14, 2024

Conversation

CognitiveDisson
Copy link
Contributor

@CognitiveDisson CognitiveDisson commented Sep 10, 2024

In Xcode 15, Apple introduced a new command-line tool that allows management of physical devices. This makes it possible to install and launch *_application targets on a physical device without third-party solutions.

With these changes, you can now use bazel run //:iOSApp --ios_multi_cpus=arm64.

Previously, this command would attempt to launch the application on a simulator and fail due to an invalid architecture.

Bazel currently lacks a specific flag for specifying device identifiers suitable for this purpose. I created a PR to Bazel introducing an --ios_device flag. However, it's unlikely to be accepted since it's a platform-specific flag. If it is accepted, we can utilize it in the future.

For the current implementation, I added astring_flagthat allows passing a device identifier. It can be used like this:--@build_bazel_rules_apple//apple/build_settings:ios_device=<uuid|ecid|serial_number|udid|name|dns_name> .

Note: //doc:check_apple failing on master

@brentleyjones
Copy link
Collaborator

brentleyjones commented Sep 10, 2024

Unfortunately, Bazel currently lacks a specific flag for specifying device identifiers suitable for this purpose.

Can't we make a new Starlark flag?

@CognitiveDisson
Copy link
Contributor Author

CognitiveDisson commented Sep 10, 2024

Can't we make a new Starlark flag?

I was planning to do it, but I think it shouldn't block this PR. Even if it's accepted, the flag will be available only in the next Bazel version, if I understand that correctly.

@brentleyjones Done

@luispadron
Copy link
Contributor

This is great so far i have some very minor nits about docs and some questions about whats expected now when doing bazel run for an app.

Is it now the default that doing bazel run //FooApp where FooApp is an ios_application will run on a device if it's connected to the host machine? I think this make sense if so, just checking! If it is the new default I think we should make it a bit more obvious in the docs

Co-authored-by: Luis Padron <[email protected]>
Co-authored-by: Brentley Jones <[email protected]>
@CognitiveDisson
Copy link
Contributor Author

This is great so far i have some very minor nits about docs and some questions about whats expected now when doing bazel run for an app.

Is it now the default that doing bazel run //FooApp where FooApp is an ios_application will run on a device if it's connected to the host machine? I think this make sense if so, just checking! If it is the new default I think we should make it a bit more obvious in the docs

Yes, it's now the default behavior. The choice between running on a simulator or a device depends on the target architecture. However, it's worth noting that users typically build this target rather than running it directly.

To me, it looks like this is emphasized enough in the documentation, but I'm open to suggestions.

@luispadron
Copy link
Contributor

This is great so far i have some very minor nits about docs and some questions about whats expected now when doing bazel run for an app.

Is it now the default that doing bazel run //FooApp where FooApp is an ios_application will run on a device if it's connected to the host machine? I think this make sense if so, just checking! If it is the new default I think we should make it a bit more obvious in the docs

Yes, it's now the default behavior. The choice between running on a simulator or a device depends on the target architecture. However, it's worth noting that users typically build this target rather than running it directly.

To me, it looks like this is emphasized enough in the documentation, but I'm open to suggestions.

Ah makes sense it'll run on a device based on the arch, thank you!

@luispadron luispadron merged commit 00a5576 into bazelbuild:master Sep 14, 2024
8 checks passed
sewerynplazuk pushed a commit to sewerynplazuk/rules_apple that referenced this pull request Sep 20, 2024
…al device (bazelbuild#2527)

In Xcode 15, Apple introduced a new command-line tool that allows
management of physical devices. This makes it possible to install and
launch *_application targets on a physical device without third-party
solutions.

With these changes, you can now use `bazel run //:iOSApp
--ios_multi_cpus=arm64`.

Previously, this command would attempt to launch the application on a
simulator and fail due to an invalid architecture.

Bazel currently lacks a specific flag for specifying device identifiers
suitable for this purpose. I created a [PR to
Bazel](bazelbuild/bazel#23599) introducing an
`--ios_device` flag. However, it's unlikely to be accepted since it's a
platform-specific flag. If it is accepted, we can utilize it in the
future.

For the current implementation, I added astring_flagthat allows passing
a device identifier. It can be used like
this:--@build_bazel_rules_apple//apple/build_settings:ios_device=<uuid|ecid|serial_number|udid|name|dns_name&gt;
.
---------

Signed-off-by: Vadim Smal <[email protected]>
Co-authored-by: Luis Padron <[email protected]>
Co-authored-by: Brentley Jones <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants