"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/packages/flutter_tools/lib/src/ios/migrations/remove_framework_link_and_embedding_migration.dart" (13 Nov 2020, 4255 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Copyright 2014 The Flutter Authors. All rights reserved.
    2 // Use of this source code is governed by a BSD-style license that can be
    3 // found in the LICENSE file.
    4 
    5 import '../../base/common.dart';
    6 import '../../base/file_system.dart';
    7 import '../../base/logger.dart';
    8 import '../../macos/xcode.dart';
    9 import '../../project.dart';
   10 import '../../reporting/reporting.dart';
   11 import 'ios_migrator.dart';
   12 
   13 // Xcode 11.4 requires linked and embedded frameworks to contain all targeted architectures before build phases are run.
   14 // This caused issues switching between a real device and simulator due to architecture mismatch.
   15 // Remove the linking and embedding logic from the Xcode project to give the tool more control over these.
   16 class RemoveFrameworkLinkAndEmbeddingMigration extends IOSMigrator {
   17   RemoveFrameworkLinkAndEmbeddingMigration(
   18     IosProject project,
   19     Logger logger,
   20     Xcode xcode,
   21     Usage usage,
   22   ) : _xcodeProjectInfoFile = project.xcodeProjectInfoFile,
   23         _xcode = xcode,
   24         _usage = usage,
   25         super(logger);
   26 
   27   final File _xcodeProjectInfoFile;
   28   final Xcode _xcode;
   29   final Usage _usage;
   30 
   31   @override
   32   bool migrate() {
   33     if (!_xcodeProjectInfoFile.existsSync()) {
   34       logger.printTrace('Xcode project not found, skipping framework link and embedding migration');
   35       return true;
   36     }
   37 
   38     processFileLines(_xcodeProjectInfoFile);
   39 
   40     return true;
   41   }
   42 
   43   @override
   44   String migrateLine(String line) {
   45     // App.framework Frameworks reference.
   46     // isa = PBXFrameworksBuildPhase;
   47     // files = (
   48     //    3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
   49     if (line.contains('3B80C3941E831B6300D905FE')) {
   50       return null;
   51     }
   52 
   53     // App.framework Embed Framework reference (build phase to embed framework).
   54     // 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
   55     if (line.contains('3B80C3951E831B6300D905FE')
   56         || line.contains('741F496821356857001E2961')) { // Ephemeral add-to-app variant.
   57       return null;
   58     }
   59 
   60     // App.framework project file reference (seen in Xcode navigator pane).
   61     // isa = PBXGroup;
   62     // children = (
   63     //   3B80C3931E831B6300D905FE /* App.framework */,
   64     if (line.contains('3B80C3931E831B6300D905FE')
   65         || line.contains('741F496521356807001E2961')) { // Ephemeral add-to-app variant.
   66       return null;
   67     }
   68 
   69     // Flutter.framework Frameworks reference.
   70     // isa = PBXFrameworksBuildPhase;
   71     // files = (
   72     //   9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
   73     if (line.contains('9705A1C61CF904A100538489')) {
   74       return null;
   75     }
   76 
   77     // Flutter.framework Embed Framework reference (build phase to embed framework).
   78     // 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
   79     if (line.contains('9705A1C71CF904A300538489')
   80         || line.contains('741F496221355F47001E2961')) { // Ephemeral add-to-app variant.
   81       return null;
   82     }
   83 
   84     // Flutter.framework project file reference (seen in Xcode navigator pane).
   85     // isa = PBXGroup;
   86     // children = (
   87     //   9740EEBA1CF902C7004384FC /* Flutter.framework */,
   88     if (line.contains('9740EEBA1CF902C7004384FC')
   89         || line.contains('741F495E21355F27001E2961')) { // Ephemeral add-to-app variant.
   90       return null;
   91     }
   92 
   93     // Embed and thin frameworks in a script instead of using Xcode's link / embed build phases.
   94     const String thinBinaryScript = 'xcode_backend.sh\\" thin';
   95     if (line.contains(thinBinaryScript) && !line.contains(' embed')) {
   96       return line.replaceFirst(thinBinaryScript, 'xcode_backend.sh\\" embed_and_thin');
   97     }
   98 
   99     if (line.contains('/* App.framework ') || line.contains('/* Flutter.framework ')) {
  100       // Print scary message if the user is on Xcode 11.4 or greater, or if Xcode isn't installed.
  101       final bool xcodeIsInstalled = _xcode.isInstalled;
  102       if(!xcodeIsInstalled || (_xcode.majorVersion > 11 || (_xcode.majorVersion == 11 && _xcode.minorVersion >= 4))) {
  103         UsageEvent('ios-migration', 'remove-frameworks', label: 'failure', flutterUsage: _usage).send();
  104         throwToolExit('Your Xcode project requires migration. See https://flutter.dev/docs/development/ios-project-migration for details.');
  105       }
  106     }
  107 
  108     return line;
  109   }
  110 }