Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usage event for failed iOS project migration #51879

Merged
merged 2 commits into from
Mar 6, 2020

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented Mar 3, 2020

Description

Add usage event for failed iOS project migrations.
Move flutterUsage to globals as part of #47161.

Related Issues

Fixes #51817
See also #51453

Feedback followup from #51453 (comment).

Tests

Added IOSMigration tests.

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.

@jmagman jmagman added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 3, 2020
@jmagman jmagman requested a review from zanderso March 3, 2020 20:34
@jmagman jmagman self-assigned this Mar 3, 2020
@jmagman jmagman changed the title Add usage event for failed migration Add usage event for failed iOS project migration Mar 3, 2020
@@ -95,6 +95,7 @@ Future<XcodeBuildResult> buildXcodeProject({

for (final IOSMigrator migrator in migrators) {
if (!migrator.migrate()) {
UsageEvent('ios-migration', '${migrator.usageEventAction}-failure').send();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be a bit easier to navigate in GA as:

UsageEvent('ios-migration', migrator.usageEventAction, label: 'failure').send();


/// 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);
abstract class IOSMigrator {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does processFileLines need to take a callback? Could it call an abstract method provided by the subclasses?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration can handle multiple files with different pattern matching per file:

  void run() {
    _migrateXcodeProjectInfoFile();
    _migratePodfile();
  }
 void _migrateXcodeProjectInfoFile() {
    _processFileLines(_xcodeProjectInfoFile, (String line) {
      if (line.contains('3B80C3941E831B6300D905FE')) {
        return null;
      }
...
    });
  }

  void _migratePodfile() {
    _processFileLines(_podfile, (String line) {
      if (line.contains('Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.')) {
        return null;
      }
...
    });
  }

Original version of RemoveFrameworkLinkAndEmbeddingMigration (Podfile migration since deleted):
https://github.com/jmagman/flutter/blob/e70ed529c41b1dbfe6392c45f84b6cfb165fb419/packages/flutter_tools/lib/src/ios/ios_project_migration.dart

@@ -54,3 +56,20 @@ class IOSMigrator {
}
}
}

class IOSMigration {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially for a migration that might touch multiple files, this will have to be treated like a database transaction. We don't want to leave a tree in a partially migrated state, for example. Not for this PR (unless we already have multi-file migrations), but maybe add a TODO and file an issue.


bool run() {
for (final IOSMigrator migrator in migrators) {
if (!migrator.migrate()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should this code handle exceptions from migrator.migrate()

@@ -2,26 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_tools/src/base/common.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import '../../base/common.dart'

Copy link
Member Author

@jmagman jmagman Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh Android Studio always does that without me noticing. Turning off import code folding...

@jmagman jmagman merged commit f6a5512 into flutter:master Mar 6, 2020
@jmagman jmagman deleted the migration-usage branch March 6, 2020 20:14
@jmagman jmagman added the platform-ios iOS applications specifically label Aug 21, 2020
@github-actions GitHub Actions bot locked as resolved and limited conversation to collaborators Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add usage event for iOS project Flutter migrations
3 participants