Add iOS module template (#18830)
Add iOS module template This will enable integration of flutter-views into existing iOS project.
This commit is contained in:
@@ -9,6 +9,8 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/flutter_manifest.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/ios/cocoapods.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
@@ -132,21 +134,25 @@ void main() {
|
||||
podFile = fs.file(fs.path.join('project', 'ios', 'Podfile'));
|
||||
});
|
||||
|
||||
testUsingContext('creates objective-c Podfile when not present', () {
|
||||
cocoaPodsUnderTest.setupPodfile('project');
|
||||
testUsingContext('creates objective-c Podfile when not present', () async {
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('project').manifest;
|
||||
cocoaPodsUnderTest.setupPodfile('project', manifest);
|
||||
|
||||
expect(podFile.readAsStringSync(), 'Objective-C podfile template');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
});
|
||||
|
||||
testUsingContext('creates swift Podfile if swift', () {
|
||||
testUsingContext('creates swift Podfile if swift', () async {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.getBuildSettings(any, any)).thenReturn(<String, String>{
|
||||
'SWIFT_VERSION': '4.0',
|
||||
});
|
||||
|
||||
cocoaPodsUnderTest.setupPodfile('project');
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('project').manifest;
|
||||
cocoaPodsUnderTest.setupPodfile('project', manifest);
|
||||
|
||||
expect(podFile.readAsStringSync(), 'Swift podfile template');
|
||||
}, overrides: <Type, Generator>{
|
||||
@@ -154,20 +160,24 @@ void main() {
|
||||
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
|
||||
});
|
||||
|
||||
testUsingContext('does not recreate Podfile when already present', () {
|
||||
testUsingContext('does not recreate Podfile when already present', () async {
|
||||
podFile..createSync()..writeAsStringSync('Existing Podfile');
|
||||
|
||||
cocoaPodsUnderTest.setupPodfile('project');
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('project').manifest;
|
||||
cocoaPodsUnderTest.setupPodfile('project', manifest);
|
||||
|
||||
expect(podFile.readAsStringSync(), 'Existing Podfile');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
});
|
||||
|
||||
testUsingContext('does not create Podfile when we cannot interpret Xcode projects', () {
|
||||
testUsingContext('does not create Podfile when we cannot interpret Xcode projects', () async {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(false);
|
||||
|
||||
cocoaPodsUnderTest.setupPodfile('project');
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('project').manifest;
|
||||
cocoaPodsUnderTest.setupPodfile('project', manifest);
|
||||
|
||||
expect(podFile.existsSync(), false);
|
||||
}, overrides: <Type, Generator>{
|
||||
@@ -175,12 +185,14 @@ void main() {
|
||||
XcodeProjectInterpreter: () => mockXcodeProjectInterpreter,
|
||||
});
|
||||
|
||||
testUsingContext('includes Pod config in xcconfig files, if not present', () {
|
||||
testUsingContext('includes Pod config in xcconfig files, if not present', () async {
|
||||
podFile..createSync()..writeAsStringSync('Existing Podfile');
|
||||
debugConfigFile..createSync(recursive: true)..writeAsStringSync('Existing debug config');
|
||||
releaseConfigFile..createSync(recursive: true)..writeAsStringSync('Existing release config');
|
||||
|
||||
cocoaPodsUnderTest.setupPodfile('project');
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('project').manifest;
|
||||
cocoaPodsUnderTest.setupPodfile('project', manifest);
|
||||
|
||||
final String debugContents = debugConfigFile.readAsStringSync();
|
||||
expect(debugContents, contains(
|
||||
|
||||
@@ -11,6 +11,8 @@ import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/bundle.dart' as bundle;
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/flutter_manifest.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
@@ -284,12 +286,16 @@ Information about project "Runner":
|
||||
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
|
||||
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, any)).thenReturn('engine');
|
||||
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
|
||||
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
|
||||
previewDart2: true,
|
||||
targetPlatform: TargetPlatform.ios,
|
||||
);
|
||||
await updateGeneratedXcodeProperties(
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('path/to/project').manifest;
|
||||
updateGeneratedXcodeProperties(
|
||||
projectPath: 'path/to/project',
|
||||
manifest: manifest,
|
||||
buildInfo: buildInfo,
|
||||
previewDart2: true,
|
||||
);
|
||||
@@ -309,8 +315,11 @@ Information about project "Runner":
|
||||
trackWidgetCreation: true,
|
||||
targetPlatform: TargetPlatform.ios,
|
||||
);
|
||||
await updateGeneratedXcodeProperties(
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('path/to/project').manifest;
|
||||
updateGeneratedXcodeProperties(
|
||||
projectPath: 'path/to/project',
|
||||
manifest: manifest,
|
||||
buildInfo: buildInfo,
|
||||
previewDart2: true,
|
||||
);
|
||||
@@ -329,8 +338,11 @@ Information about project "Runner":
|
||||
previewDart2: true,
|
||||
targetPlatform: TargetPlatform.ios,
|
||||
);
|
||||
await updateGeneratedXcodeProperties(
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('path/to/project').manifest;
|
||||
updateGeneratedXcodeProperties(
|
||||
projectPath: 'path/to/project',
|
||||
manifest: manifest,
|
||||
buildInfo: buildInfo,
|
||||
previewDart2: true,
|
||||
);
|
||||
@@ -349,8 +361,12 @@ Information about project "Runner":
|
||||
previewDart2: true,
|
||||
targetPlatform: TargetPlatform.ios,
|
||||
);
|
||||
await updateGeneratedXcodeProperties(
|
||||
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath('path/to/project').manifest;
|
||||
updateGeneratedXcodeProperties(
|
||||
projectPath: 'path/to/project',
|
||||
manifest: manifest,
|
||||
buildInfo: buildInfo,
|
||||
previewDart2: true,
|
||||
);
|
||||
@@ -394,15 +410,18 @@ Information about project "Runner":
|
||||
}
|
||||
|
||||
Future<void> checkBuildVersion({
|
||||
String manifest,
|
||||
String manifestString,
|
||||
BuildInfo buildInfo,
|
||||
String expectedBuildName,
|
||||
String expectedBuildNumber,
|
||||
}) async {
|
||||
final String projectPath = await createMinimalProject(manifest);
|
||||
final String projectPath = await createMinimalProject(manifestString);
|
||||
|
||||
await updateGeneratedXcodeProperties(
|
||||
final FlutterManifest manifest =
|
||||
await new FlutterProject.fromPath(projectPath).manifest;
|
||||
updateGeneratedXcodeProperties(
|
||||
projectPath: projectPath,
|
||||
manifest: manifest,
|
||||
buildInfo: buildInfo,
|
||||
targetOverride: bundle.defaultMainPath,
|
||||
previewDart2: false,
|
||||
@@ -427,7 +446,7 @@ flutter:
|
||||
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null);
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.0',
|
||||
expectedBuildNumber: '1',
|
||||
@@ -445,7 +464,7 @@ flutter:
|
||||
''';
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null);
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.0',
|
||||
expectedBuildNumber: null,
|
||||
@@ -463,7 +482,7 @@ flutter:
|
||||
''';
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null, buildName: '1.0.2');
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.2',
|
||||
expectedBuildNumber: '1',
|
||||
@@ -481,7 +500,7 @@ flutter:
|
||||
''';
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null, buildNumber: 3);
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.0',
|
||||
expectedBuildNumber: '3',
|
||||
@@ -499,7 +518,7 @@ flutter:
|
||||
''';
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null, buildName: '1.0.2', buildNumber: 3);
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.2',
|
||||
expectedBuildNumber: '3',
|
||||
@@ -517,7 +536,7 @@ flutter:
|
||||
''';
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null, buildName: '1.0.2', buildNumber: 3);
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.2',
|
||||
expectedBuildNumber: '3',
|
||||
@@ -534,7 +553,7 @@ flutter:
|
||||
''';
|
||||
const BuildInfo buildInfo = const BuildInfo(BuildMode.release, null, buildName: '1.0.2', buildNumber: 3);
|
||||
await checkBuildVersion(
|
||||
manifest: manifest,
|
||||
manifestString: manifest,
|
||||
buildInfo: buildInfo,
|
||||
expectedBuildName: '1.0.2',
|
||||
expectedBuildNumber: '3',
|
||||
|
||||
@@ -15,7 +15,14 @@ void main() {
|
||||
group('Project', () {
|
||||
testInMemory('knows location', () {
|
||||
final Directory directory = fs.directory('myproject');
|
||||
expect(new FlutterProject(directory).directory, directory);
|
||||
expect(
|
||||
new FlutterProject(directory).directory.absolute.path,
|
||||
directory.absolute.path,
|
||||
);
|
||||
expect(
|
||||
new FlutterProject.fromPath(directory.path).directory.absolute.path,
|
||||
directory.absolute.path,
|
||||
);
|
||||
});
|
||||
group('ensure ready for platform-specific tooling', () {
|
||||
testInMemory('does nothing, if project is not created', () async {
|
||||
@@ -94,7 +101,7 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
FlutterProject someProject() => new FlutterProject(fs.directory('some_project'));
|
||||
FlutterProject someProject() => new FlutterProject.fromPath('some_project');
|
||||
|
||||
FlutterProject aProjectWithIos() {
|
||||
final Directory directory = fs.directory('ios_project');
|
||||
|
||||
Reference in New Issue
Block a user