-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support tvOS and watchOS simulators #203
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we merge PR #206 and then rebase this on top of that PR. Then we can also add CI testing for this support, to ensure it works for both x86_64 and ARM64 hosts.
.travis.sh
Outdated
|
||
if [ `uname` = Darwin ] | ||
then | ||
title "••••• Darwin: ios simulator tests •••••" | ||
title "boot a simulator" | ||
rustup target add x86_64-apple-ios; | ||
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1) | ||
export SIM_ID=$(xcrun simctl create My-iphone7 com.apple.CoreSimulator.SimDeviceType.iPhone-8 $RUNTIME_ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's wrong. better to handle it in a separate PR.
.travis.sh
Outdated
export WATCHOS_SIM_ID=$(xcrun simctl create My-apple-watch com.apple.CoreSimulator.SimDeviceType.Apple-Watch-SE-44mm-2nd-generation $WATCHOS_RUNTIME_ID) | ||
|
||
xcrun simctl boot $WATCHOS_SIM_ID | ||
tests_sequence_unstable_target x86_64-apple-watchos-sim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the M1 support PR, I suggest that we (automatically) use aarch64-apple-watchos-sim if the host is aarch64 and x86_64-apple-watchos-sim if the host is x86_64.
Perhaps we could extend the auto-
mechanism to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what it will do if we use -d sim
or '-d watchos-sim' actually. -d allows partial match. And if we are lucky the ios discovery code will only create an auto device for the matching architecture simulator...
And if it does not it may be desirable/easy to make it do so.
test-ws/test-bin/.cargo/config.toml
Outdated
runner = "cargo run --manifest-path ../../Cargo.toml --bin cargo-dinghy -- -p auto-ios-aarch64-sim runner" | ||
|
||
[target.x86_64-apple-ios] | ||
runner = "cargo run --manifest-path ../../Cargo.toml --bin cargo-dinghy -- -p auto-ios-x86_64 runner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree this is very useful to document and many people will want to copy-paste something like this into their own .cargo/config.toml. But perhaps we should have a separate PR for adding this example/documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
.travis.sh
Outdated
|
||
title "••••• Darwin: watchvos simulator tests •••••" | ||
title "boot a simulator" | ||
rustup toolchain add nightly --component rust-src; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the second time that the command is run.
dinghy-lib/src/apple/device.rs
Outdated
Ok(build_bundle) | ||
} | ||
|
||
fn make_watchos_app( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like these two functions really duplicate a lot of make_ios_app. I think it would be easier to maintain if most of the commonality were factored out or if make_ios_app were renamed and parameterized over AppleSimulatorType
so that it could handle all three cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda agree here, unless there is something I can't see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I originally thought I might have to do more changes per simulator target so I just duplicated the functions. The bulk of the difference is now in the plist addition.
dinghy-lib/src/apple/xcode.rs
Outdated
@@ -70,6 +70,63 @@ pub fn add_plist_to_app(bundle: &BuildBundle, arch: &str, app_bundle_id: &str) - | |||
Ok(()) | |||
} | |||
|
|||
pub fn add_plist_to_tvos_app(bundle: &BuildBundle, arch: &str, app_bundle_id: &str) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto regarding DRY. it is quite difficult to spot the differences between the three add_plist_to_*_app
functions to understand what's different, and it would be easier to maintain this is we could have the common logic shared.
* Added CI tests for watchOS and tvOS
a8ec5b0
to
37cd7b7
Compare
.travis.sh
Outdated
tests_sequence_unstable_target() { | ||
# There's something odd with using the .cargo/config runner attribute and | ||
# workspaces when the runner uses `cargo run --manifest-path ../Cargo.toml | ||
# --bin cargo-dinghy ...` | ||
title "testing from project directory for rust target $1 on device $2" | ||
title "testing from workspace directory" | ||
( \ | ||
cd test-ws \ | ||
&& cargo clean \ | ||
&& $CARGO_DINGHY -d $1 -p $2 test -Zbuild-std pass \ | ||
&& ! $CARGO_DINGHY -d $1 -p $2 test -Zbuild-std fails \ | ||
&& ! $CARGO_DINGHY -d $1 -p $2 test -Zbuild-std \ | ||
) | ||
|
||
title "testing from project directory" | ||
( \ | ||
cd test-ws/test-app \ | ||
&& cargo clean \ | ||
&& $CARGO_DINGHY -d $1 -p $2 test pass \ | ||
&& ! $CARGO_DINGHY -d $1 -p $2 test fails \ | ||
&& ! $CARGO_DINGHY -d $1 -p $2 test \ | ||
) | ||
|
||
title "test from workspace directory with project filter" | ||
( \ | ||
cd test-ws \ | ||
&& cargo clean \ | ||
&& $CARGO_DINGHY -d $1 -p $2 test -p test-app pass \ | ||
&& ! $CARGO_DINGHY -d $1 -p $2 test -p test-app fails \ | ||
&& ! $CARGO_DINGHY -d $1 -p $2 test -p test-app \ | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This additional function makes test_sequence
, tests_sequence_aarch64_ios_sim
, and tests_sequence_unstable_target
which is pretty gross. Any suggestions?
Some(AppleSimulatorType::Ios) | Some(AppleSimulatorType::Tvos) | None => { | ||
writeln!(plist, "<key>UIRequiredDeviceCapabilities</key>")?; | ||
writeln!(plist, "<array><string>{}</string></array>", arch)?; | ||
writeln!(plist, "<key>UILaunchStoryboardName</key>")?; | ||
writeln!(plist, "<string></string>")?; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, these will diverge more I think. Today, I spent a bit of time diving into an audio microphone issue on cpal. I manually added micrphone
to the UIRequiredDeviceCapabilities
.
It's out of the scope of this PR but it'd be nice to have some possible permission options or maybe a custom Info.plist
.
OK, I think we're good here. Thanks for working on this and being patient with the review :) |
Closes #194 and #193.
It's unclear if we want test these targets in CI. For one, these targets require the
build-std
nightly feature and for another, all targets for watchOS are tier 3 and tvOS are tier 3. They might sometimes break (as with tier 3 targets).At this point, the thing I dislike about this implementation is that some parts imply that there are device targets for tvOS and watchOS and that's kinda not in planned (to me).
I elected to test
watchOS
andtvOS
using just thetest-ws/test-bin
because it's simpler and I ended up with different errors in thetest-ws/test-app
pass tests.I partially started this task with the goal of testing
aarch64-apple-tvos-sim
. I feel like I'm going crazy but I swear it was working but at moment of this writing, it fails on my machine. Yet, targets such asaarch64-apple-watchos-sim
,x86_64-apple-watchos-sim
andx86_64-apple-tvos
all work. Free macOS github runners aren't apple silicon so we cannot test the aarch64 targets at the moment in CI. I think the existing tests should suffice.