@@ -77,6 +77,11 @@ class PluginTest {
77
77
final _FlutterProject app = await _FlutterProject .create (tempDir, options, buildTarget,
78
78
name: 'plugintestapp' , template: 'app' , environment: appCreateEnvironment);
79
79
try {
80
+ if (cocoapodsTransitiveFlutterDependency) {
81
+ section ('Disable Swift Package Manager' );
82
+ await app.disableSwiftPackageManager ();
83
+ }
84
+
80
85
section ('Add plugins' );
81
86
await app.addPlugin ('plugintest' ,
82
87
pluginPath: path.join ('..' , 'plugintest' ));
@@ -147,6 +152,20 @@ class _FlutterProject {
147
152
return _FlutterProject (Directory (path.join (rootPath)), 'example' );
148
153
}
149
154
155
+ Future <void > disableSwiftPackageManager () async {
156
+ final File pubspec = pubspecFile;
157
+ String content = await pubspec.readAsString ();
158
+ content = content.replaceFirst (
159
+ '# The following section is specific to Flutter packages.\n '
160
+ 'flutter:\n ' ,
161
+ '# The following section is specific to Flutter packages.\n '
162
+ 'flutter:\n '
163
+ '\n '
164
+ ' disable-swift-package-manager: true\n '
165
+ );
166
+ await pubspec.writeAsString (content, flush: true );
167
+ }
168
+
150
169
Future <void > addPlugin (String plugin, {String ? pluginPath}) async {
151
170
final File pubspec = pubspecFile;
152
171
String content = await pubspec.readAsString ();
@@ -244,9 +263,14 @@ class $dartPluginClass {
244
263
await podspec.writeAsString (podspecContent, flush: true );
245
264
246
265
// Make PlugintestPlugin.swift compile on iOS and macOS with target conditionals.
266
+ // If SwiftPM is disabled, the file will be in `darwin/Classes/`.
267
+ // Otherwise, the file will be in `darwin/<plugin>/Sources/<plugin>/`.
247
268
final String pluginClass = '${name [0 ].toUpperCase ()}${name .substring (1 )}Plugin' ;
248
269
print ('pluginClass: $pluginClass ' );
249
- final File pluginRegister = File (path.join (darwinDir.path, 'Classes' , '$pluginClass .swift' ));
270
+ File pluginRegister = File (path.join (darwinDir.path, 'Classes' , '$pluginClass .swift' ));
271
+ if (! pluginRegister.existsSync ()) {
272
+ pluginRegister = File (path.join (darwinDir.path, name, 'Sources' , name, '$pluginClass .swift' ));
273
+ }
250
274
final String pluginRegisterContent = '''
251
275
#if os(macOS)
252
276
import FlutterMacOS
@@ -494,42 +518,55 @@ s.dependency 'AppAuth', '1.6.0'
494
518
}
495
519
496
520
if (validateNativeBuildProject) {
497
- final File podsProject = File (path.join (rootPath, target, 'Pods' , 'Pods.xcodeproj' , 'project.pbxproj' ));
498
- if (! podsProject.existsSync ()) {
499
- throw TaskResult .failure ('Xcode Pods project file missing at ${podsProject .path }' );
500
- }
501
-
502
- final String podsProjectContent = podsProject.readAsStringSync ();
503
- if (target == 'ios' ) {
504
- // Plugins with versions lower than the app version should not have IPHONEOS_DEPLOYMENT_TARGET set.
505
- // The plugintest plugin target should not have IPHONEOS_DEPLOYMENT_TARGET set since it has been lowered
506
- // in _reduceDarwinPluginMinimumVersion to 10, which is below the target version of 11.
507
- if (podsProjectContent.contains ('IPHONEOS_DEPLOYMENT_TARGET = 10' )) {
508
- throw TaskResult .failure ('Plugin build setting IPHONEOS_DEPLOYMENT_TARGET not removed' );
509
- }
510
- // Transitive dependency AppAuth targeting too-low 8.0 was not fixed.
511
- if (podsProjectContent.contains ('IPHONEOS_DEPLOYMENT_TARGET = 8' )) {
512
- throw TaskResult .failure ('Transitive dependency build setting IPHONEOS_DEPLOYMENT_TARGET=8 not removed' );
521
+ final File generatedSwiftManifest = File (path.join (
522
+ rootPath,
523
+ target,
524
+ 'Flutter' ,
525
+ 'ephemeral' ,
526
+ 'Packages' ,
527
+ 'FlutterGeneratedPluginSwiftPackage' ,
528
+ 'Package.swift'
529
+ ));
530
+ final bool swiftPackageManagerEnabled = generatedSwiftManifest.existsSync ();
531
+
532
+ if (! swiftPackageManagerEnabled) {
533
+ final File podsProject = File (path.join (rootPath, target, 'Pods' , 'Pods.xcodeproj' , 'project.pbxproj' ));
534
+ if (! podsProject.existsSync ()) {
535
+ throw TaskResult .failure ('Xcode Pods project file missing at ${podsProject .path }' );
513
536
}
514
- if (! podsProjectContent.contains (r'"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "$(inherited) i386";' )) {
515
- throw TaskResult .failure (r'EXCLUDED_ARCHS is not "$(inherited) i386"' );
516
- }
517
- } else if (target == 'macos' ) {
518
- // Same for macOS deployment target, but 10.8.
519
- // The plugintest target should not have MACOSX_DEPLOYMENT_TARGET set.
520
- if (podsProjectContent.contains ('MACOSX_DEPLOYMENT_TARGET = 10.8' )) {
521
- throw TaskResult .failure ('Plugin build setting MACOSX_DEPLOYMENT_TARGET not removed' );
522
- }
523
- // Transitive dependency AppAuth targeting too-low 10.9 was not fixed.
524
- if (podsProjectContent.contains ('MACOSX_DEPLOYMENT_TARGET = 10.9' )) {
525
- throw TaskResult .failure ('Transitive dependency build setting MACOSX_DEPLOYMENT_TARGET=10.9 not removed' );
537
+
538
+ final String podsProjectContent = podsProject.readAsStringSync ();
539
+ if (target == 'ios' ) {
540
+ // Plugins with versions lower than the app version should not have IPHONEOS_DEPLOYMENT_TARGET set.
541
+ // The plugintest plugin target should not have IPHONEOS_DEPLOYMENT_TARGET set since it has been lowered
542
+ // in _reduceDarwinPluginMinimumVersion to 10, which is below the target version of 11.
543
+ if (podsProjectContent.contains ('IPHONEOS_DEPLOYMENT_TARGET = 10' )) {
544
+ throw TaskResult .failure ('Plugin build setting IPHONEOS_DEPLOYMENT_TARGET not removed' );
545
+ }
546
+ // Transitive dependency AppAuth targeting too-low 8.0 was not fixed.
547
+ if (podsProjectContent.contains ('IPHONEOS_DEPLOYMENT_TARGET = 8' )) {
548
+ throw TaskResult .failure ('Transitive dependency build setting IPHONEOS_DEPLOYMENT_TARGET=8 not removed' );
549
+ }
550
+ if (! podsProjectContent.contains (r'"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "$(inherited) i386";' )) {
551
+ throw TaskResult .failure (r'EXCLUDED_ARCHS is not "$(inherited) i386"' );
552
+ }
553
+ } else if (target == 'macos' ) {
554
+ // Same for macOS deployment target, but 10.8.
555
+ // The plugintest target should not have MACOSX_DEPLOYMENT_TARGET set.
556
+ if (podsProjectContent.contains ('MACOSX_DEPLOYMENT_TARGET = 10.8' )) {
557
+ throw TaskResult .failure ('Plugin build setting MACOSX_DEPLOYMENT_TARGET not removed' );
558
+ }
559
+ // Transitive dependency AppAuth targeting too-low 10.9 was not fixed.
560
+ if (podsProjectContent.contains ('MACOSX_DEPLOYMENT_TARGET = 10.9' )) {
561
+ throw TaskResult .failure ('Transitive dependency build setting MACOSX_DEPLOYMENT_TARGET=10.9 not removed' );
562
+ }
526
563
}
527
- }
528
564
529
- if (localEngine != null ) {
530
- final RegExp localEngineSearchPath = RegExp ('FRAMEWORK_SEARCH_PATHS\\ s*=[^;]*${localEngine .path }' );
531
- if (! localEngineSearchPath.hasMatch (podsProjectContent)) {
532
- throw TaskResult .failure ('FRAMEWORK_SEARCH_PATHS does not contain the --local-engine path' );
565
+ if (localEngine != null ) {
566
+ final RegExp localEngineSearchPath = RegExp ('FRAMEWORK_SEARCH_PATHS\\ s*=[^;]*${localEngine .path }' );
567
+ if (! localEngineSearchPath.hasMatch (podsProjectContent)) {
568
+ throw TaskResult .failure ('FRAMEWORK_SEARCH_PATHS does not contain the --local-engine path' );
569
+ }
533
570
}
534
571
}
535
572
}
0 commit comments