Move embedding and linking Flutter frameworks into the tool (#51453)
* Move embedding and linking Flutter frameworks into the tool * Unused import * Migrate * Rename run, add comments, remove typedef * Add status log to tell the user what we did * Remove Podfile migration, create IOSMigration superclass * word-smiting Co-Authored-By: Jonah Williams <jonahwilliams@google.com> * for space Co-Authored-By: Jonah Williams <jonahwilliams@google.com> Co-authored-by: Jonah Williams <jonahwilliams@google.com>
This commit is contained in:
@@ -290,7 +290,7 @@ EmbedFlutterFrameworks() {
|
||||
|
||||
# Embed App.framework from Flutter into the app (after creating the Frameworks directory
|
||||
# if it doesn't already exist).
|
||||
local xcode_frameworks_dir=${BUILT_PRODUCTS_DIR}"/"${PRODUCT_NAME}".app/Frameworks"
|
||||
local xcode_frameworks_dir="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
RunCommand mkdir -p -- "${xcode_frameworks_dir}"
|
||||
RunCommand cp -Rv -- "${flutter_ios_out_folder}/App.framework" "${xcode_frameworks_dir}"
|
||||
|
||||
@@ -302,17 +302,22 @@ EmbedFlutterFrameworks() {
|
||||
RunCommand cp -Rv -- "${flutter_ios_engine_folder}/Flutter.framework" "${xcode_frameworks_dir}/"
|
||||
|
||||
# Sign the binaries we moved.
|
||||
local identity="${EXPANDED_CODE_SIGN_IDENTITY_NAME:-$CODE_SIGN_IDENTITY}"
|
||||
if [[ -n "$identity" && "$identity" != "\"\"" ]]; then
|
||||
RunCommand codesign --force --verbose --sign "${identity}" -- "${xcode_frameworks_dir}/App.framework/App"
|
||||
RunCommand codesign --force --verbose --sign "${identity}" -- "${xcode_frameworks_dir}/Flutter.framework/Flutter"
|
||||
if [[ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]]; then
|
||||
RunCommand codesign --force --verbose --sign "${EXPANDED_CODE_SIGN_IDENTITY}" -- "${xcode_frameworks_dir}/App.framework/App"
|
||||
RunCommand codesign --force --verbose --sign "${EXPANDED_CODE_SIGN_IDENTITY}" -- "${xcode_frameworks_dir}/Flutter.framework/Flutter"
|
||||
fi
|
||||
}
|
||||
|
||||
EmbedAndThinFrameworks() {
|
||||
EmbedFlutterFrameworks
|
||||
ThinAppFrameworks
|
||||
}
|
||||
|
||||
# Main entry point.
|
||||
if [[ $# == 0 ]]; then
|
||||
# Backwards-compatibility: if no args are provided, build.
|
||||
# Backwards-compatibility: if no args are provided, build and embed.
|
||||
BuildApp
|
||||
EmbedFlutterFrameworks
|
||||
else
|
||||
case $1 in
|
||||
"build")
|
||||
@@ -321,5 +326,7 @@ else
|
||||
ThinAppFrameworks ;;
|
||||
"embed")
|
||||
EmbedFlutterFrameworks ;;
|
||||
"embed_and_thin")
|
||||
EmbedAndThinFrameworks ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -22,6 +22,8 @@ import '../macos/xcode.dart';
|
||||
import '../project.dart';
|
||||
import '../reporting/reporting.dart';
|
||||
import 'code_signing.dart';
|
||||
import 'migrations/ios_migrator.dart';
|
||||
import 'migrations/remove_framework_link_and_embedding_migration.dart';
|
||||
import 'xcodeproj.dart';
|
||||
|
||||
class IMobileDevice {
|
||||
@@ -87,6 +89,16 @@ Future<XcodeBuildResult> buildXcodeProject({
|
||||
return XcodeBuildResult(success: false);
|
||||
}
|
||||
|
||||
final List<IOSMigrator> migrators = <IOSMigrator>[
|
||||
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.xcode)
|
||||
];
|
||||
|
||||
for (final IOSMigrator migrator in migrators) {
|
||||
if (!migrator.migrate()) {
|
||||
return XcodeBuildResult(success: false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_checkXcodeVersion()) {
|
||||
return XcodeBuildResult(success: false);
|
||||
}
|
||||
@@ -439,6 +451,20 @@ Future<void> diagnoseXcodeBuildFailure(XcodeBuildResult result) async {
|
||||
).send();
|
||||
}
|
||||
|
||||
// Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS.
|
||||
// or
|
||||
// Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator.
|
||||
if (result.stdout?.contains('Building for iOS') == true
|
||||
&& result.stdout?.contains('but the linked and embedded framework') == true
|
||||
&& result.stdout?.contains('was built for iOS') == true) {
|
||||
globals.printError('');
|
||||
globals.printError('Your Xcode project requires migration. See https://github.com/flutter/flutter/issues/50568 for details.');
|
||||
globals.printError('');
|
||||
globals.printError('You can temporarily work around this issue by running:');
|
||||
globals.printError(' rm -rf ios/Flutter/App.framework');
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.xcodeBuildExecution != null &&
|
||||
result.xcodeBuildExecution.buildForPhysicalDevice &&
|
||||
result.stdout?.contains('BCEROR') == true &&
|
||||
@@ -529,6 +555,7 @@ bool _checkXcodeVersion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO(jmagman): Refactor to IOSMigrator.
|
||||
bool upgradePbxProjWithFlutterAssets(IosProject project) {
|
||||
final File xcodeProjectFile = project.xcodeProjectInfoFile;
|
||||
assert(xcodeProjectFile.existsSync());
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/logger.dart';
|
||||
|
||||
/// iOS project is generated from a template on Flutter project creation.
|
||||
/// Sometimes (due to behavior changes in Xcode, CocoaPods, etc) these files need to be altered
|
||||
/// from the original template.
|
||||
class IOSMigrator {
|
||||
IOSMigrator(this.logger);
|
||||
|
||||
@protected
|
||||
final Logger logger;
|
||||
|
||||
/// Returns whether migration was successful or was skipped.
|
||||
bool migrate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// [processLine] should return null if the line should be deleted.
|
||||
@protected
|
||||
void processFileLines(File file, String Function(String) processLine) {
|
||||
final List<String> lines = file.readAsLinesSync();
|
||||
|
||||
final StringBuffer newProjectContents = StringBuffer();
|
||||
final String basename = file.basename;
|
||||
|
||||
bool migrationRequired = false;
|
||||
for (final String line in lines) {
|
||||
final String newProjectLine = processLine(line);
|
||||
if (newProjectLine == null) {
|
||||
logger.printTrace('Migrating $basename, removing:');
|
||||
logger.printTrace(' $line');
|
||||
migrationRequired = true;
|
||||
continue;
|
||||
}
|
||||
if (newProjectLine != line) {
|
||||
logger.printTrace('Migrating $basename, replacing:');
|
||||
logger.printTrace(' $line');
|
||||
logger.printTrace('with:');
|
||||
logger.printTrace(' $newProjectLine');
|
||||
migrationRequired = true;
|
||||
}
|
||||
newProjectContents.writeln(newProjectLine);
|
||||
}
|
||||
|
||||
if (migrationRequired) {
|
||||
logger.printStatus('Upgrading $basename');
|
||||
file.writeAsStringSync(newProjectContents.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import '../../base/file_system.dart';
|
||||
import '../../base/logger.dart';
|
||||
import '../../macos/xcode.dart';
|
||||
import '../../project.dart';
|
||||
import 'ios_migrator.dart';
|
||||
|
||||
/// Xcode 11.4 requires linked and embedded frameworks to contain all targeted architectures before build phases are run.
|
||||
/// This caused issues switching between a real device and simulator due to architecture mismatch.
|
||||
/// Remove the linking and embedding logic from the Xcode project to give the tool more control over these.
|
||||
class RemoveFrameworkLinkAndEmbeddingMigration extends IOSMigrator {
|
||||
RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
IosProject project,
|
||||
Logger logger,
|
||||
Xcode xcode,
|
||||
) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile,
|
||||
_xcode = xcode,
|
||||
super(logger);
|
||||
|
||||
final File _xcodeProjectInfoFile;
|
||||
final Xcode _xcode;
|
||||
|
||||
/// Inspect [project] for necessary migrations and rewrite files as needed.
|
||||
@override
|
||||
bool migrate() {
|
||||
return _migrateXcodeProjectInfoFile();
|
||||
}
|
||||
|
||||
bool _migrateXcodeProjectInfoFile() {
|
||||
if (!_xcodeProjectInfoFile.existsSync()) {
|
||||
logger.printTrace('Xcode project not found, skipping migration');
|
||||
return true;
|
||||
}
|
||||
|
||||
bool migrationFailure = false;
|
||||
processFileLines(_xcodeProjectInfoFile, (String line) {
|
||||
// App.framework Frameworks reference.
|
||||
// isa = PBXFrameworksBuildPhase;
|
||||
// files = (
|
||||
// 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||
if (line.contains('3B80C3941E831B6300D905FE')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// App.framework Embed Framework reference (build phase to embed framework).
|
||||
// 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||
if (line.contains('3B80C3951E831B6300D905FE')
|
||||
|| line.contains('741F496821356857001E2961')) { // Ephemeral add-to-app variant.
|
||||
return null;
|
||||
}
|
||||
|
||||
// App.framework project file reference (seen in Xcode navigator pane).
|
||||
// isa = PBXGroup;
|
||||
// children = (
|
||||
// 3B80C3931E831B6300D905FE /* App.framework */,
|
||||
if (line.contains('3B80C3931E831B6300D905FE')
|
||||
|| line.contains('741F496521356807001E2961')) { // Ephemeral add-to-app variant.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Flutter.framework Frameworks reference.
|
||||
// isa = PBXFrameworksBuildPhase;
|
||||
// files = (
|
||||
// 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||
if (line.contains('9705A1C61CF904A100538489')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Flutter.framework Embed Framework reference (build phase to embed framework).
|
||||
// 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||
if (line.contains('9705A1C71CF904A300538489')
|
||||
|| line.contains('741F496221355F47001E2961')) { // Ephemeral add-to-app variant.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Flutter.framework project file reference (seen in Xcode navigator pane).
|
||||
// isa = PBXGroup;
|
||||
// children = (
|
||||
// 9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||
if (line.contains('9740EEBA1CF902C7004384FC')
|
||||
|| line.contains('741F495E21355F27001E2961')) { // Ephemeral add-to-app variant.
|
||||
return null;
|
||||
}
|
||||
|
||||
// Embed and thin frameworks in a script instead of using Xcode's link / embed build phases.
|
||||
const String thinBinaryScript = 'xcode_backend.sh\\" thin';
|
||||
if (line.contains(thinBinaryScript)) {
|
||||
return line.replaceFirst(thinBinaryScript, 'xcode_backend.sh\\" embed_and_thin');
|
||||
}
|
||||
|
||||
if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) {
|
||||
migrationFailure = true;
|
||||
}
|
||||
|
||||
return line;
|
||||
});
|
||||
|
||||
if (migrationFailure) {
|
||||
// Print scary message if the user is on Xcode 11.4 or greater, or if Xcode isn't installed.
|
||||
final bool xcodeIsInstalled = _xcode.isInstalled;
|
||||
if(!xcodeIsInstalled || (_xcode.majorVersion > 11 || (_xcode.majorVersion == 11 && _xcode.minorVersion >= 4))) {
|
||||
logger.printError('Your Xcode project requires migration. See https://github.com/flutter/flutter/issues/50568 for details.');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,11 @@ List<String> _xcodeBuildSettingsLines({
|
||||
xcodeBuildSettings.add('SYMROOT=\${SOURCE_ROOT}/../${getIosBuildDirectory()}');
|
||||
}
|
||||
|
||||
// iOS does not link on Flutter in any build phase. Add the linker flag.
|
||||
if (!useMacOSConfig) {
|
||||
xcodeBuildSettings.add('OTHER_LDFLAGS=\$(inherited) -framework Flutter');
|
||||
}
|
||||
|
||||
if (!project.isModule) {
|
||||
// For module projects we do not want to write the FLUTTER_FRAMEWORK_DIR
|
||||
// explicitly. Rather we rely on the xcode backend script and the Podfile
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
|
||||
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
@@ -27,8 +23,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -39,13 +33,11 @@
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
@@ -59,8 +51,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -70,9 +60,7 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B80C3931E831B6300D905FE /* App.framework */,
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
@@ -204,7 +192,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
|
||||
@@ -9,11 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
@@ -26,8 +22,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -38,13 +32,11 @@
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -57,8 +49,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -68,9 +58,7 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B80C3931E831B6300D905FE /* App.framework */,
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
@@ -201,7 +189,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
|
||||
@@ -75,9 +75,6 @@ target 'Runner' do
|
||||
end
|
||||
end
|
||||
|
||||
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
|
||||
install! 'cocoapods', :disable_input_output_paths => true
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
|
||||
@@ -78,9 +78,6 @@ target 'Runner' do
|
||||
end
|
||||
end
|
||||
|
||||
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
|
||||
install! 'cocoapods', :disable_input_output_paths => true
|
||||
|
||||
post_install do |installer|
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
741F496221355F47001E2961 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 741F495E21355F27001E2961 /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
741F496821356857001E2961 /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 741F496521356807001E2961 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
|
||||
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
@@ -23,8 +21,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
741F496821356857001E2961 /* App.framework in Embed Frameworks */,
|
||||
741F496221355F47001E2961 /* Flutter.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -32,11 +28,8 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
741F495E21355F27001E2961 /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = ../.ios/Flutter/engine/Flutter.framework; sourceTree = "<group>"; };
|
||||
741F496521356807001E2961 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = ../.ios/Flutter/App.framework; sourceTree = "<group>"; };
|
||||
74974046213559DB008C567A /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
74974047213559DB008C567A /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
7497404A213559E7008C567A /* Flutter.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Flutter.xcconfig; sourceTree = "<group>"; };
|
||||
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = ../.ios/Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
@@ -72,8 +65,6 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
741F496521356807001E2961 /* App.framework */,
|
||||
741F495E21355F27001E2961 /* Flutter.framework */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
);
|
||||
name = Flutter;
|
||||
@@ -200,7 +191,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
|
||||
@@ -9,6 +9,3 @@ target 'Runner' do
|
||||
install_flutter_engine_pod
|
||||
install_flutter_plugin_pods flutter_application_path
|
||||
end
|
||||
|
||||
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
|
||||
install! 'cocoapods', :disable_input_output_paths => true
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/ios/migrations/remove_framework_link_and_embedding_migration.dart';
|
||||
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
|
||||
void main () {
|
||||
group('remove framework linking and embedding migration', () {
|
||||
MemoryFileSystem memoryFileSystem;
|
||||
BufferLogger testLogger;
|
||||
MockIosProject mockIosProject;
|
||||
File xcodeProjectInfoFile;
|
||||
MockXcode mockXcode;
|
||||
|
||||
setUp(() {
|
||||
memoryFileSystem = MemoryFileSystem();
|
||||
mockXcode = MockXcode();
|
||||
xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj');
|
||||
|
||||
testLogger = BufferLogger(
|
||||
terminal: AnsiTerminal(
|
||||
stdio: null,
|
||||
platform: const LocalPlatform(),
|
||||
),
|
||||
outputPreferences: OutputPreferences.test(),
|
||||
);
|
||||
|
||||
mockIosProject = MockIosProject();
|
||||
when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile);
|
||||
});
|
||||
|
||||
testWithoutContext('skipped if files are missing', () {
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
|
||||
expect(xcodeProjectInfoFile.existsSync(), isFalse);
|
||||
|
||||
expect(testLogger.traceText, contains('Xcode project not found, skipping migration'));
|
||||
expect(testLogger.statusText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('skipped if nothing to upgrade', () {
|
||||
const String contents = 'Nothing to upgrade';
|
||||
xcodeProjectInfoFile.writeAsStringSync(contents);
|
||||
final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync();
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
|
||||
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
|
||||
expect(xcodeProjectInfoFile.readAsStringSync(), contents);
|
||||
|
||||
expect(testLogger.statusText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('Xcode project is migrated', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
prefix 3B80C3941E831B6300D905FE
|
||||
3B80C3951E831B6300D905FE suffix
|
||||
741F496821356857001E2961
|
||||
keep this 1
|
||||
3B80C3931E831B6300D905FE spaces
|
||||
741F496521356807001E2961
|
||||
9705A1C61CF904A100538489
|
||||
9705A1C71CF904A300538489
|
||||
741F496221355F47001E2961
|
||||
9740EEBA1CF902C7004384FC
|
||||
741F495E21355F27001E2961
|
||||
shellScript = "/bin/sh \"\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\\" thin";
|
||||
keep this 2
|
||||
''');
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
|
||||
expect(xcodeProjectInfoFile.readAsStringSync(), '''
|
||||
keep this 1
|
||||
shellScript = "/bin/sh "\$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\\" embed_and_thin";
|
||||
keep this 2
|
||||
|
||||
''');
|
||||
expect(testLogger.statusText, contains('Upgrading project.pbxproj'));
|
||||
});
|
||||
|
||||
testWithoutContext('migration fails with leftover App.framework reference', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
746232531E83B71900CC1A5E /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 746232521E83B71900CC1A5E /* App.framework */; };
|
||||
''');
|
||||
when(mockXcode.isInstalled).thenReturn(true);
|
||||
when(mockXcode.majorVersion).thenReturn(11);
|
||||
when(mockXcode.minorVersion).thenReturn(4);
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isFalse);
|
||||
expect(testLogger.errorText, contains('Your Xcode project requires migration'));
|
||||
});
|
||||
|
||||
testWithoutContext('migration fails with leftover Flutter.framework reference', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
9705A1C71CF904A300538480 /* Flutter.framework in Embed Frameworks */,
|
||||
''');
|
||||
when(mockXcode.isInstalled).thenReturn(true);
|
||||
when(mockXcode.majorVersion).thenReturn(11);
|
||||
when(mockXcode.minorVersion).thenReturn(4);
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isFalse);
|
||||
expect(testLogger.errorText, contains('Your Xcode project requires migration'));
|
||||
});
|
||||
|
||||
testWithoutContext('migration fails without Xcode installed', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
746232531E83B71900CC1A5E /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 746232521E83B71900CC1A5E /* App.framework */; };
|
||||
''');
|
||||
when(mockXcode.isInstalled).thenReturn(false);
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isFalse);
|
||||
expect(testLogger.errorText, contains('Your Xcode project requires migration'));
|
||||
});
|
||||
|
||||
testWithoutContext('migration fails on Xcode < 11.4', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
746232531E83B71900CC1A5E /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 746232521E83B71900CC1A5E /* App.framework */; };
|
||||
''');
|
||||
when(mockXcode.isInstalled).thenReturn(true);
|
||||
when(mockXcode.majorVersion).thenReturn(11);
|
||||
when(mockXcode.minorVersion).thenReturn(3);
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isTrue);
|
||||
expect(testLogger.errorText, isEmpty);
|
||||
});
|
||||
|
||||
testWithoutContext('migration fails on Xcode 11.4', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
746232531E83B71900CC1A5E /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 746232521E83B71900CC1A5E /* App.framework */; };
|
||||
''');
|
||||
when(mockXcode.isInstalled).thenReturn(true);
|
||||
when(mockXcode.majorVersion).thenReturn(11);
|
||||
when(mockXcode.minorVersion).thenReturn(4);
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isFalse);
|
||||
expect(testLogger.errorText, contains('Your Xcode project requires migration'));
|
||||
});
|
||||
|
||||
testWithoutContext('migration fails on Xcode 12,0', () {
|
||||
xcodeProjectInfoFile.writeAsStringSync('''
|
||||
746232531E83B71900CC1A5E /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 746232521E83B71900CC1A5E /* App.framework */; };
|
||||
''');
|
||||
when(mockXcode.isInstalled).thenReturn(true);
|
||||
when(mockXcode.majorVersion).thenReturn(12);
|
||||
when(mockXcode.minorVersion).thenReturn(0);
|
||||
|
||||
final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration(
|
||||
mockIosProject,
|
||||
testLogger,
|
||||
mockXcode,
|
||||
);
|
||||
expect(iosProjectMigration.migrate(), isFalse);
|
||||
expect(testLogger.errorText, contains('Your Xcode project requires migration'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class MockIosProject extends Mock implements IosProject {}
|
||||
class MockXcode extends Mock implements Xcode {}
|
||||
@@ -286,6 +286,80 @@ Could not build the precompiled application for the device.''',
|
||||
contains('Building a deployable iOS app requires a selected Development Team with a \nProvisioning Profile.'),
|
||||
);
|
||||
}, overrides: noColorTerminalOverride);
|
||||
|
||||
testUsingContext('embedded and linked framework iOS mismatch shows message', () async {
|
||||
final XcodeBuildResult buildResult = XcodeBuildResult(
|
||||
success: false,
|
||||
stdout: '''
|
||||
Launching lib/main.dart on iPhone in debug mode...
|
||||
Automatically signing iOS for device deployment using specified development team in Xcode project: blah
|
||||
Xcode build done. 5.7s
|
||||
Failed to build iOS app
|
||||
Error output from Xcode build:
|
||||
↳
|
||||
** BUILD FAILED **
|
||||
Xcode's output:
|
||||
↳
|
||||
note: Using new build system
|
||||
note: Building targets in parallel
|
||||
note: Planning build
|
||||
note: Constructing build description
|
||||
error: Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS. (in target 'Runner' from project 'Runner')
|
||||
Could not build the precompiled application for the device.
|
||||
|
||||
Error launching application on iPhone.
|
||||
Exited (sigterm)''',
|
||||
xcodeBuildExecution: XcodeBuildExecution(
|
||||
buildCommands: <String>['xcrun', 'xcodebuild', 'blah'],
|
||||
appDirectory: '/blah/blah',
|
||||
buildForPhysicalDevice: true,
|
||||
buildSettings: buildSettings,
|
||||
),
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult);
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
contains('Your Xcode project requires migration.'),
|
||||
);
|
||||
}, overrides: noColorTerminalOverride);
|
||||
|
||||
testUsingContext('embedded and linked framework iOS simulator mismatch shows message', () async {
|
||||
final XcodeBuildResult buildResult = XcodeBuildResult(
|
||||
success: false,
|
||||
stdout: '''
|
||||
Launching lib/main.dart on iPhone in debug mode...
|
||||
Automatically signing iOS for device deployment using specified development team in Xcode project: blah
|
||||
Xcode build done. 5.7s
|
||||
Failed to build iOS app
|
||||
Error output from Xcode build:
|
||||
↳
|
||||
** BUILD FAILED **
|
||||
Xcode's output:
|
||||
↳
|
||||
note: Using new build system
|
||||
note: Building targets in parallel
|
||||
note: Planning build
|
||||
note: Constructing build description
|
||||
error: Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator. (in target 'Runner' from project 'Runner')
|
||||
Could not build the precompiled application for the device.
|
||||
|
||||
Error launching application on iPhone.
|
||||
Exited (sigterm)''',
|
||||
xcodeBuildExecution: XcodeBuildExecution(
|
||||
buildCommands: <String>['xcrun', 'xcodebuild', 'blah'],
|
||||
appDirectory: '/blah/blah',
|
||||
buildForPhysicalDevice: true,
|
||||
buildSettings: buildSettings,
|
||||
),
|
||||
);
|
||||
|
||||
await diagnoseXcodeBuildFailure(buildResult);
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
contains('Your Xcode project requires migration.'),
|
||||
);
|
||||
}, overrides: noColorTerminalOverride);
|
||||
});
|
||||
|
||||
group('Upgrades project.pbxproj for old asset usage', () {
|
||||
|
||||
@@ -455,6 +455,57 @@ Information about project "Runner":
|
||||
});
|
||||
}
|
||||
|
||||
testUsingOsxContext('sets OTHER_LDFLAGS for iOS', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn(fs.path.join('engine', 'Flutter.framework'));
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
|
||||
|
||||
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
|
||||
final FlutterProject project = FlutterProject.fromPath('path/to/project');
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
|
||||
expect(config.existsSync(), isTrue);
|
||||
|
||||
final String contents = config.readAsStringSync();
|
||||
expect(contents.contains('OTHER_LDFLAGS=\$(inherited) -framework Flutter'), isTrue);
|
||||
|
||||
final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh');
|
||||
expect(buildPhaseScript.existsSync(), isTrue);
|
||||
|
||||
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
|
||||
expect(buildPhaseScriptContents.contains('OTHER_LDFLAGS=\$(inherited) -framework Flutter'), isTrue);
|
||||
});
|
||||
|
||||
testUsingOsxContext('do not set OTHER_LDFLAGS for macOS', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterMacOSFramework,
|
||||
platform: TargetPlatform.darwin_x64, mode: anyNamed('mode'))).thenReturn(fs.path.join('engine', 'FlutterMacOS.framework'));
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
|
||||
|
||||
const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
|
||||
final FlutterProject project = FlutterProject.fromPath('path/to/project');
|
||||
await updateGeneratedXcodeProperties(
|
||||
project: project,
|
||||
buildInfo: buildInfo,
|
||||
useMacOSConfig: true,
|
||||
);
|
||||
|
||||
final File config = fs.file('path/to/project/macos/Flutter/ephemeral/Flutter-Generated.xcconfig');
|
||||
expect(config.existsSync(), isTrue);
|
||||
|
||||
final String contents = config.readAsStringSync();
|
||||
expect(contents.contains('OTHER_LDFLAGS'), isFalse);
|
||||
|
||||
final File buildPhaseScript = fs.file('path/to/project/macos/Flutter/ephemeral/flutter_export_environment.sh');
|
||||
expect(buildPhaseScript.existsSync(), isTrue);
|
||||
|
||||
final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync();
|
||||
expect(buildPhaseScriptContents.contains('OTHER_LDFLAGS'), isFalse);
|
||||
});
|
||||
|
||||
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework,
|
||||
platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine');
|
||||
|
||||
Reference in New Issue
Block a user