Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
167655e8
Unverified
Commit
167655e8
authored
Jul 26, 2022
by
Jenn Magder
Committed by
GitHub
Jul 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only show iOS simulators, reduce output spew in verbose (#108345)
parent
fe16c206
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
139 additions
and
123 deletions
+139
-123
ios_workflow.dart
packages/flutter_tools/lib/src/ios/ios_workflow.dart
+1
-1
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+39
-69
xcode.dart
packages/flutter_tools/lib/src/macos/xcode.dart
+1
-1
ios_workflow_test.dart
...utter_tools/test/general.shard/ios/ios_workflow_test.dart
+35
-3
simulators_test.dart
...flutter_tools/test/general.shard/ios/simulators_test.dart
+56
-46
xcode_test.dart
...es/flutter_tools/test/general.shard/macos/xcode_test.dart
+4
-0
xcode_validator_test.dart
..._tools/test/general.shard/macos/xcode_validator_test.dart
+3
-3
No files found.
packages/flutter_tools/lib/src/ios/ios_workflow.dart
View file @
167655e8
...
...
@@ -25,7 +25,7 @@ class IOSWorkflow implements Workflow {
// We need xcode (+simctl) to list simulator devices, and libimobiledevice to list real devices.
@override
bool
get
canListDevices
=>
appliesToHostPlatform
&&
_xcode
.
is
InstalledAndMeetsVersionCheck
&&
_xcode
.
is
SimctlInstalled
;
bool
get
canListDevices
=>
appliesToHostPlatform
&&
_xcode
.
isSimctlInstalled
;
// We need xcode to launch simulator devices, and ios-deploy
// for real devices.
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
167655e8
...
...
@@ -71,8 +71,8 @@ class IOSSimulatorUtils {
return
<
IOSSimulator
>[];
}
final
List
<
SimDevice
>
connected
=
await
_simControl
.
getConnectedDevices
();
return
connected
.
map
<
IOSSimulator
?>((
SimDevice
device
)
{
final
List
<
Booted
SimDevice
>
connected
=
await
_simControl
.
getConnectedDevices
();
return
connected
.
map
<
IOSSimulator
?>((
Booted
SimDevice
device
)
{
final
String
?
udid
=
device
.
udid
;
final
String
?
name
=
device
.
name
;
if
(
udid
==
null
)
{
...
...
@@ -109,30 +109,45 @@ class SimControl {
/// Runs `simctl list --json` and returns the JSON of the corresponding
/// [section].
Future
<
Map
<
String
,
Object
?>>
_list
(
SimControlListSection
section
)
async
{
// Sample output from `simctl list --json`:
Future
<
Map
<
String
,
Object
?>>
_list
BootedDevices
(
)
async
{
// Sample output from `simctl list
available booted
--json`:
//
// {
// "devicetypes": { ... },
// "runtimes": { ... },
// "devices" : {
// "com.apple.CoreSimulator.SimRuntime.iOS-
8-2
" : [
// "com.apple.CoreSimulator.SimRuntime.iOS-
14-0
" : [
// {
// "state" : "Shutdown",
// "availability" : " (unavailable, runtime profile not found)",
// "name" : "iPhone 4s",
// "udid" : "1913014C-6DCB-485D-AC6B-7CD76D322F5B"
// },
// ...
// },
// "pairs": { ... },
// "lastBootedAt" : "2022-07-26T01:46:23Z",
// "dataPath" : "\/Users\/magder\/Library\/Developer\/CoreSimulator\/Devices\/9EC90A99-6924-472D-8CDD-4D8234AB4779\/data",
// "dataPathSize" : 1620578304,
// "logPath" : "\/Users\/magder\/Library\/Logs\/CoreSimulator\/9EC90A99-6924-472D-8CDD-4D8234AB4779",
// "udid" : "9EC90A99-6924-472D-8CDD-4D8234AB4779",
// "isAvailable" : true,
// "logPathSize" : 9740288,
// "deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-11",
// "state" : "Booted",
// "name" : "iPhone 11"
// }
// ],
// "com.apple.CoreSimulator.SimRuntime.iOS-13-0" : [
//
// ],
// "com.apple.CoreSimulator.SimRuntime.iOS-12-4" : [
//
// ],
// "com.apple.CoreSimulator.SimRuntime.iOS-16-0" : [
//
// ]
// }
// }
final
List
<
String
>
command
=
<
String
>[
...
_xcode
.
xcrunCommand
(),
'simctl'
,
'list'
,
'devices'
,
'booted'
,
'iOS'
,
'--json'
,
section
.
name
,
];
_logger
.
printTrace
(
command
.
join
(
' '
));
final
RunResult
results
=
await
_processUtils
.
run
(
command
);
...
...
@@ -141,7 +156,7 @@ class SimControl {
return
<
String
,
Map
<
String
,
Object
?>>{};
}
try
{
final
Object
?
decodeResult
=
(
json
.
decode
(
results
.
stdout
)
as
Map
<
String
,
Object
?>)[
section
.
name
];
final
Object
?
decodeResult
=
(
json
.
decode
(
results
.
stdout
)
as
Map
<
String
,
Object
?>)[
'devices'
];
if
(
decodeResult
is
Map
<
String
,
Object
?>)
{
return
decodeResult
;
}
...
...
@@ -156,17 +171,17 @@ class SimControl {
}
}
/// Returns a
list of all available devices, both potential and connected
.
Future
<
List
<
SimDevice
>>
get
Devices
()
async
{
final
List
<
SimDevice
>
devices
=
<
SimDevice
>[];
/// Returns a
ll the connected simulator devices
.
Future
<
List
<
BootedSimDevice
>>
getConnected
Devices
()
async
{
final
List
<
BootedSimDevice
>
devices
=
<
Booted
SimDevice
>[];
final
Map
<
String
,
Object
?>
devicesSection
=
await
_list
(
SimControlListSection
.
devices
);
final
Map
<
String
,
Object
?>
devicesSection
=
await
_list
BootedDevices
(
);
for
(
final
String
deviceCategory
in
devicesSection
.
keys
)
{
final
Object
?
devicesData
=
devicesSection
[
deviceCategory
];
if
(
devicesData
!=
null
&&
devicesData
is
List
<
Object
?>)
{
for
(
final
Map
<
String
,
Object
?>
data
in
devicesData
.
map
<
Map
<
String
,
Object
?>?>(
castStringKeyedMap
).
whereType
<
Map
<
String
,
Object
?>>())
{
devices
.
add
(
SimDevice
(
deviceCategory
,
data
));
devices
.
add
(
Booted
SimDevice
(
deviceCategory
,
data
));
}
}
}
...
...
@@ -174,12 +189,6 @@ class SimControl {
return
devices
;
}
/// Returns all the connected simulator devices.
Future
<
List
<
SimDevice
>>
getConnectedDevices
()
async
{
final
List
<
SimDevice
>
simDevices
=
await
getDevices
();
return
simDevices
.
where
((
SimDevice
device
)
=>
device
.
isBooted
).
toList
();
}
Future
<
bool
>
isInstalled
(
String
deviceId
,
String
appId
)
{
return
_processUtils
.
exitsHappy
(<
String
>[
...
_xcode
.
xcrunCommand
(),
...
...
@@ -267,54 +276,15 @@ class SimControl {
}
}
/// Enumerates all data sections of `xcrun simctl list --json` command.
class
SimControlListSection
{
const
SimControlListSection
.
_
(
this
.
name
);
final
String
name
;
static
const
SimControlListSection
devices
=
SimControlListSection
.
_
(
'devices'
);
static
const
SimControlListSection
devicetypes
=
SimControlListSection
.
_
(
'devicetypes'
);
static
const
SimControlListSection
runtimes
=
SimControlListSection
.
_
(
'runtimes'
);
static
const
SimControlListSection
pairs
=
SimControlListSection
.
_
(
'pairs'
);
}
/// A simulated device type.
///
/// Simulated device types can be listed using the command
/// `xcrun simctl list devicetypes`.
class
SimDeviceType
{
SimDeviceType
(
this
.
name
,
this
.
identifier
);
/// The name of the device type.
///
/// Examples:
///
/// "iPhone 6s"
/// "iPhone 6 Plus"
final
String
name
;
/// The identifier of the device type.
///
/// Examples:
///
/// "com.apple.CoreSimulator.SimDeviceType.iPhone-6s"
/// "com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus"
final
String
identifier
;
}
class
SimDevice
{
SimDevice
(
this
.
category
,
this
.
data
);
class
Booted
SimDevice
{
Booted
SimDevice
(
this
.
category
,
this
.
data
);
final
String
category
;
final
Map
<
String
,
Object
?>
data
;
String
?
get
state
=>
data
[
'state'
]?.
toString
();
String
?
get
availability
=>
data
[
'availability'
]?.
toString
();
String
?
get
name
=>
data
[
'name'
]?.
toString
();
String
?
get
udid
=>
data
[
'udid'
]?.
toString
();
bool
get
isBooted
=>
state
==
'Booted'
;
}
class
IOSSimulator
extends
Device
{
...
...
packages/flutter_tools/lib/src/macos/xcode.dart
View file @
167655e8
...
...
@@ -136,7 +136,7 @@ class Xcode {
// This command will error if additional components need to be installed in
// xcode 9.2 and above.
final
RunResult
result
=
_processUtils
.
runSync
(
<
String
>[...
xcrunCommand
(),
'simctl'
,
'list'
],
<
String
>[...
xcrunCommand
(),
'simctl'
,
'list'
,
'devices'
,
'booted'
],
);
_isSimctlInstalled
=
result
.
exitCode
==
0
;
}
on
ProcessException
{
...
...
packages/flutter_tools/test/general.shard/ios/ios_workflow_test.dart
View file @
167655e8
...
...
@@ -49,10 +49,18 @@ void main() {
expect
(
iosWorkflow
.
canListDevices
,
false
);
});
testWithoutContext
(
'iOS workflow applies on macOS, no Xcode'
,
()
{
testWithoutContext
(
'iOS workflow applies on macOS, no Xcode or simctl'
,
()
{
final
FakeProcessManager
xcodeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
,
'devices'
,
'booted'
,
],
exitCode:
1
,
),
]);
final
IOSWorkflow
iosWorkflow
=
IOSWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'macos'
),
xcode:
Xcode
.
test
(
processManager:
FakeProcessManager
.
any
()
,
xcode:
Xcode
.
test
(
processManager:
xcodeProcessManager
,
xcodeProjectInterpreter:
XcodeProjectInterpreter
.
test
(
processManager:
FakeProcessManager
.
any
(),
version:
null
,
...
...
@@ -65,9 +73,33 @@ void main() {
expect
(
iosWorkflow
.
canLaunchDevices
,
false
);
expect
(
iosWorkflow
.
canListDevices
,
false
);
expect
(
iosWorkflow
.
canListEmulators
,
false
);
expect
(
xcodeProcessManager
,
hasNoRemainingExpectations
);
});
testWithoutContext
(
'iOS workflow can list devices even when Xcode version is too low'
,
()
{
final
Xcode
xcode
=
Xcode
.
test
(
processManager:
FakeProcessManager
.
any
(),
xcodeProjectInterpreter:
XcodeProjectInterpreter
.
test
(
processManager:
FakeProcessManager
.
any
(),
version:
Version
(
1
,
0
,
0
)
),
);
final
IOSWorkflow
iosWorkflow
=
IOSWorkflow
(
platform:
FakePlatform
(
operatingSystem:
'macos'
),
xcode:
xcode
,
featureFlags:
TestFeatureFlags
(),
);
// Make sure we're testing the right Xcode state.
// expect(xcode.isInstalledAndMeetsVersionCheck, true);
expect
(
xcode
.
isSimctlInstalled
,
true
);
expect
(
iosWorkflow
.
canLaunchDevices
,
false
);
expect
(
iosWorkflow
.
canListDevices
,
true
);
expect
(
iosWorkflow
.
canListEmulators
,
false
);
});
testWithoutContext
(
'iOS workflow can launch
and list
devices when Xcode is set up'
,
()
{
testWithoutContext
(
'iOS workflow can launch devices when Xcode is set up'
,
()
{
final
Xcode
xcode
=
Xcode
.
test
(
processManager:
FakeProcessManager
.
any
(),
xcodeProjectInterpreter:
XcodeProjectInterpreter
.
test
(
...
...
packages/flutter_tools/test/general.shard/ios/simulators_test.dart
View file @
167655e8
...
...
@@ -724,28 +724,43 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
const
String
validSimControlOutput
=
'''
{
"devices" : {
"
watchOS 4.3
" : [
"
com.apple.CoreSimulator.SimRuntime.iOS-14-0
" : [
{
"state" : "Shutdown",
"availability" : "(available)",
"name" : "Apple Watch - 38mm",
"udid" : "TEST-WATCH-UDID"
"dataPathSize" : 1734569984,
"udid" : "iPhone 11-UDID",
"isAvailable" : true,
"logPathSize" : 9506816,
"deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-11",
"state" : "Booted",
"name" : "iPhone 11"
}
],
"iOS 11.4" : [
"com.apple.CoreSimulator.SimRuntime.iOS-13-0" : [
],
"com.apple.CoreSimulator.SimRuntime.iOS-12-4" : [
],
"com.apple.CoreSimulator.SimRuntime.tvOS-16-0" : [
],
"com.apple.CoreSimulator.SimRuntime.watchOS-9-0" : [
],
"com.apple.CoreSimulator.SimRuntime.iOS-16-0" : [
{
"dataPathSize" : 552366080,
"udid" : "Phone w Watch-UDID",
"isAvailable" : true,
"logPathSize" : 90112,
"deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-11",
"state" : "Booted",
"availability" : "(available)",
"name" : "iPhone 5s",
"udid" : "TEST-PHONE-UDID"
}
],
"tvOS 11.4" : [
"name" : "Phone w Watch"
},
{
"state" : "Shutdown",
"availability" : "(available)",
"name" : "Apple TV",
"udid" : "TEST-TV-UDID"
"dataPathSize" : 2186457088,
"udid" : "iPhone 13-UDID",
"isAvailable" : true,
"logPathSize" : 151552,
"deviceTypeIdentifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-13",
"state" : "Booted",
"name" : "iPhone 13"
}
]
}
...
...
@@ -768,59 +783,54 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
);
});
testWithoutContext
(
'getDevices succeeds'
,
()
async
{
testWithoutContext
(
'get
Connected
Devices succeeds'
,
()
async
{
fakeProcessManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
,
'--json'
,
'devices'
,
'booted'
,
'iOS'
,
'--json'
,
],
stdout:
validSimControlOutput
,
));
final
List
<
SimDevice
>
devices
=
await
simControl
.
getDevices
();
final
SimDevice
watch
=
devices
[
0
];
expect
(
watch
.
category
,
'watchOS 4.3'
);
expect
(
watch
.
state
,
'Shutdown'
);
expect
(
watch
.
availability
,
'(available)'
);
expect
(
watch
.
name
,
'Apple Watch - 38mm'
);
expect
(
watch
.
udid
,
'TEST-WATCH-UDID'
);
expect
(
watch
.
isBooted
,
isFalse
);
final
SimDevice
phone
=
devices
[
1
];
expect
(
phone
.
category
,
'iOS 11.4'
);
expect
(
phone
.
state
,
'Booted'
);
expect
(
phone
.
availability
,
'(available)'
);
expect
(
phone
.
name
,
'iPhone 5s'
);
expect
(
phone
.
udid
,
'TEST-PHONE-UDID'
);
expect
(
phone
.
isBooted
,
isTrue
);
final
SimDevice
tv
=
devices
[
2
];
expect
(
tv
.
category
,
'tvOS 11.4'
);
expect
(
tv
.
state
,
'Shutdown'
);
expect
(
tv
.
availability
,
'(available)'
);
expect
(
tv
.
name
,
'Apple TV'
);
expect
(
tv
.
udid
,
'TEST-TV-UDID'
);
expect
(
tv
.
isBooted
,
isFalse
);
final
List
<
BootedSimDevice
>
devices
=
await
simControl
.
getConnectedDevices
();
final
BootedSimDevice
phone1
=
devices
[
0
];
expect
(
phone1
.
category
,
'com.apple.CoreSimulator.SimRuntime.iOS-14-0'
);
expect
(
phone1
.
name
,
'iPhone 11'
);
expect
(
phone1
.
udid
,
'iPhone 11-UDID'
);
final
BootedSimDevice
phone2
=
devices
[
1
];
expect
(
phone2
.
category
,
'com.apple.CoreSimulator.SimRuntime.iOS-16-0'
);
expect
(
phone2
.
name
,
'Phone w Watch'
);
expect
(
phone2
.
udid
,
'Phone w Watch-UDID'
);
final
BootedSimDevice
phone3
=
devices
[
2
];
expect
(
phone3
.
category
,
'com.apple.CoreSimulator.SimRuntime.iOS-16-0'
);
expect
(
phone3
.
name
,
'iPhone 13'
);
expect
(
phone3
.
udid
,
'iPhone 13-UDID'
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
});
testWithoutContext
(
'getDevices handles bad simctl output'
,
()
async
{
testWithoutContext
(
'get
Connected
Devices handles bad simctl output'
,
()
async
{
fakeProcessManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
,
'--json'
,
'devices'
,
'booted'
,
'iOS'
,
'--json'
,
],
stdout:
'Install Started'
,
));
final
List
<
SimDevice
>
devices
=
await
simControl
.
get
Devices
();
final
List
<
BootedSimDevice
>
devices
=
await
simControl
.
getConnected
Devices
();
expect
(
devices
,
isEmpty
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
...
...
packages/flutter_tools/test/general.shard/macos/xcode_test.dart
View file @
167655e8
...
...
@@ -59,6 +59,8 @@ void main() {
'xcrun'
,
'simctl'
,
'list'
,
'devices'
,
'booted'
,
],
),
);
...
...
@@ -78,6 +80,8 @@ void main() {
'xcrun'
,
'simctl'
,
'list'
,
'devices'
,
'booted'
,
],
exitCode:
1
,
),
...
...
packages/flutter_tools/test/general.shard/macos/xcode_validator_test.dart
View file @
167655e8
...
...
@@ -98,7 +98,7 @@ void main() {
'Xcode EULA has not been accepted.
\n
Launch Xcode and accept the license.'
,
),
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
],
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
,
'devices'
,
'booted'
],
),
]);
final
Xcode
xcode
=
Xcode
.
test
(
...
...
@@ -135,7 +135,7 @@ void main() {
command:
<
String
>[
'xcrun'
,
'clang'
],
),
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
],
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
,
'devices'
,
'booted'
],
exitCode:
1
,
),
]);
...
...
@@ -173,7 +173,7 @@ void main() {
command:
<
String
>[
'xcrun'
,
'clang'
],
),
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
],
command:
<
String
>[
'xcrun'
,
'simctl'
,
'list'
,
'devices'
,
'booted'
],
),
]);
final
Xcode
xcode
=
Xcode
.
test
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment