Skip to content

Conversation

@jmagman
Copy link
Member

@jmagman jmagman commented Jun 11, 2021

Add a new MacOSDesignedForIPadDevice device to target when running native ARM iOS apps on Apple Silicon macOS. I called this "Mac Designed for iPad" based on the Xcode target name, since there doesn't seem to be a pithy marketing name for this feature.
Screen Shot 2021-06-10 at 10 22 49 PM

It only supports flutter attaching to iOS apps already launched from Xcode, per guidance from product leadership so as not to confuse the desktop macOS development story.

The running apps are discovered via mDNS.
Screen Shot 2021-06-10 at 9 36 26 PM

It's like a desktop device for log reading/port purposes. It's like an iOS device in that it's only supported for apps with an ios project directory. If startApp, buildApp, etc are ever implemented in a future PR, it will have to create the right structured bundle out of the iOS app.
Screen Shot 2021-06-10 at 10 26 36 PM

Also create MacOSDesignedForIPadDevices device discovery that will only return this new device type if on an ARM Mac, and iOS is supported (Xcode is installed, etc).

flutter devices does not show this device type:

$ flutter devices
No devices detected.

However when I flutter attach:

$ flutter attach --app-id "com.example.testCreate"
Syncing files to device Mac Designed for iPad...                    5.9s

Flutter run key commands.
r Hot reload. 🔥🔥🔥
...

And it's actually attached:
https://user-images.githubusercontent.com/682784/121634738-f78b9a00-ca39-11eb-9a25-b53f16dd2cda.mov

Will try to figure out a way to integration test this once #79430 is done.

flutter attach part of #66184

@jmagman jmagman added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. platform-mac Building on or for macOS specifically labels Jun 11, 2021
@jmagman jmagman self-assigned this Jun 11, 2021
@google-cla google-cla bot added the cla: no label Jun 11, 2021
@jmagman jmagman added cla: yes and removed cla: no labels Jun 11, 2021
@flutter flutter deleted a comment from google-cla bot Jun 11, 2021
Comment on lines +127 to +128
/// Set to show ARM macOS as an iOS device target.
static bool allowDiscovery = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out a non-global way to set this (modeled on FlutterTesterDevices.showFlutterTesterDevice). I tried to make it a property on a context override on IOSWorkflow but I would have needed to set it the context override only for the attach command in:

await context.run<void>(
overrides: contextOverrides.map<Type, Generator>((Type type, dynamic value) {
return MapEntry<Type, Generator>(type, () => value);
}),

and
Future<void> validateCommand() async {
await super.validateCommand();

and
Future<FlutterCommandResult> runCommand() async {
await _validateArguments();
final Device device = await findTargetDevice();

Welcome suggestions to make this better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static is fine, please no more context overrides

Comment on lines +62 to +64
tearDown(() {
MacOSDesignedForIPadDevices.allowDiscovery = false;
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See allowDiscovery global comment. It's similar to:

group('FlutterTesterDevices', () {
tearDown(() {
FlutterTesterDevices.showFlutterTesterDevice = false;
});

@jmagman jmagman requested a review from jonahwilliams June 11, 2021 18:42
@jonahwilliams
Copy link
Contributor

Heads up that I won't have a chance to look at this today since I'm heading out early, but I will take a look first thing monday

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thipokch
Copy link

@jmagman Just curious if attaching from vscode would work too?

@thipokch
Copy link

thipokch commented Apr 25, 2023

Managed to get it to work in vscode with the following config:

// (launch.json)
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach: Design for iPad",
            "request": "attach",
            "type": "dart",
            "program": "lib/main.dart",
            "args": [
                "--app-id",
                "com.example"
            ],
            "deviceId": "designed-for-ipad",
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform-ios iOS applications specifically platform-mac Building on or for macOS specifically platform-target-arm Targeting an ARM-based platform tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants