Add Swift Package Manager as new opt-in feature for iOS and macOS (#146256)
This PR adds initial support for Swift Package Manager (SPM). Users must opt in. Only compatible with Xcode 15+. Fixes https://github.com/flutter/flutter/issues/146369. ## Included Features This PR includes the following features: * Enabling SPM via config `flutter config --enable-swift-package-manager` * Disabling SPM via config (will disable for all projects) `flutter config --no-enable-swift-package-manager` * Disabling SPM via pubspec.yaml (will disable for the specific project) ``` flutter: disable-swift-package-manager: true ``` * Migrating existing apps to add SPM integration if using a Flutter plugin with a Package.swift * Generates a Swift Package (named `FlutterGeneratedPluginSwiftPackage`) that handles Flutter SPM-compatible plugin dependencies. Generated package is added to the Xcode project. * Error parsing of common errors that may occur due to using CocoaPods and Swift Package Manager together * Tool will print warnings when using all Swift Package plugins and encourage you to remove CocoaPods This PR also converts `integration_test` and `integration_test_macos` plugins to be both Swift Packages and CocoaPod Pods. ## How it Works The Flutter CLI will generate a Swift Package called `FlutterGeneratedPluginSwiftPackage`, which will have local dependencies on all Swift Package compatible Flutter plugins. The `FlutterGeneratedPluginSwiftPackage` package will be added to the Xcode project via altering of the `project.pbxproj`. In addition, a "Pre-action" script will be added via altering of the `Runner.xcscheme`. This script will invoke the flutter tool to copy the Flutter/FlutterMacOS framework to the `BUILT_PRODUCTS_DIR` directory before the build starts. This is needed because plugins need to be linked to the Flutter framework and fortunately Swift Package Manager automatically uses `BUILT_PRODUCTS_DIR` as a framework search path. CocoaPods will continue to run and be used to support non-Swift Package compatible Flutter plugins. ## Not Included Features It does not include the following (will be added in future PRs): * Create plugin template * Create app template * Add-to-App integration
This commit is contained in:
committed by
GitHub
parent
f0fc419a6c
commit
6d19fa3bfa
@@ -15,10 +15,10 @@ LICENSE
|
||||
}
|
||||
s.author = { 'Flutter Team' => 'flutter-dev@googlegroups.com' }
|
||||
s.source = { :http => 'https://github.com/flutter/flutter/tree/main/packages/integration_test/integration_test_macos' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.source_files = 'integration_test_macos/Sources/integration_test_macos/**/*'
|
||||
s.dependency 'FlutterMacOS'
|
||||
|
||||
s.platform = :osx, '10.11'
|
||||
s.platform = :osx, '10.14'
|
||||
s.swift_version = '5.0'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
end
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// swift-tools-version: 5.9
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "integration_test_macos",
|
||||
platforms: [
|
||||
.macOS("10.14"),
|
||||
],
|
||||
products: [
|
||||
.library(name: "integration-test-macos", targets: ["integration_test_macos"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "integration_test_macos",
|
||||
resources: [
|
||||
.process("Resources"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -15,8 +15,8 @@ LICENSE
|
||||
}
|
||||
s.author = { 'Flutter Team' => 'flutter-dev@googlegroups.com' }
|
||||
s.source = { :http => 'https://github.com/flutter/flutter/tree/main/packages/integration_test' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.source_files = 'integration_test/Sources/integration_test/**/*.{h,m}'
|
||||
s.public_header_files = 'integration_test/Sources/integration_test/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
s.ios.framework = 'UIKit'
|
||||
|
||||
|
||||
25
packages/integration_test/ios/integration_test/Package.swift
Normal file
25
packages/integration_test/ios/integration_test/Package.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
// swift-tools-version: 5.9
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "integration_test",
|
||||
platforms: [
|
||||
.iOS("12.0"),
|
||||
],
|
||||
products: [
|
||||
.library(name: "integration-test", targets: ["integration_test"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "integration_test",
|
||||
resources: [
|
||||
.process("Resources"),
|
||||
],
|
||||
cSettings: [
|
||||
.headerSearchPath("include/integration_test"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user