[go: nahoru, domu]

Skip to content

Commit

Permalink
Set DEFINES_MODULE for FlutterPluginRegistrant to generate modulemap (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagman committed Sep 13, 2019
1 parent 69a2964 commit b80b9be
Show file tree
Hide file tree
Showing 16 changed files with 789 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version

Expand Down
99 changes: 77 additions & 22 deletions dev/devicelab/bin/tasks/module_test_ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Future<void> main() async {
String content = await pubspec.readAsString();
content = content.replaceFirst(
'\ndependencies:\n',
'\ndependencies:\n device_info:\n package_info:\n',
'\ndependencies:\n device_info:\n google_maps_flutter:\n', // One dynamic and one static framework.
);
await pubspec.writeAsString(content, flush: true);
await inDirectory(projectDir, () async {
Expand Down Expand Up @@ -192,7 +192,7 @@ Future<void> main() async {
if (!podfileLockOutput.contains(':path: Flutter/engine')
|| !podfileLockOutput.contains(':path: Flutter/FlutterPluginRegistrant')
|| !podfileLockOutput.contains(':path: Flutter/.symlinks/device_info/ios')
|| !podfileLockOutput.contains(':path: Flutter/.symlinks/package_info/ios')) {
|| !podfileLockOutput.contains(':path: Flutter/.symlinks/google_maps_flutter/ios')) {
return TaskResult.failure('Building ephemeral host app Podfile.lock does not contain expected pods');
}

Expand Down Expand Up @@ -232,18 +232,18 @@ Future<void> main() async {
return TaskResult.failure('Failed to build editable host .app');
}

section('Add to existing iOS app');
section('Add to existing iOS Objective-C app');

final Directory hostApp = Directory(path.join(tempDir.path, 'hello_host_app'));
mkdir(hostApp);
final Directory objectiveCHostApp = Directory(path.join(tempDir.path, 'hello_host_app'));
mkdir(objectiveCHostApp);
recursiveCopy(
Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_host_app')),
hostApp,
objectiveCHostApp,
);

final File analyticsOutputFile = File(path.join(tempDir.path, 'analytics.log'));

await inDirectory(hostApp, () async {
final File objectiveCAnalyticsOutputFile = File(path.join(tempDir.path, 'analytics-objc.log'));
final Directory objectiveCBuildDirectory = Directory(path.join(tempDir.path, 'build-objc'));
await inDirectory(objectiveCHostApp, () async {
await exec('pod', <String>['install']);
await exec(
'xcodebuild',
Expand All @@ -258,37 +258,37 @@ Future<void> main() async {
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'CONFIGURATION_BUILD_DIR=${tempDir.path}',
'CONFIGURATION_BUILD_DIR=${objectiveCBuildDirectory.path}',
'COMPILER_INDEX_STORE_ENABLE=NO',
],
environment: <String, String> {
'FLUTTER_ANALYTICS_LOG_FILE': analyticsOutputFile.path,
'FLUTTER_ANALYTICS_LOG_FILE': objectiveCAnalyticsOutputFile.path,
}
);
});

final bool existingAppBuilt = exists(File(path.join(
tempDir.path,
objectiveCBuildDirectory.path,
'Host.app',
'Host',
)));
if (!existingAppBuilt) {
return TaskResult.failure('Failed to build existing app .app');
return TaskResult.failure('Failed to build existing Objective-C app .app');
}

final String analyticsOutput = analyticsOutputFile.readAsStringSync();
if (!analyticsOutput.contains('cd24: ios')
|| !analyticsOutput.contains('cd25: true')
|| !analyticsOutput.contains('viewName: build/bundle')) {
final String objectiveCAnalyticsOutput = objectiveCAnalyticsOutputFile.readAsStringSync();
if (!objectiveCAnalyticsOutput.contains('cd24: ios')
|| !objectiveCAnalyticsOutput.contains('cd25: true')
|| !objectiveCAnalyticsOutput.contains('viewName: build/bundle')) {
return TaskResult.failure(
'Building outer app produced the following analytics: "$analyticsOutput"'
'Building outer Objective-C app produced the following analytics: "$objectiveCAnalyticsOutput"'
'but not the expected strings: "cd24: ios", "cd25: true", "viewName: build/bundle"'
);
}

section('Fail building existing iOS app if flutter script fails');
section('Fail building existing Objective-C iOS app if flutter script fails');
int xcodebuildExitCode = 0;
await inDirectory(hostApp, () async {
await inDirectory(objectiveCHostApp, () async {
xcodebuildExitCode = await exec(
'xcodebuild',
<String>[
Expand All @@ -303,15 +303,70 @@ Future<void> main() async {
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'CONFIGURATION_BUILD_DIR=${tempDir.path}',
'CONFIGURATION_BUILD_DIR=${objectiveCBuildDirectory.path}',
'COMPILER_INDEX_STORE_ENABLE=NO',
],
canFail: true
);
});

if (xcodebuildExitCode != 65) { // 65 returned on PhaseScriptExecution failure.
return TaskResult.failure('Host app build succeeded though flutter script failed');
return TaskResult.failure('Host Objective-C app build succeeded though flutter script failed');
}

section('Add to existing iOS Swift app');

final Directory swiftHostApp = Directory(path.join(tempDir.path, 'hello_host_app_swift'));
mkdir(swiftHostApp);
recursiveCopy(
Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'ios_host_app_swift')),
swiftHostApp,
);

final File swiftAnalyticsOutputFile = File(path.join(tempDir.path, 'analytics-swift.log'));
final Directory swiftBuildDirectory = Directory(path.join(tempDir.path, 'build-swift'));

await inDirectory(swiftHostApp, () async {
await exec('pod', <String>['install']);
await exec(
'xcodebuild',
<String>[
'-workspace',
'Host.xcworkspace',
'-scheme',
'Host',
'-configuration',
'Debug',
'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO',
'CODE_SIGN_IDENTITY=-',
'EXPANDED_CODE_SIGN_IDENTITY=-',
'CONFIGURATION_BUILD_DIR=${swiftBuildDirectory.path}',
'COMPILER_INDEX_STORE_ENABLE=NO',
],
environment: <String, String> {
'FLUTTER_ANALYTICS_LOG_FILE': swiftAnalyticsOutputFile.path,
}
);
});

final bool existingSwiftAppBuilt = exists(File(path.join(
swiftBuildDirectory.path,
'Host.app',
'Host',
)));
if (!existingSwiftAppBuilt) {
return TaskResult.failure('Failed to build existing Swift app .app');
}

final String swiftAnalyticsOutput = swiftAnalyticsOutputFile.readAsStringSync();
if (!swiftAnalyticsOutput.contains('cd24: ios')
|| !swiftAnalyticsOutput.contains('cd25: true')
|| !swiftAnalyticsOutput.contains('viewName: build/bundle')) {
return TaskResult.failure(
'Building outer Swift app produced the following analytics: "$swiftAnalyticsOutput"'
'but not the expected strings: "cd24: ios", "cd25: true", "viewName: build/bundle"'
);
}

return TaskResult.success(null);
Expand Down
1 change: 1 addition & 0 deletions dev/integration_tests/ios_host_app/Host/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@implementation ViewController

// Boiler-plate add-to-app demo. Not integration tested anywhere.
- (void)viewDidLoad {
[super viewDidLoad];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
Expand Down
Loading

0 comments on commit b80b9be

Please sign in to comment.