Skip to content

Commit 2e9c5fe

Browse files
committed
Add Swift Package Manager support for permission_handler_apple
- Move source files to SPM-compliant structure (ios/permission_handler_apple/Sources/) - Add Package.swift with environment-based permission defines - Update podspec to reference new file locations - Add GitHub workflow matrix testing for both CocoaPods and SPM - Maintain backward compatibility with existing CocoaPods setup Follows on Baseflow#1440 and fixes Baseflow#1439
1 parent d842345 commit 2e9c5fe

File tree

49 files changed

+71
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+71
-6
lines changed

.github/workflows/permission_handler_apple.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
# should be moved back to `macos-latest` when GitHub Actions images are updated.
2929
runs-on: macos-15
3030

31+
strategy:
32+
matrix:
33+
dependency-manager: [cocoapods, spm]
34+
3135
env:
3236
source-directory: ./permission_handler_apple
3337
example-directory: ./permission_handler_apple/example
@@ -57,7 +61,17 @@ jobs:
5761
run: flutter analyze
5862
working-directory: ${{env.source-directory}}
5963

64+
# Configure dependency manager
65+
- name: Configure dependency manager
66+
run: |
67+
if [ "${{ matrix.dependency-manager }}" = "spm" ]; then
68+
flutter config --enable-swift-package-manager
69+
cd ${{env.example-directory}}/ios && rm -rf Podfile Podfile.lock Pods
70+
else
71+
flutter config --no-enable-swift-package-manager
72+
fi
73+
6074
# Build iOS version of the example App
61-
- name: Run iOS build
75+
- name: Run iOS build (${{ matrix.dependency-manager }})
6276
run: flutter build ios --no-codesign --release
6377
working-directory: ${{env.example-directory}}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ flutter_export_environment.sh
8383
**/ios/Flutter/App.framework
8484
**/ios/Flutter/Flutter.framework
8585
**/ios/Flutter/Generated.xcconfig
86+
**/ios/Flutter/ephemeral/
8687
**/ios/Flutter/app.flx
8788
**/ios/Flutter/app.zip
8889
**/ios/Flutter/flutter_assets/

permission_handler_apple/example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

permission_handler_apple/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ dev_dependencies:
2121
# the parent directory to use the current plugin's version.
2222
path: ../
2323

24-
url_launcher: ^6.0.12
24+
url_launcher: ^6.3.0
2525

2626
flutter:
2727
uses-material-design: true

permission_handler_apple/ios/permission_handler_apple.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Andro
1212
s.license = { :file => '../LICENSE' }
1313
s.author = { 'Baseflow' => '[email protected]' }
1414
s.source = { :path => '.' }
15-
s.source_files = 'Classes/**/*'
16-
s.public_header_files = 'Classes/**/*.h'
15+
s.source_files = 'permission_handler_apple/Sources/permission_handler_apple/**/*'
16+
s.public_header_files = 'permission_handler_apple/Sources/permission_handler_apple/include/permission_handler_apple/*.h'
1717
s.dependency 'Flutter'
1818

1919
s.ios.deployment_target = '8.0'
2020
s.static_framework = true
21-
s.resource_bundles = {'permission_handler_apple_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
21+
s.resource_bundles = {'permission_handler_apple_privacy' => ['permission_handler_apple/Sources/permission_handler_apple/Resources/PrivacyInfo.xcprivacy']}
2222
end
2323

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// swift-tools-version: 5.9
2+
import PackageDescription
3+
4+
let environmentVariables = ProcessInfo.processInfo.environment
5+
6+
let permissionDefines: [CSetting] = [
7+
.define("PERMISSION_EVENTS", to: environmentVariables["PERMISSION_EVENTS"] ?? "0"),
8+
.define("PERMISSION_EVENTS_FULL_ACCESS", to: environmentVariables["PERMISSION_EVENTS_FULL_ACCESS"] ?? "0"),
9+
.define("PERMISSION_REMINDERS", to: environmentVariables["PERMISSION_REMINDERS"] ?? "0"),
10+
.define("PERMISSION_CONTACTS", to: environmentVariables["PERMISSION_CONTACTS"] ?? "0"),
11+
.define("PERMISSION_CAMERA", to: environmentVariables["PERMISSION_CAMERA"] ?? "0"),
12+
.define("PERMISSION_MICROPHONE", to: environmentVariables["PERMISSION_MICROPHONE"] ?? "0"),
13+
.define("PERMISSION_SPEECH_RECOGNIZER", to: environmentVariables["PERMISSION_SPEECH_RECOGNIZER"] ?? "0"),
14+
.define("PERMISSION_PHOTOS", to: environmentVariables["PERMISSION_PHOTOS"] ?? "0"),
15+
.define("PERMISSION_LOCATION", to: environmentVariables["PERMISSION_LOCATION"] ?? "0"),
16+
.define("PERMISSION_LOCATION_WHENINUSE", to: environmentVariables["PERMISSION_LOCATION_WHENINUSE"] ?? "0"),
17+
.define("PERMISSION_NOTIFICATIONS", to: environmentVariables["PERMISSION_NOTIFICATIONS"] ?? "0"),
18+
.define("PERMISSION_MEDIA_LIBRARY", to: environmentVariables["PERMISSION_MEDIA_LIBRARY"] ?? "0"),
19+
.define("PERMISSION_SENSORS", to: environmentVariables["PERMISSION_SENSORS"] ?? "0"),
20+
.define("PERMISSION_BLUETOOTH", to: environmentVariables["PERMISSION_BLUETOOTH"] ?? "0"),
21+
.define("PERMISSION_APP_TRACKING_TRANSPARENCY", to: environmentVariables["PERMISSION_APP_TRACKING_TRANSPARENCY"] ?? "0"),
22+
.define("PERMISSION_CRITICAL_ALERTS", to: environmentVariables["PERMISSION_CRITICAL_ALERTS"] ?? "0")
23+
]
24+
25+
let package = Package(
26+
name: "permission-handler-apple",
27+
platforms: [
28+
.iOS(.v12)
29+
],
30+
products: [
31+
.library(
32+
name: "permission-handler-apple",
33+
targets: ["permission-handler-apple"]),
34+
],
35+
dependencies: [],
36+
targets: [
37+
.target(
38+
name: "permission-handler-apple",
39+
dependencies: [],
40+
path: "Sources/permission_handler_apple",
41+
resources: [
42+
.copy("Resources/PrivacyInfo.xcprivacy")
43+
],
44+
publicHeadersPath: "include",
45+
cSettings: [
46+
.headerSearchPath("include/permission_handler_apple")
47+
] + permissionDefines
48+
),
49+
]
50+
)

0 commit comments

Comments
 (0)