Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOBILE-4771: Research Flutter SPM support #245

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 70 additions & 48 deletions example/ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion example/ios/Runner/AirshipPluginExtender.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/* Copyright Airship and Contributors */

import Foundation
import AirshipKit
import AirshipFrameworkProxy
import ActivityKit

#if canImport(AirshipCore)
import AirshipCore
#else
import AirshipKit
#endif

@objc(AirshipPluginExtender)
public class AirshipPluginExtender: NSObject, AirshipPluginExtenderProtocol {

Expand Down
5 changes: 5 additions & 0 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import UIKit
import Flutter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does anything in this example actually need to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've updated the example app to support both cocoapods and spm framework usage. adding flutter is required as if there is no cocoapods, the flutter dependency is not added


#if canImport(AirshipCore)
import AirshipCore
#else
import AirshipKit
#endif

@main
@objc class AppDelegate: FlutterAppDelegate {
Expand Down
2 changes: 2 additions & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
.DS_Store
*.swp
profile
airship_flutter/.swiftpm/
airship_flutter/.build/

DerivedData/
build/
Expand Down
Empty file removed ios/Assets/.gitkeep
Empty file.
4 changes: 0 additions & 4 deletions ios/Classes/AirshipPlugin.h

This file was deleted.

8 changes: 0 additions & 8 deletions ios/Classes/AirshipPlugin.m

This file was deleted.

4 changes: 2 additions & 2 deletions ios/airship_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Airship flutter plugin.
s.license = { :file => '../LICENSE' }
s.author = { 'Airship' => '[email protected]' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.source_files = 'airship_flutter/Sources/airship_flutter/**/*'
s.dependency 'Flutter'
s.ios.deployment_target = "14.0"
s.dependency "AirshipFrameworkProxy", "11.1.0"
s.swift_version = "5.0.0"
s.resource_bundles = {'airship_flutter_privacy' => ['airship_flutter/Sources/airship_flutter/PrivacyInfo.xcprivacy']}
end

26 changes: 26 additions & 0 deletions ios/airship_flutter/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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: "airship_flutter",
platforms: [.macOS(.v10_15), .iOS(.v14), .tvOS(.v14), .visionOS(.v1)],
products: [
.library( name: "airship-flutter", targets: ["airship_flutter"])
],
dependencies: [
.package(url: "https://github.com/urbanairship/airship-mobile-framework-proxy.git", from: "11.2.2")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to set the correct new version of the proxy once urbanairship/airship-mobile-framework-proxy#75 is merged and released

],
targets: [
.target(
name: "airship_flutter",
dependencies: [
.product(name: "AirshipFrameworkProxy", package: "airship-mobile-framework-proxy")
],
resources: [
.process("PrivacyInfo.xcprivacy")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import Flutter
import AirshipKit
import AirshipFrameworkProxy

#if canImport(AirshipCore)
import AirshipCore
#else
import AirshipKit
#endif

public class AirshipAutopilot: NSObject {

@objc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import Foundation
import AirshipKit
import SwiftUI
import Flutter

#if canImport(AirshipCore)
import AirshipCore
#else
import AirshipKit
#endif

class AirshipEmbeddedViewFactory: NSObject, FlutterPlatformViewFactory {
let registrar: FlutterPluginRegistrar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import Foundation
import AirshipKit
import WebKit
import Flutter

#if canImport(AirshipCore)
import AirshipCore
import AirshipMessageCenter
#else
import AirshipKit
#endif

class AirshipInboxMessageViewFactory : NSObject, FlutterPlatformViewFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import Flutter
import UIKit
import AirshipKit
import AirshipFrameworkProxy
import Combine

public class SwiftAirshipPlugin: NSObject, FlutterPlugin {
#if canImport(AirshipCore)
import AirshipCore
#else
import AirshipKit
#endif

public class AirshipPlugin: NSObject, FlutterPlugin {
private static let eventNames: [AirshipProxyEventType: String] = [
.authorizedNotificationSettingsChanged: "com.airship.flutter/event/ios_authorized_notification_settings_changed",
.pushTokenReceived: "com.airship.flutter/event/push_token_received",
Expand All @@ -21,18 +26,18 @@ public class SwiftAirshipPlugin: NSObject, FlutterPlugin {

private let streams: [AirshipProxyEventType: AirshipEventStream] = {
var streams: [AirshipProxyEventType: AirshipEventStream] = [:]
SwiftAirshipPlugin.eventNames.forEach { (key: AirshipProxyEventType, value: String) in
AirshipPlugin.eventNames.forEach { (key: AirshipProxyEventType, value: String) in
streams[key] = AirshipEventStream(key, name: value)
}
return streams
}()

private var subscriptions = Set<AnyCancellable>()

static let shared = SwiftAirshipPlugin()
static let shared = AirshipPlugin()

public static func register(with registrar: FlutterPluginRegistrar) {
SwiftAirshipPlugin.shared.setup(registrar: registrar)
AirshipPlugin.shared.setup(registrar: registrar)
}

private func setup(registrar: FlutterPluginRegistrar) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AirshipFrameworkProxy
import UIKit

@objc(AirshipPluginLoader)
public class AirshipPluginLoader: NSObject, AirshipPluginLoaderProtocol {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeProductInteraction</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
<string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string>
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDataTypes</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
<string>NSPrivacyCollectedDataTypePurposeProductPersonalization</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeUserID</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeDeveloperAdvertising</string>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
</array>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>