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
2d9902d9
Unverified
Commit
2d9902d9
authored
Mar 18, 2020
by
Christopher Fujino
Committed by
GitHub
Mar 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup ios devices (#52568)
parent
dc8ffe04
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
289 additions
and
177 deletions
+289
-177
device.dart
packages/flutter_tools/lib/src/device.dart
+5
-1
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+61
-46
ios_workflow.dart
packages/flutter_tools/lib/src/ios/ios_workflow.dart
+0
-4
xcode.dart
packages/flutter_tools/lib/src/macos/xcode.dart
+1
-0
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+222
-126
No files found.
packages/flutter_tools/lib/src/device.dart
View file @
2d9902d9
...
@@ -76,7 +76,11 @@ class DeviceManager {
...
@@ -76,7 +76,11 @@ class DeviceManager {
androidWorkflow:
androidWorkflow
,
androidWorkflow:
androidWorkflow
,
processManager:
globals
.
processManager
,
processManager:
globals
.
processManager
,
),
),
IOSDevices
(),
IOSDevices
(
platform:
globals
.
platform
,
xcdevice:
globals
.
xcdevice
,
iosWorkflow:
globals
.
iosWorkflow
,
),
IOSSimulators
(
iosSimulatorUtils:
globals
.
iosSimulatorUtils
),
IOSSimulators
(
iosSimulatorUtils:
globals
.
iosSimulatorUtils
),
FuchsiaDevices
(),
FuchsiaDevices
(),
FlutterTesterDevices
(),
FlutterTesterDevices
(),
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
2d9902d9
...
@@ -27,25 +27,51 @@ import '../protocol_discovery.dart';
...
@@ -27,25 +27,51 @@ import '../protocol_discovery.dart';
import
'../vmservice.dart'
;
import
'../vmservice.dart'
;
import
'fallback_discovery.dart'
;
import
'fallback_discovery.dart'
;
import
'ios_deploy.dart'
;
import
'ios_deploy.dart'
;
import
'ios_workflow.dart'
;
import
'mac.dart'
;
import
'mac.dart'
;
class
IOSDevices
extends
PollingDeviceDiscovery
{
class
IOSDevices
extends
PollingDeviceDiscovery
{
IOSDevices
()
:
super
(
'iOS devices'
);
// TODO(fujino): make these required and remove fallbacks once internal invocations migrated
IOSDevices
({
Platform
platform
,
XCDevice
xcdevice
,
IOSWorkflow
iosWorkflow
,
})
:
_platform
=
platform
??
globals
.
platform
,
_xcdevice
=
xcdevice
??
globals
.
xcdevice
,
_iosWorkflow
=
iosWorkflow
??
globals
.
iosWorkflow
,
super
(
'iOS devices'
);
final
Platform
_platform
;
final
XCDevice
_xcdevice
;
final
IOSWorkflow
_iosWorkflow
;
@override
@override
bool
get
supportsPlatform
=>
globals
.
platform
.
isMacOS
;
bool
get
supportsPlatform
=>
_
platform
.
isMacOS
;
@override
@override
bool
get
canListAnything
=>
globals
.
iosWorkflow
.
canListDevices
;
bool
get
canListAnything
=>
_
iosWorkflow
.
canListDevices
;
@override
@override
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
{
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
async
{
return
IOSDevice
.
getAttachedDevices
(
if
(!
_platform
.
isMacOS
)
{
globals
.
platform
,
globals
.
xcdevice
,
timeout:
timeout
);
throw
UnsupportedError
(
'Control of iOS devices or simulators only supported on macOS.'
);
}
return
await
_xcdevice
.
getAvailableTetheredIOSDevices
(
timeout:
timeout
);
}
}
@override
@override
Future
<
List
<
String
>>
getDiagnostics
()
=>
IOSDevice
.
getDiagnostics
(
globals
.
platform
,
globals
.
xcdevice
);
Future
<
List
<
String
>>
getDiagnostics
()
async
{
if
(!
_platform
.
isMacOS
)
{
return
const
<
String
>[
'Control of iOS devices or simulators only supported on macOS.'
];
}
return
await
_xcdevice
.
getDiagnostics
();
}
}
}
class
IOSDevice
extends
Device
{
class
IOSDevice
extends
Device
{
...
@@ -57,10 +83,13 @@ class IOSDevice extends Device {
...
@@ -57,10 +83,13 @@ class IOSDevice extends Device {
@required
Platform
platform
,
@required
Platform
platform
,
@required
Artifacts
artifacts
,
@required
Artifacts
artifacts
,
@required
IOSDeploy
iosDeploy
,
@required
IOSDeploy
iosDeploy
,
@required
Logger
logger
,
})
})
:
_sdkVersion
=
sdkVersion
,
:
_sdkVersion
=
sdkVersion
,
_iosDeploy
=
iosDeploy
,
_iosDeploy
=
iosDeploy
,
_fileSystem
=
fileSystem
,
_fileSystem
=
fileSystem
,
_logger
=
logger
,
_platform
=
platform
,
super
(
super
(
id
,
id
,
category:
Category
.
mobile
,
category:
Category
.
mobile
,
...
@@ -82,6 +111,8 @@ class IOSDevice extends Device {
...
@@ -82,6 +111,8 @@ class IOSDevice extends Device {
final
String
_sdkVersion
;
final
String
_sdkVersion
;
final
IOSDeploy
_iosDeploy
;
final
IOSDeploy
_iosDeploy
;
final
FileSystem
_fileSystem
;
final
FileSystem
_fileSystem
;
final
Logger
_logger
;
final
Platform
_platform
;
/// May be 0 if version cannot be parsed.
/// May be 0 if version cannot be parsed.
int
get
majorSdkVersion
{
int
get
majorSdkVersion
{
...
@@ -113,22 +144,6 @@ class IOSDevice extends Device {
...
@@ -113,22 +144,6 @@ class IOSDevice extends Device {
@override
@override
bool
get
supportsStartPaused
=>
false
;
bool
get
supportsStartPaused
=>
false
;
static
Future
<
List
<
IOSDevice
>>
getAttachedDevices
(
Platform
platform
,
XCDevice
xcdevice
,
{
Duration
timeout
})
async
{
if
(!
platform
.
isMacOS
)
{
throw
UnsupportedError
(
'Control of iOS devices or simulators only supported on macOS.'
);
}
return
await
xcdevice
.
getAvailableTetheredIOSDevices
(
timeout:
timeout
);
}
static
Future
<
List
<
String
>>
getDiagnostics
(
Platform
platform
,
XCDevice
xcdevice
)
async
{
if
(!
platform
.
isMacOS
)
{
return
const
<
String
>[
'Control of iOS devices or simulators only supported on macOS.'
];
}
return
await
xcdevice
.
getDiagnostics
();
}
@override
@override
Future
<
bool
>
isAppInstalled
(
IOSApp
app
)
async
{
Future
<
bool
>
isAppInstalled
(
IOSApp
app
)
async
{
bool
result
;
bool
result
;
...
@@ -138,7 +153,7 @@ class IOSDevice extends Device {
...
@@ -138,7 +153,7 @@ class IOSDevice extends Device {
deviceId:
id
,
deviceId:
id
,
);
);
}
on
ProcessException
catch
(
e
)
{
}
on
ProcessException
catch
(
e
)
{
globals
.
printError
(
e
.
message
);
_logger
.
printError
(
e
.
message
);
return
false
;
return
false
;
}
}
return
result
;
return
result
;
...
@@ -151,7 +166,7 @@ class IOSDevice extends Device {
...
@@ -151,7 +166,7 @@ class IOSDevice extends Device {
Future
<
bool
>
installApp
(
IOSApp
app
)
async
{
Future
<
bool
>
installApp
(
IOSApp
app
)
async
{
final
Directory
bundle
=
_fileSystem
.
directory
(
app
.
deviceBundlePath
);
final
Directory
bundle
=
_fileSystem
.
directory
(
app
.
deviceBundlePath
);
if
(!
bundle
.
existsSync
())
{
if
(!
bundle
.
existsSync
())
{
globals
.
printError
(
'Could not find application bundle at
${bundle.path}
; have you run "flutter build ios"?'
);
_logger
.
printError
(
'Could not find application bundle at
${bundle.path}
; have you run "flutter build ios"?'
);
return
false
;
return
false
;
}
}
...
@@ -163,14 +178,14 @@ class IOSDevice extends Device {
...
@@ -163,14 +178,14 @@ class IOSDevice extends Device {
launchArguments:
<
String
>[],
launchArguments:
<
String
>[],
);
);
}
on
ProcessException
catch
(
e
)
{
}
on
ProcessException
catch
(
e
)
{
globals
.
printError
(
e
.
message
);
_logger
.
printError
(
e
.
message
);
return
false
;
return
false
;
}
}
if
(
installationResult
!=
0
)
{
if
(
installationResult
!=
0
)
{
globals
.
printError
(
'Could not install
${bundle.path}
on
$id
.'
);
_logger
.
printError
(
'Could not install
${bundle.path}
on
$id
.'
);
globals
.
printError
(
'Try launching Xcode and selecting "Product > Run" to fix the problem:'
);
_logger
.
printError
(
'Try launching Xcode and selecting "Product > Run" to fix the problem:'
);
globals
.
printError
(
' open ios/Runner.xcworkspace'
);
_logger
.
printError
(
' open ios/Runner.xcworkspace'
);
globals
.
printError
(
''
);
_logger
.
printError
(
''
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -185,11 +200,11 @@ class IOSDevice extends Device {
...
@@ -185,11 +200,11 @@ class IOSDevice extends Device {
bundleId:
app
.
id
,
bundleId:
app
.
id
,
);
);
}
on
ProcessException
catch
(
e
)
{
}
on
ProcessException
catch
(
e
)
{
globals
.
printError
(
e
.
message
);
_logger
.
printError
(
e
.
message
);
return
false
;
return
false
;
}
}
if
(
uninstallationResult
!=
0
)
{
if
(
uninstallationResult
!=
0
)
{
globals
.
printError
(
'Could not uninstall
${app.id}
on
$id
.'
);
_logger
.
printError
(
'Could not uninstall
${app.id}
on
$id
.'
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -212,7 +227,7 @@ class IOSDevice extends Device {
...
@@ -212,7 +227,7 @@ class IOSDevice extends Device {
if
(!
prebuiltApplication
)
{
if
(!
prebuiltApplication
)
{
// TODO(chinmaygarde): Use mainPath, route.
// TODO(chinmaygarde): Use mainPath, route.
globals
.
printTrace
(
'Building
${package.name}
for
$id
'
);
_logger
.
printTrace
(
'Building
${package.name}
for
$id
'
);
// Step 1: Build the precompiled/DBC application if necessary.
// Step 1: Build the precompiled/DBC application if necessary.
final
XcodeBuildResult
buildResult
=
await
buildXcodeProject
(
final
XcodeBuildResult
buildResult
=
await
buildXcodeProject
(
...
@@ -223,9 +238,9 @@ class IOSDevice extends Device {
...
@@ -223,9 +238,9 @@ class IOSDevice extends Device {
activeArch:
cpuArchitecture
,
activeArch:
cpuArchitecture
,
);
);
if
(!
buildResult
.
success
)
{
if
(!
buildResult
.
success
)
{
globals
.
printError
(
'Could not build the precompiled application for the device.'
);
_logger
.
printError
(
'Could not build the precompiled application for the device.'
);
await
diagnoseXcodeBuildFailure
(
buildResult
);
await
diagnoseXcodeBuildFailure
(
buildResult
);
globals
.
printError
(
''
);
_logger
.
printError
(
''
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
packageId
=
buildResult
.
xcodeBuildExecution
?.
buildSettings
[
'PRODUCT_BUNDLE_IDENTIFIER'
];
packageId
=
buildResult
.
xcodeBuildExecution
?.
buildSettings
[
'PRODUCT_BUNDLE_IDENTIFIER'
];
...
@@ -240,7 +255,7 @@ class IOSDevice extends Device {
...
@@ -240,7 +255,7 @@ class IOSDevice extends Device {
// Step 2: Check that the application exists at the specified path.
// Step 2: Check that the application exists at the specified path.
final
Directory
bundle
=
_fileSystem
.
directory
(
package
.
deviceBundlePath
);
final
Directory
bundle
=
_fileSystem
.
directory
(
package
.
deviceBundlePath
);
if
(!
bundle
.
existsSync
())
{
if
(!
bundle
.
existsSync
())
{
globals
.
printError
(
'Could not find the built application bundle at
${bundle.path}
.'
);
_logger
.
printError
(
'Could not find the built application bundle at
${bundle.path}
.'
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
...
@@ -267,7 +282,7 @@ class IOSDevice extends Device {
...
@@ -267,7 +282,7 @@ class IOSDevice extends Device {
// "system_debug_ios" integration test in the CI, which simulates a
// "system_debug_ios" integration test in the CI, which simulates a
// home-screen launch.
// home-screen launch.
if
(
debuggingOptions
.
debuggingEnabled
&&
if
(
debuggingOptions
.
debuggingEnabled
&&
globals
.
platform
.
environment
[
'FLUTTER_TOOLS_DEBUG_WITHOUT_CHECKED_MODE'
]
!=
'true'
)
...<
String
>[
_
platform
.
environment
[
'FLUTTER_TOOLS_DEBUG_WITHOUT_CHECKED_MODE'
]
!=
'true'
)
...<
String
>[
'--enable-checked-mode'
,
'--enable-checked-mode'
,
'--verify-entry-points'
,
'--verify-entry-points'
,
],
],
...
@@ -282,13 +297,13 @@ class IOSDevice extends Device {
...
@@ -282,13 +297,13 @@ class IOSDevice extends Device {
if
(
platformArgs
[
'trace-startup'
]
as
bool
??
false
)
'--trace-startup'
,
if
(
platformArgs
[
'trace-startup'
]
as
bool
??
false
)
'--trace-startup'
,
];
];
final
Status
installStatus
=
globals
.
logger
.
startProgress
(
final
Status
installStatus
=
_
logger
.
startProgress
(
'Installing and launching...'
,
'Installing and launching...'
,
timeout:
timeoutConfiguration
.
slowOperation
);
timeout:
timeoutConfiguration
.
slowOperation
);
try
{
try
{
ProtocolDiscovery
observatoryDiscovery
;
ProtocolDiscovery
observatoryDiscovery
;
if
(
debuggingOptions
.
debuggingEnabled
)
{
if
(
debuggingOptions
.
debuggingEnabled
)
{
globals
.
printTrace
(
'Debugging is enabled, connecting to observatory'
);
_logger
.
printTrace
(
'Debugging is enabled, connecting to observatory'
);
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
getLogReader
(
app:
package
),
getLogReader
(
app:
package
),
portForwarder:
portForwarder
,
portForwarder:
portForwarder
,
...
@@ -303,10 +318,10 @@ class IOSDevice extends Device {
...
@@ -303,10 +318,10 @@ class IOSDevice extends Device {
launchArguments:
launchArguments
,
launchArguments:
launchArguments
,
);
);
if
(
installationResult
!=
0
)
{
if
(
installationResult
!=
0
)
{
globals
.
printError
(
'Could not run
${bundle.path}
on
$id
.'
);
_logger
.
printError
(
'Could not run
${bundle.path}
on
$id
.'
);
globals
.
printError
(
'Try launching Xcode and selecting "Product > Run" to fix the problem:'
);
_logger
.
printError
(
'Try launching Xcode and selecting "Product > Run" to fix the problem:'
);
globals
.
printError
(
' open ios/Runner.xcworkspace'
);
_logger
.
printError
(
' open ios/Runner.xcworkspace'
);
globals
.
printError
(
''
);
_logger
.
printError
(
''
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
...
@@ -314,9 +329,9 @@ class IOSDevice extends Device {
...
@@ -314,9 +329,9 @@ class IOSDevice extends Device {
return
LaunchResult
.
succeeded
();
return
LaunchResult
.
succeeded
();
}
}
globals
.
printTrace
(
'Application launched on the device. Waiting for observatory port.'
);
_logger
.
printTrace
(
'Application launched on the device. Waiting for observatory port.'
);
final
FallbackDiscovery
fallbackDiscovery
=
FallbackDiscovery
(
final
FallbackDiscovery
fallbackDiscovery
=
FallbackDiscovery
(
logger:
globals
.
logger
,
logger:
_
logger
,
mDnsObservatoryDiscovery:
MDnsObservatoryDiscovery
.
instance
,
mDnsObservatoryDiscovery:
MDnsObservatoryDiscovery
.
instance
,
portForwarder:
portForwarder
,
portForwarder:
portForwarder
,
protocolDiscovery:
observatoryDiscovery
,
protocolDiscovery:
observatoryDiscovery
,
...
@@ -334,7 +349,7 @@ class IOSDevice extends Device {
...
@@ -334,7 +349,7 @@ class IOSDevice extends Device {
}
}
return
LaunchResult
.
succeeded
(
observatoryUri:
localUri
);
return
LaunchResult
.
succeeded
(
observatoryUri:
localUri
);
}
on
ProcessException
catch
(
e
)
{
}
on
ProcessException
catch
(
e
)
{
globals
.
printError
(
e
.
message
);
_logger
.
printError
(
e
.
message
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
finally
{
}
finally
{
installStatus
.
stop
();
installStatus
.
stop
();
...
...
packages/flutter_tools/lib/src/ios/ios_workflow.dart
View file @
2d9902d9
...
@@ -2,13 +2,9 @@
...
@@ -2,13 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'../base/context.dart'
;
import
'../doctor.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
// TODO(fujino): remove once internal references replaced by `globals.iosWorkflow`
IOSWorkflow
get
iosWorkflow
=>
context
.
get
<
IOSWorkflow
>();
class
IOSWorkflow
implements
Workflow
{
class
IOSWorkflow
implements
Workflow
{
const
IOSWorkflow
();
const
IOSWorkflow
();
...
...
packages/flutter_tools/lib/src/macos/xcode.dart
View file @
2d9902d9
...
@@ -354,6 +354,7 @@ class XCDevice {
...
@@ -354,6 +354,7 @@ class XCDevice {
sdkVersion:
_sdkVersion
(
deviceProperties
),
sdkVersion:
_sdkVersion
(
deviceProperties
),
artifacts:
globals
.
artifacts
,
artifacts:
globals
.
artifacts
,
fileSystem:
globals
.
fs
,
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
iosDeploy:
globals
.
iosDeploy
,
iosDeploy:
globals
.
iosDeploy
,
platform:
globals
.
platform
,
platform:
globals
.
platform
,
));
));
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
2d9902d9
This diff is collapsed.
Click to expand it.
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