-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
integration_test is currently included in a newly flutter created pubspec. It is embedded in iOS projects via CocoaPods as is normal for a plugin (though really it should only be embedded in a test target, but that's a fixable bug). This means that every project will need to be opted into CocoaPods (currently a dependency only required with plugins), even though integration_test has no pod dependencies and is not even distributed via pub.
This plugin is shipped in the repository proper, so it may instead possible to integrate it into test projects via Swift Package Manager, bypassing CocoaPods completely.
I have a prototype working with a Package.swift file in the root of the Flutter repo:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "Flutter",
platforms: [
.iOS(.v9)
],
products: [
.library(
name: "integration_test",
targets: ["integration_test"]),
],
targets: [
.target(
name: "integration_test",
dependencies: ["Flutter"],
path: "packages/integration_test/ios",
exclude: ["integration_test.podspec"],
sources: ["Classes"],
publicHeadersPath: "Classes"
),
.binaryTarget(
name: "Flutter",
path: "bin/cache/artifacts/engine/ios-release/Flutter.xcframework"),
]
)To test this, drag the flutter repo directory into Frameworks:

Create a test target with @import integration_test, Link Binary with Libraries, and choose integration_test

It should then build.
Notes:
- The Flutter
binaryTargetis required sinceintegration_testimportsFlutter. I wasn't able to get any linker tricks working to avoid this. - Since
binaryTargetis required, this will only work in Xcode 12+ (Swift 5.3) where the feature was introduced. Currently the minimum Xcode version enforced in the tool is 11.0. - All places where plugins==CocoaPods is assumed needs to be hard coded to avoid integration_test the tool. For example, don't generate a
Podfilewhen it's the only plugin, etc. integration_testshould be removed fromGeneratedPluginRegistrantsince the app proper should never link on this.- The
pathto the Package.swift will need to be a property in the Xcode project. The path can't actually be the absolute path to the user's Flutter SDK since that will be different on every machine, and this file is checked in and shared between team members. That probably means creating a symlink to the project to the repo (inios/.symlinks/flutter?) recreated on everyensureReadyForPlatformSpecificTooling.
F7FA93DA258AEF2200C1C93B /* flutter */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter; path = path/to/flutter; sourceTree = "<group>"; };
Blocked by #57083