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
01dc19b9
Unverified
Commit
01dc19b9
authored
Oct 29, 2019
by
Jenn Magder
Committed by
GitHub
Oct 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass environment variables through to xcodebuild (#43553)
parent
19e551c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
2 deletions
+90
-2
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+1
-0
xcodeproj.dart
packages/flutter_tools/lib/src/ios/xcodeproj.dart
+18
-1
build_macos.dart
packages/flutter_tools/lib/src/macos/build_macos.dart
+1
-0
xcodeproj_test.dart
.../flutter_tools/test/general.shard/ios/xcodeproj_test.dart
+70
-1
No files found.
packages/flutter_tools/lib/src/ios/mac.dart
View file @
01dc19b9
...
...
@@ -464,6 +464,7 @@ Future<XcodeBuildResult> buildXcodeProject({
// e.g. `flutter build bundle`.
buildCommands
.
add
(
'FLUTTER_SUPPRESS_ANALYTICS=true'
);
buildCommands
.
add
(
'COMPILER_INDEX_STORE_ENABLE=NO'
);
buildCommands
.
addAll
(
environmentVariablesAsXcodeBuildSettings
());
final
Stopwatch
sw
=
Stopwatch
()..
start
();
initialBuildStatus
=
logger
.
startProgress
(
'Running Xcode build...'
,
timeout:
timeoutConfiguration
.
fastOperation
);
...
...
packages/flutter_tools/lib/src/ios/xcodeproj.dart
View file @
01dc19b9
...
...
@@ -293,9 +293,10 @@ class XcodeProjectInterpreter {
'-target'
,
target
,
'-showBuildSettings'
,
...
environmentVariablesAsXcodeBuildSettings
()
];
try
{
// showBuildSettings is reported to oc
as
sionally timeout. Here, we give it
// showBuildSettings is reported to oc
ca
sionally timeout. Here, we give it
// a lot of wiggle room (locally on Flutter Gallery, this takes ~1s).
// When there is a timeout, we retry once.
final
RunResult
result
=
await
processUtils
.
run
(
...
...
@@ -329,6 +330,7 @@ class XcodeProjectInterpreter {
scheme
,
'-quiet'
,
'clean'
,
...
environmentVariablesAsXcodeBuildSettings
()
],
workingDirectory:
fs
.
currentDirectory
.
path
);
}
...
...
@@ -354,6 +356,21 @@ class XcodeProjectInterpreter {
}
}
/// Environment variables prefixed by FLUTTER_XCODE_ will be passed as build configurations to xcodebuild.
/// This allows developers to pass arbitrary build settings in without the tool needing to make a flag
/// for or be aware of each one. This could be used to set code signing build settings in a CI
/// environment without requiring settings changes in the Xcode project.
List
<
String
>
environmentVariablesAsXcodeBuildSettings
()
{
const
String
xcodeBuildSettingPrefix
=
'FLUTTER_XCODE_'
;
return
platform
.
environment
.
entries
.
where
((
MapEntry
<
String
,
String
>
mapEntry
)
{
return
mapEntry
.
key
.
startsWith
(
xcodeBuildSettingPrefix
);
}).
expand
<
String
>((
MapEntry
<
String
,
String
>
mapEntry
)
{
// Remove FLUTTER_XCODE_ prefix from the environment variable to get the build setting.
final
String
trimmedBuildSettingKey
=
mapEntry
.
key
.
substring
(
xcodeBuildSettingPrefix
.
length
);
return
<
String
>[
'
$trimmedBuildSettingKey
=
${mapEntry.value}
'
];
}).
toList
();
}
Map
<
String
,
String
>
parseXcodeBuildSettings
(
String
showBuildSettingsOutput
)
{
final
Map
<
String
,
String
>
settings
=
<
String
,
String
>{};
for
(
Match
match
in
showBuildSettingsOutput
.
split
(
'
\n
'
).
map
<
Match
>(
_settingExpr
.
firstMatch
))
{
...
...
packages/flutter_tools/lib/src/macos/build_macos.dart
View file @
01dc19b9
...
...
@@ -79,6 +79,7 @@ Future<void> buildMacOS({
'OBJROOT=
${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}
'
,
'SYMROOT=
${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}
'
,
'COMPILER_INDEX_STORE_ENABLE=NO'
,
...
environmentVariablesAsXcodeBuildSettings
()
],
trace:
true
);
}
finally
{
status
.
cancel
();
...
...
packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
View file @
01dc19b9
...
...
@@ -23,7 +23,7 @@ import '../../src/pubspec_schema.dart';
const
String
xcodebuild
=
'/usr/bin/xcodebuild'
;
void
main
(
)
{
group
(
'xcodebuild
versioning
'
,
()
{
group
(
'xcodebuild
commands
'
,
()
{
mocks
.
MockProcessManager
mockProcessManager
;
XcodeProjectInterpreter
xcodeProjectInterpreter
;
FakePlatform
macOS
;
...
...
@@ -172,6 +172,54 @@ void main() {
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingOsxContext
(
'build settings contains Flutter Xcode environment variables'
,
()
async
{
macOS
.
environment
=
Map
<
String
,
String
>.
unmodifiable
(<
String
,
String
>{
'FLUTTER_XCODE_CODE_SIGN_STYLE'
:
'Manual'
,
'FLUTTER_XCODE_ARCHS'
:
'arm64'
});
when
(
mockProcessManager
.
runSync
(<
String
>[
xcodebuild
,
'-project'
,
macOS
.
pathSeparator
,
'-target'
,
''
,
'-showBuildSettings'
,
'CODE_SIGN_STYLE=Manual'
,
'ARCHS=arm64'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
)))
.
thenReturn
(
ProcessResult
(
1
,
0
,
''
,
''
));
expect
(
await
xcodeProjectInterpreter
.
getBuildSettings
(
''
,
''
),
const
<
String
,
String
>{});
});
testUsingOsxContext
(
'clean contains Flutter Xcode environment variables'
,
()
async
{
macOS
.
environment
=
Map
<
String
,
String
>.
unmodifiable
(<
String
,
String
>{
'FLUTTER_XCODE_CODE_SIGN_STYLE'
:
'Manual'
,
'FLUTTER_XCODE_ARCHS'
:
'arm64'
});
when
(
mockProcessManager
.
runSync
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
)))
.
thenReturn
(
ProcessResult
(
1
,
0
,
''
,
''
));
xcodeProjectInterpreter
.
cleanWorkspace
(
'workspace_path'
,
'Runner'
);
final
List
<
dynamic
>
captured
=
verify
(
mockProcessManager
.
runSync
(
captureAny
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
))).
captured
;
expect
(
captured
.
first
,
<
String
>[
xcodebuild
,
'-workspace'
,
'workspace_path'
,
'-scheme'
,
'Runner'
,
'-quiet'
,
'clean'
,
'CODE_SIGN_STYLE=Manual'
,
'ARCHS=arm64'
]);
});
});
group
(
'xcodebuild -list'
,
()
{
...
...
@@ -338,6 +386,27 @@ Information about project "Runner":
});
});
group
(
'environmentVariablesAsXcodeBuildSettings'
,
()
{
FakePlatform
platform
;
setUp
(()
{
platform
=
fakePlatform
(
'ignored'
);
});
testUsingContext
(
'environment variables as Xcode build settings'
,
()
{
platform
.
environment
=
Map
<
String
,
String
>.
unmodifiable
(<
String
,
String
>{
'Ignored'
:
'Bogus'
,
'FLUTTER_NOT_XCODE'
:
'Bogus'
,
'FLUTTER_XCODE_CODE_SIGN_STYLE'
:
'Manual'
,
'FLUTTER_XCODE_ARCHS'
:
'arm64'
});
final
List
<
String
>
environmentVariablesAsBuildSettings
=
environmentVariablesAsXcodeBuildSettings
();
expect
(
environmentVariablesAsBuildSettings
,
<
String
>[
'CODE_SIGN_STYLE=Manual'
,
'ARCHS=arm64'
]);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
platform
});
});
group
(
'updateGeneratedXcodeProperties'
,
()
{
MockLocalEngineArtifacts
mockArtifacts
;
MockProcessManager
mockProcessManager
;
...
...
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