Skip to content

Commit 88a7ec6

Browse files
authored
[SwiftPM] Rename SWIFT_PACKAGE_MANAGER environment variable to FLUTTER_SWIFT_PACKAGE_MANAGER (#159502)
Previously, the Swift Package Manager feature could be overridden using the `SWIFT_PACKAGE_MANAGER` environment variable. This environment variable name is a bit generic and might collide with other tooling. This renames the environment variable to `FLUTTER_SWIFT_PACKAGE_MANAGER`. **This is a breaking change**, however, [we haven't documented this environment variable](https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers#how-to-turn-on-swift-package-manager). Addresses flutter/flutter#159121 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent e64ee5d commit 88a7ec6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

packages/flutter_tools/lib/src/features.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const Feature previewDevice = Feature(
185185
const Feature swiftPackageManager = Feature(
186186
name: 'support for Swift Package Manager for iOS and macOS',
187187
configSetting: 'enable-swift-package-manager',
188-
environmentOverride: 'SWIFT_PACKAGE_MANAGER',
188+
environmentOverride: 'FLUTTER_SWIFT_PACKAGE_MANAGER',
189189
master: FeatureChannelSetting(
190190
available: true,
191191
),

packages/flutter_tools/test/general.shard/features_test.dart

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,23 @@ void main() {
403403
expect(nativeAssets.stable.available, false);
404404
});
405405

406-
test('${swiftPackageManager.name} availability and default enabled', () {
407-
expect(swiftPackageManager.master.enabledByDefault, false);
408-
expect(swiftPackageManager.master.available, true);
409-
expect(swiftPackageManager.beta.enabledByDefault, false);
410-
expect(swiftPackageManager.beta.available, true);
411-
expect(swiftPackageManager.stable.enabledByDefault, false);
412-
expect(swiftPackageManager.stable.available, true);
406+
group('Swift Package Manager feature', () {
407+
test('availability and default enabled', () {
408+
expect(swiftPackageManager.master.enabledByDefault, false);
409+
expect(swiftPackageManager.master.available, true);
410+
expect(swiftPackageManager.beta.enabledByDefault, false);
411+
expect(swiftPackageManager.beta.available, true);
412+
expect(swiftPackageManager.stable.enabledByDefault, false);
413+
expect(swiftPackageManager.stable.available, true);
414+
});
415+
416+
test('can be enabled', () {
417+
platform.environment = <String, String>{
418+
'FLUTTER_SWIFT_PACKAGE_MANAGER': 'true',
419+
};
420+
421+
expect(featureFlags.isSwiftPackageManagerEnabled, isTrue);
422+
});
413423
});
414424
});
415425
}

0 commit comments

Comments
 (0)