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
602a3561
Commit
602a3561
authored
Jan 15, 2016
by
Chinmay Garde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `flutter start` for iOS simulator
parent
02f423f5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
27 deletions
+63
-27
device.dart
packages/flutter_tools/lib/src/device.dart
+63
-27
No files found.
packages/flutter_tools/lib/src/device.dart
View file @
602a3561
...
...
@@ -187,20 +187,12 @@ class IOSDevice extends Device {
return
false
;
}
Future
<
bool
>
buildPrecompiledApplication
(
ApplicationPackage
app
)
async
{
int
result
=
await
runCommandAndStreamOutput
([
'/usr/bin/env'
,
'xcrun'
,
'xcodebuild'
,
'-target'
,
'Runner'
,
'-configuration'
,
'Release'
],
workingDirectory:
app
.
localPath
);
return
result
==
0
;
}
@override
Future
<
bool
>
startApp
(
ApplicationPackage
app
)
async
{
logging
.
fine
(
"Attempting to build and install
${app.name}
on
$id
"
);
// Step 1: Install the precompiled application if necessary
bool
buildResult
=
await
buildPrecompiledApplication
(
app
);
bool
buildResult
=
await
_buildIOSXcodeProject
(
app
,
true
);
if
(!
buildResult
)
{
logging
.
severe
(
'Could not build the precompiled application for the device'
);
...
...
@@ -257,11 +249,6 @@ class IOSDevice extends Device {
]);
return
true
;
}
else
{
// TODO(iansf): It may be possible to make this work on Linux. Since this
// functionality appears to be the only that prevents us from
// supporting iOS on Linux, it may be worth putting some time
// into investigating this.
// See https://bbs.archlinux.org/viewtopic.php?id=192655
return
false
;
}
return
false
;
...
...
@@ -364,8 +351,6 @@ class IOSSimulator extends Device {
List
<
IOSSimulator
>
devices
=
[];
String
id
=
_getRunningSimulatorID
(
mockIOS
);
if
(
id
!=
null
)
{
// TODO(iansf): get the simulator's name
// String name = _getDeviceName(id, mockIOS);
devices
.
add
(
new
IOSSimulator
(
id:
id
));
}
return
devices
;
...
...
@@ -448,20 +433,53 @@ class IOSSimulator extends Device {
@override
Future
<
bool
>
startApp
(
ApplicationPackage
app
)
async
{
if
(!
isAppInstalled
(
app
))
{
logging
.
fine
(
'Building
${app.name}
for
${id}
'
);
// Step 1: Build the Xcode project
bool
buildResult
=
await
_buildIOSXcodeProject
(
app
,
false
);
if
(!
buildResult
)
{
logging
.
severe
(
'Could not build the application for the simulator'
);
return
false
;
}
try
{
if
(
id
==
defaultDeviceID
)
{
runCheckedSync
(
[
xcrunPath
,
'simctl'
,
'launch'
,
'booted'
,
app
.
id
]);
}
else
{
runCheckedSync
([
xcrunPath
,
'simctl'
,
'launch'
,
id
,
app
.
id
]);
// Step 2: Assert that the Xcode project was successfully built
Directory
bundle
=
new
Directory
(
path
.
join
(
app
.
localPath
,
'build'
,
'Release-iphonesimulator'
,
'Runner.app'
));
bool
bundleExists
=
await
bundle
.
exists
();
if
(!
bundleExists
)
{
logging
.
severe
(
'Could not find the built application bundle at
${bundle.path}
'
);
return
false
;
}
return
true
;
}
catch
(
e
)
{
// Step 3: Install the updated bundle to the simulator
int
installResult
=
await
runCommandAndStreamOutput
([
xcrunPath
,
'simctl'
,
'install'
,
id
==
defaultDeviceID
?
'booted'
:
id
,
path
.
absolute
(
bundle
.
path
)
]);
if
(
installResult
!=
0
)
{
logging
.
severe
(
'Could not install the application bundle on the simulator'
);
return
false
;
}
// Step 4: Launch the updated application in the simulator
int
launchResult
=
await
runCommandAndStreamOutput
([
xcrunPath
,
'simctl'
,
'launch'
,
id
==
defaultDeviceID
?
'booted'
:
id
,
app
.
id
]);
if
(
launchResult
!=
0
)
{
logging
.
severe
(
'Could not launch the freshly installed application on the simulator'
);
return
false
;
}
logging
.
fine
(
'Successfully started
${app.name}
on
$id
'
);
return
true
;
}
@override
...
...
@@ -1038,7 +1056,11 @@ class DeviceStore {
break
;
case
TargetPlatform
.
iOSSimulator
:
assert
(
iOSSimulator
==
null
);
iOSSimulator
=
_deviceForConfig
(
config
,
IOSSimulator
.
getAttachedDevices
());
if
(
iOSSimulator
==
null
)
{
// Creates a simulator with the default identifier
iOSSimulator
=
new
IOSSimulator
();
}
break
;
case
TargetPlatform
.
mac
:
case
TargetPlatform
.
linux
:
...
...
@@ -1049,3 +1071,17 @@ class DeviceStore {
return
new
DeviceStore
(
android:
android
,
iOS:
iOS
,
iOSSimulator:
iOSSimulator
);
}
}
Future
<
bool
>
_buildIOSXcodeProject
(
ApplicationPackage
app
,
bool
isDevice
)
async
{
List
<
String
>
command
=
[
'/usr/bin/env'
,
'xcrun'
,
'xcodebuild'
,
'-target'
,
'Runner'
,
'-configuration'
,
'Release'
];
if
(!
isDevice
)
{
command
.
addAll
([
'-sdk'
,
'iphonesimulator'
]);
}
int
result
=
await
runCommandAndStreamOutput
(
command
,
workingDirectory:
app
.
localPath
);
return
result
==
0
;
}
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