From 6872c3b8d42d748282de732e025b21127bf05dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Fri, 31 May 2024 12:03:36 -0700 Subject: [PATCH] [image_picker_ios] Re-adds Swift Package Manager compatibility (#6833) Adds Swift Package Manager compatibility to `image_picker_ios`. The previous attempt, https://github.com/flutter/packages/pull/6617, was partially reverted due to https://github.com/flutter/flutter/issues/148307. This reland uses the new approach proposed in https://github.com/flutter/flutter/issues/148572: the Swift Package Manager package does not have a `.modulemap`. As a result, the plugin no longer has a `.Test` submodule if using Swift Package Manager. Fixes https://github.com/flutter/flutter/issues/146919. --- .../image_picker_ios/CHANGELOG.md | 4 +++ .../ios/RunnerTests/ImagePickerPluginTests.m | 2 ++ .../example/ios/RunnerTests/ImageUtilTests.m | 2 ++ .../ios/RunnerTests/MetaDataUtilTests.m | 2 ++ .../ios/RunnerTests/PhotoAssetUtilTests.m | 2 ++ .../PickerSaveImageToPathOperationTests.m | 2 ++ .../ios/image_picker_ios/Package.swift | 31 +++++++++++++++++++ .../image_picker_ios/pubspec.yaml | 2 +- 8 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 packages/image_picker/image_picker_ios/ios/image_picker_ios/Package.swift diff --git a/packages/image_picker/image_picker_ios/CHANGELOG.md b/packages/image_picker/image_picker_ios/CHANGELOG.md index 7a131df2c8a1..4bbdbe6e865a 100644 --- a/packages/image_picker/image_picker_ios/CHANGELOG.md +++ b/packages/image_picker/image_picker_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.12 + +* Re-adds Swift Package Manager compatibility. + ## 0.8.11+2 * Temporarily remove Swift Package Manager compatibility to resolve issues with Cocoapods builds. diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m index d54d5c3ec248..3ade851e1ec9 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImagePickerPluginTests.m @@ -5,7 +5,9 @@ #import "ImagePickerTestImages.h" @import image_picker_ios; +#if __has_include() @import image_picker_ios.Test; +#endif @import UniformTypeIdentifiers; @import XCTest; diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImageUtilTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImageUtilTests.m index c5332425bde6..6be8f28bd3da 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImageUtilTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/ImageUtilTests.m @@ -5,7 +5,9 @@ #import "ImagePickerTestImages.h" @import image_picker_ios; +#if __has_include() @import image_picker_ios.Test; +#endif @import XCTest; // Corner colors of test image scaled to 3x2. Format is "R G B A". diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/MetaDataUtilTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/MetaDataUtilTests.m index b684a214570b..2ae51cdb93f5 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/MetaDataUtilTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/MetaDataUtilTests.m @@ -5,7 +5,9 @@ #import "ImagePickerTestImages.h" @import image_picker_ios; +#if __has_include() @import image_picker_ios.Test; +#endif @import XCTest; @interface MetaDataUtilTests : XCTestCase diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PhotoAssetUtilTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PhotoAssetUtilTests.m index fd8a2fcc810c..45ad94a00e02 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PhotoAssetUtilTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PhotoAssetUtilTests.m @@ -5,7 +5,9 @@ #import "ImagePickerTestImages.h" @import image_picker_ios; +#if __has_include() @import image_picker_ios.Test; +#endif @import XCTest; @interface PhotoAssetUtilTests : XCTestCase diff --git a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PickerSaveImageToPathOperationTests.m b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PickerSaveImageToPathOperationTests.m index ad0a4c4b7028..b9c97a645fb8 100644 --- a/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PickerSaveImageToPathOperationTests.m +++ b/packages/image_picker/image_picker_ios/example/ios/RunnerTests/PickerSaveImageToPathOperationTests.m @@ -5,7 +5,9 @@ #import @import image_picker_ios; +#if __has_include() @import image_picker_ios.Test; +#endif @import UniformTypeIdentifiers; @import XCTest; diff --git a/packages/image_picker/image_picker_ios/ios/image_picker_ios/Package.swift b/packages/image_picker/image_picker_ios/ios/image_picker_ios/Package.swift new file mode 100644 index 000000000000..987b206fb2ee --- /dev/null +++ b/packages/image_picker/image_picker_ios/ios/image_picker_ios/Package.swift @@ -0,0 +1,31 @@ +// swift-tools-version: 5.9 + +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import PackageDescription + +let package = Package( + name: "image_picker_ios", + platforms: [ + .iOS("12.0") + ], + products: [ + .library(name: "image-picker-ios", targets: ["image_picker_ios"]) + ], + dependencies: [], + targets: [ + .target( + name: "image_picker_ios", + dependencies: [], + exclude: ["include/image_picker_ios-umbrella.h", "include/ImagePickerPlugin.modulemap"], + resources: [ + .process("Resources") + ], + cSettings: [ + .headerSearchPath("include/image_picker_ios") + ] + ) + ] +) diff --git a/packages/image_picker/image_picker_ios/pubspec.yaml b/packages/image_picker/image_picker_ios/pubspec.yaml index a824aed35767..bbc99bc79f31 100755 --- a/packages/image_picker/image_picker_ios/pubspec.yaml +++ b/packages/image_picker/image_picker_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: image_picker_ios description: iOS implementation of the image_picker plugin. repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22 -version: 0.8.11+2 +version: 0.8.12 environment: sdk: ^3.3.0