Skip to content

Commit b68cdba

Browse files
committed
fix(macos): include pigeons for swift
1 parent c410c26 commit b68cdba

File tree

2 files changed

+384
-0
lines changed

2 files changed

+384
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,382 @@
1+
// Copyright 2025, the Chromium project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
// Autogenerated from Pigeon (v25.3.2), do not edit directly.
5+
// See also: https://pub.dev/packages/pigeon
6+
7+
import Foundation
8+
9+
#if os(iOS)
10+
import Flutter
11+
#elseif os(macOS)
12+
import FlutterMacOS
13+
#else
14+
#error("Unsupported platform.")
15+
#endif
16+
17+
/// Error class for passing custom error details to Dart side.
18+
final class PigeonError: Error {
19+
let code: String
20+
let message: String?
21+
let details: Sendable?
22+
23+
init(code: String, message: String?, details: Sendable?) {
24+
self.code = code
25+
self.message = message
26+
self.details = details
27+
}
28+
29+
var localizedDescription: String {
30+
return
31+
"PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")"
32+
}
33+
}
34+
35+
private func wrapResult(_ result: Any?) -> [Any?] {
36+
return [result]
37+
}
38+
39+
private func wrapError(_ error: Any) -> [Any?] {
40+
if let pigeonError = error as? PigeonError {
41+
return [
42+
pigeonError.code,
43+
pigeonError.message,
44+
pigeonError.details,
45+
]
46+
}
47+
if let flutterError = error as? FlutterError {
48+
return [
49+
flutterError.code,
50+
flutterError.message,
51+
flutterError.details,
52+
]
53+
}
54+
return [
55+
"\(error)",
56+
"\(type(of: error))",
57+
"Stacktrace: \(Thread.callStackSymbols)",
58+
]
59+
}
60+
61+
private func createConnectionError(withChannelName channelName: String) -> PigeonError {
62+
return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "")
63+
}
64+
65+
private func isNullish(_ value: Any?) -> Bool {
66+
return value is NSNull || value == nil
67+
}
68+
69+
private func nilOrValue<T>(_ value: Any?) -> T? {
70+
if value is NSNull { return nil }
71+
return value as! T?
72+
}
73+
74+
func deepEqualsFirebaseAppInstallationsMessages(_ lhs: Any?, _ rhs: Any?) -> Bool {
75+
let cleanLhs = nilOrValue(lhs) as Any?
76+
let cleanRhs = nilOrValue(rhs) as Any?
77+
switch (cleanLhs, cleanRhs) {
78+
case (nil, nil):
79+
return true
80+
81+
case (nil, _), (_, nil):
82+
return false
83+
84+
case is (Void, Void):
85+
return true
86+
87+
case let (cleanLhsHashable, cleanRhsHashable) as (AnyHashable, AnyHashable):
88+
return cleanLhsHashable == cleanRhsHashable
89+
90+
case let (cleanLhsArray, cleanRhsArray) as ([Any?], [Any?]):
91+
guard cleanLhsArray.count == cleanRhsArray.count else { return false }
92+
for (index, element) in cleanLhsArray.enumerated() {
93+
if !deepEqualsFirebaseAppInstallationsMessages(element, cleanRhsArray[index]) {
94+
return false
95+
}
96+
}
97+
return true
98+
99+
case let (cleanLhsDictionary, cleanRhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]):
100+
guard cleanLhsDictionary.count == cleanRhsDictionary.count else { return false }
101+
for (key, cleanLhsValue) in cleanLhsDictionary {
102+
guard cleanRhsDictionary.index(forKey: key) != nil else { return false }
103+
if !deepEqualsFirebaseAppInstallationsMessages(cleanLhsValue, cleanRhsDictionary[key]!) {
104+
return false
105+
}
106+
}
107+
return true
108+
109+
default:
110+
// Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue.
111+
return false
112+
}
113+
}
114+
115+
func deepHashFirebaseAppInstallationsMessages(value: Any?, hasher: inout Hasher) {
116+
if let valueList = value as? [AnyHashable] {
117+
for item in valueList { deepHashFirebaseAppInstallationsMessages(value: item, hasher: &hasher) }
118+
return
119+
}
120+
121+
if let valueDict = value as? [AnyHashable: AnyHashable] {
122+
for key in valueDict.keys {
123+
hasher.combine(key)
124+
deepHashFirebaseAppInstallationsMessages(value: valueDict[key]!, hasher: &hasher)
125+
}
126+
return
127+
}
128+
129+
if let hashableValue = value as? AnyHashable {
130+
hasher.combine(hashableValue.hashValue)
131+
}
132+
133+
return hasher.combine(String(describing: value))
134+
}
135+
136+
137+
138+
/// Generated class from Pigeon that represents data sent in messages.
139+
struct AppInstallationsPigeonSettings: Hashable {
140+
var persistenceEnabled: Bool
141+
var forceRefreshOnSignIn: Bool
142+
var forceRefreshOnTokenChange: Bool
143+
var forceRefreshOnAppUpdate: Bool
144+
145+
146+
// swift-format-ignore: AlwaysUseLowerCamelCase
147+
static func fromList(_ pigeonVar_list: [Any?]) -> AppInstallationsPigeonSettings? {
148+
let persistenceEnabled = pigeonVar_list[0] as! Bool
149+
let forceRefreshOnSignIn = pigeonVar_list[1] as! Bool
150+
let forceRefreshOnTokenChange = pigeonVar_list[2] as! Bool
151+
let forceRefreshOnAppUpdate = pigeonVar_list[3] as! Bool
152+
153+
return AppInstallationsPigeonSettings(
154+
persistenceEnabled: persistenceEnabled,
155+
forceRefreshOnSignIn: forceRefreshOnSignIn,
156+
forceRefreshOnTokenChange: forceRefreshOnTokenChange,
157+
forceRefreshOnAppUpdate: forceRefreshOnAppUpdate
158+
)
159+
}
160+
func toList() -> [Any?] {
161+
return [
162+
persistenceEnabled,
163+
forceRefreshOnSignIn,
164+
forceRefreshOnTokenChange,
165+
forceRefreshOnAppUpdate,
166+
]
167+
}
168+
static func == (lhs: AppInstallationsPigeonSettings, rhs: AppInstallationsPigeonSettings) -> Bool {
169+
return deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) }
170+
func hash(into hasher: inout Hasher) {
171+
deepHashFirebaseAppInstallationsMessages(value: toList(), hasher: &hasher)
172+
}
173+
}
174+
175+
/// Generated class from Pigeon that represents data sent in messages.
176+
struct AppInstallationsPigeonFirebaseApp: Hashable {
177+
var appName: String
178+
179+
180+
// swift-format-ignore: AlwaysUseLowerCamelCase
181+
static func fromList(_ pigeonVar_list: [Any?]) -> AppInstallationsPigeonFirebaseApp? {
182+
let appName = pigeonVar_list[0] as! String
183+
184+
return AppInstallationsPigeonFirebaseApp(
185+
appName: appName
186+
)
187+
}
188+
func toList() -> [Any?] {
189+
return [
190+
appName
191+
]
192+
}
193+
static func == (lhs: AppInstallationsPigeonFirebaseApp, rhs: AppInstallationsPigeonFirebaseApp) -> Bool {
194+
return deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) }
195+
func hash(into hasher: inout Hasher) {
196+
deepHashFirebaseAppInstallationsMessages(value: toList(), hasher: &hasher)
197+
}
198+
}
199+
200+
private class FirebaseAppInstallationsMessagesPigeonCodecReader: FlutterStandardReader {
201+
override func readValue(ofType type: UInt8) -> Any? {
202+
switch type {
203+
case 129:
204+
return AppInstallationsPigeonSettings.fromList(self.readValue() as! [Any?])
205+
case 130:
206+
return AppInstallationsPigeonFirebaseApp.fromList(self.readValue() as! [Any?])
207+
default:
208+
return super.readValue(ofType: type)
209+
}
210+
}
211+
}
212+
213+
private class FirebaseAppInstallationsMessagesPigeonCodecWriter: FlutterStandardWriter {
214+
override func writeValue(_ value: Any) {
215+
if let value = value as? AppInstallationsPigeonSettings {
216+
super.writeByte(129)
217+
super.writeValue(value.toList())
218+
} else if let value = value as? AppInstallationsPigeonFirebaseApp {
219+
super.writeByte(130)
220+
super.writeValue(value.toList())
221+
} else {
222+
super.writeValue(value)
223+
}
224+
}
225+
}
226+
227+
private class FirebaseAppInstallationsMessagesPigeonCodecReaderWriter: FlutterStandardReaderWriter {
228+
override func reader(with data: Data) -> FlutterStandardReader {
229+
return FirebaseAppInstallationsMessagesPigeonCodecReader(data: data)
230+
}
231+
232+
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
233+
return FirebaseAppInstallationsMessagesPigeonCodecWriter(data: data)
234+
}
235+
}
236+
237+
class FirebaseAppInstallationsMessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
238+
static let shared = FirebaseAppInstallationsMessagesPigeonCodec(readerWriter: FirebaseAppInstallationsMessagesPigeonCodecReaderWriter())
239+
}
240+
241+
242+
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
243+
protocol FirebaseAppInstallationsHostApi {
244+
func initializeApp(app: AppInstallationsPigeonFirebaseApp, settings: AppInstallationsPigeonSettings, completion: @escaping (Result<Void, Error>) -> Void)
245+
func delete(app: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result<Void, Error>) -> Void)
246+
func getId(app: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result<String, Error>) -> Void)
247+
func getToken(app: AppInstallationsPigeonFirebaseApp, forceRefresh: Bool, completion: @escaping (Result<String, Error>) -> Void)
248+
func onIdChange(app: AppInstallationsPigeonFirebaseApp, newId: String, completion: @escaping (Result<Void, Error>) -> Void)
249+
}
250+
251+
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
252+
class FirebaseAppInstallationsHostApiSetup {
253+
static var codec: FlutterStandardMessageCodec { FirebaseAppInstallationsMessagesPigeonCodec.shared }
254+
/// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binaryMessenger`.
255+
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: FirebaseAppInstallationsHostApi?, messageChannelSuffix: String = "") {
256+
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
257+
let initializeAppChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
258+
if let api = api {
259+
initializeAppChannel.setMessageHandler { message, reply in
260+
let args = message as! [Any?]
261+
let appArg = args[0] as! AppInstallationsPigeonFirebaseApp
262+
let settingsArg = args[1] as! AppInstallationsPigeonSettings
263+
api.initializeApp(app: appArg, settings: settingsArg) { result in
264+
switch result {
265+
case .success:
266+
reply(wrapResult(nil))
267+
case .failure(let error):
268+
reply(wrapError(error))
269+
}
270+
}
271+
}
272+
} else {
273+
initializeAppChannel.setMessageHandler(nil)
274+
}
275+
let deleteChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
276+
if let api = api {
277+
deleteChannel.setMessageHandler { message, reply in
278+
let args = message as! [Any?]
279+
let appArg = args[0] as! AppInstallationsPigeonFirebaseApp
280+
api.delete(app: appArg) { result in
281+
switch result {
282+
case .success:
283+
reply(wrapResult(nil))
284+
case .failure(let error):
285+
reply(wrapError(error))
286+
}
287+
}
288+
}
289+
} else {
290+
deleteChannel.setMessageHandler(nil)
291+
}
292+
let getIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
293+
if let api = api {
294+
getIdChannel.setMessageHandler { message, reply in
295+
let args = message as! [Any?]
296+
let appArg = args[0] as! AppInstallationsPigeonFirebaseApp
297+
api.getId(app: appArg) { result in
298+
switch result {
299+
case .success(let res):
300+
reply(wrapResult(res))
301+
case .failure(let error):
302+
reply(wrapError(error))
303+
}
304+
}
305+
}
306+
} else {
307+
getIdChannel.setMessageHandler(nil)
308+
}
309+
let getTokenChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
310+
if let api = api {
311+
getTokenChannel.setMessageHandler { message, reply in
312+
let args = message as! [Any?]
313+
let appArg = args[0] as! AppInstallationsPigeonFirebaseApp
314+
let forceRefreshArg = args[1] as! Bool
315+
api.getToken(app: appArg, forceRefresh: forceRefreshArg) { result in
316+
switch result {
317+
case .success(let res):
318+
reply(wrapResult(res))
319+
case .failure(let error):
320+
reply(wrapError(error))
321+
}
322+
}
323+
}
324+
} else {
325+
getTokenChannel.setMessageHandler(nil)
326+
}
327+
let onIdChangeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
328+
if let api = api {
329+
onIdChangeChannel.setMessageHandler { message, reply in
330+
let args = message as! [Any?]
331+
let appArg = args[0] as! AppInstallationsPigeonFirebaseApp
332+
let newIdArg = args[1] as! String
333+
api.onIdChange(app: appArg, newId: newIdArg) { result in
334+
switch result {
335+
case .success:
336+
reply(wrapResult(nil))
337+
case .failure(let error):
338+
reply(wrapError(error))
339+
}
340+
}
341+
}
342+
} else {
343+
onIdChangeChannel.setMessageHandler(nil)
344+
}
345+
}
346+
}
347+
/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift.
348+
protocol FirebaseAppInstallationsFlutterApiProtocol {
349+
func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result<String, PigeonError>) -> Void)
350+
}
351+
class FirebaseAppInstallationsFlutterApi: FirebaseAppInstallationsFlutterApiProtocol {
352+
private let binaryMessenger: FlutterBinaryMessenger
353+
private let messageChannelSuffix: String
354+
init(binaryMessenger: FlutterBinaryMessenger, messageChannelSuffix: String = "") {
355+
self.binaryMessenger = binaryMessenger
356+
self.messageChannelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
357+
}
358+
var codec: FirebaseAppInstallationsMessagesPigeonCodec {
359+
return FirebaseAppInstallationsMessagesPigeonCodec.shared
360+
}
361+
func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result<String, PigeonError>) -> Void) {
362+
let channelName: String = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener\(messageChannelSuffix)"
363+
let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec)
364+
channel.sendMessage([appArg] as [Any?]) { response in
365+
guard let listResponse = response as? [Any?] else {
366+
completion(.failure(createConnectionError(withChannelName: channelName)))
367+
return
368+
}
369+
if listResponse.count > 1 {
370+
let code: String = listResponse[0] as! String
371+
let message: String? = nilOrValue(listResponse[1])
372+
let details: String? = nilOrValue(listResponse[2])
373+
completion(.failure(PigeonError(code: code, message: message, details: details)))
374+
} else if listResponse[0] == nil {
375+
completion(.failure(PigeonError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: "")))
376+
} else {
377+
let result = listResponse[0] as! String
378+
completion(.success(result))
379+
}
380+
}
381+
}
382+
}

packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import 'package:pigeon/pigeon.dart';
1919
'../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h',
2020
objcSourceOut:
2121
'../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m',
22+
swiftOut:
23+
'../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift',
2224
cppHeaderOut: '../firebase_app_installations/windows/messages.g.h',
2325
cppSourceOut: '../firebase_app_installations/windows/messages.g.cpp',
2426
cppOptions: CppOptions(namespace: 'firebase_app_installations_windows'),

0 commit comments

Comments
 (0)