Skip to content

Commit cef4041

Browse files
committed
fix: Firebase 초기화 책임을 Infra 레이어로 이동
1 parent ff93960 commit cef4041

9 files changed

Lines changed: 116 additions & 37 deletions

File tree

Application/DevLogApp/DevLogApp.xcodeproj/project.pbxproj

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
618B54224ACD6B35D9A8F841 /* DevLogWidgetCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBFCE939492CAE5AB44E6B81 /* DevLogWidgetCore.framework */; };
1717
7188DA2B6DFD13F7FF73069E /* DevLogInfra.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A6AEE3AFC586C92F1643282 /* DevLogInfra.framework */; };
1818
79134AD67952720CCC5069EA /* DevLogPersistence.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6FFA0A819CB16649AC35CCE6 /* DevLogPersistence.framework */; };
19-
8D3BD712CB129F2527B00CFB /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = E72BBE64130E2666E4680E1B /* FirebaseMessaging */; };
2019
0B50A22827B641AEBCC033D4 /* DevLogWidgetCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EBFCE939492CAE5AB44E6B81 /* DevLogWidgetCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2120
1E452BFF04594187A06AED58 /* DevLogDomain.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA49949C677DDE083F7DE29E /* DevLogDomain.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2221
393544DD58D941B69760727E /* DevLogPresentation.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 67918B544432C45E63273D84 /* DevLogPresentation.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2322
AB11B22C33D44E55F6677889 /* DevLogCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE11B22C33D44E55F6677889 /* DevLogCore.framework */; };
2423
A54A1843C2074FD4A651238F /* DevLogWidgetCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EBFCE939492CAE5AB44E6B81 /* DevLogWidgetCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
25-
B05135963579A188BC8AC7AA /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = 0B7D3A68C7E7BF5D4A437D29 /* FirebaseCore */; };
2624
B38B9C91AECB49BA9C7CB8DC /* DevLogPersistence.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6FFA0A819CB16649AC35CCE6 /* DevLogPersistence.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2725
B9409E4F83EB4B0A9049D245 /* DevLogInfra.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9A6AEE3AFC586C92F1643282 /* DevLogInfra.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
2826
DA205F52B7C54C2C99671D50 /* DevLogCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AE11B22C33D44E55F6677889 /* DevLogCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -282,8 +280,6 @@
282280
79134AD67952720CCC5069EA /* DevLogPersistence.framework in Frameworks */,
283281
26C3DC51F23F9C590FDB282D /* DevLogPresentation.framework in Frameworks */,
284282
1589C1EF4029ECBF15A842F0 /* DevLogWidgetCore.framework in Frameworks */,
285-
B05135963579A188BC8AC7AA /* FirebaseCore in Frameworks */,
286-
8D3BD712CB129F2527B00CFB /* FirebaseMessaging in Frameworks */,
287283
18D57A125ACCF0F6B11A7101 /* GoogleSignIn in Frameworks */,
288284
160E41BDADA3136CD58BE0B4 /* DevLogData.framework in Frameworks */,
289285
);
@@ -418,8 +414,6 @@
418414
);
419415
name = DevLog;
420416
packageProductDependencies = (
421-
0B7D3A68C7E7BF5D4A437D29 /* FirebaseCore */,
422-
E72BBE64130E2666E4680E1B /* FirebaseMessaging */,
423417
F972F1E8E0F5156FE9651020 /* GoogleSignIn */,
424418
);
425419
productName = SwiftUI_DevLog;
@@ -460,7 +454,6 @@
460454
minimizedProjectReferenceProxies = 1;
461455
packageReferences = (
462456
DF66A07B2EA52E970098E643 /* XCRemoteSwiftPackageReference "SwiftLint" */,
463-
D7AE705B27EA8F3775A1284E /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
464457
1D75B0AFC69F88110A25217B /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */,
465458
);
466459
preferredProjectObjectVersion = 77;
@@ -1060,14 +1053,6 @@
10601053
minimumVersion = 9.0.0;
10611054
};
10621055
};
1063-
D7AE705B27EA8F3775A1284E /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
1064-
isa = XCRemoteSwiftPackageReference;
1065-
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
1066-
requirement = {
1067-
kind = upToNextMajorVersion;
1068-
minimumVersion = 11.15.0;
1069-
};
1070-
};
10711056
DF66A07B2EA52E970098E643 /* XCRemoteSwiftPackageReference "SwiftLint" */ = {
10721057
isa = XCRemoteSwiftPackageReference;
10731058
repositoryURL = "https://github.com/realm/SwiftLint";
@@ -1079,21 +1064,11 @@
10791064
/* End XCRemoteSwiftPackageReference section */
10801065

10811066
/* Begin XCSwiftPackageProductDependency section */
1082-
0B7D3A68C7E7BF5D4A437D29 /* FirebaseCore */ = {
1083-
isa = XCSwiftPackageProductDependency;
1084-
package = D7AE705B27EA8F3775A1284E /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1085-
productName = FirebaseCore;
1086-
};
10871067
DF66A07C2EA52E9F0098E643 /* plugin:SwiftLintBuildToolPlugin */ = {
10881068
isa = XCSwiftPackageProductDependency;
10891069
package = DF66A07B2EA52E970098E643 /* XCRemoteSwiftPackageReference "SwiftLint" */;
10901070
productName = "plugin:SwiftLintBuildToolPlugin";
10911071
};
1092-
E72BBE64130E2666E4680E1B /* FirebaseMessaging */ = {
1093-
isa = XCSwiftPackageProductDependency;
1094-
package = D7AE705B27EA8F3775A1284E /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
1095-
productName = FirebaseMessaging;
1096-
};
10971072
F972F1E8E0F5156FE9651020 /* GoogleSignIn */ = {
10981073
isa = XCSwiftPackageProductDependency;
10991074
package = 1D75B0AFC69F88110A25217B /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */;

Application/DevLogApp/Sources/App/Delegate/AppDelegate.swift

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ import UIKit
99
import DevLogCore
1010
import DevLogData
1111
import DevLogWidgetCore
12-
import Firebase
1312
import GoogleSignIn
1413

15-
class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
14+
class AppDelegate: UIResponder, UIApplicationDelegate {
1615
private let logger = Logger(category: "AppDelegate")
1716
private let container = AppDIContainer.shared
1817

@@ -28,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
2827
_ application: UIApplication,
2928
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
3029
) -> Bool {
31-
FirebaseApp.configure()
30+
container.resolve(FirebaseAppService.self).configure()
3231
_ = container.resolve(FCMTokenSyncHandler.self)
3332
_ = container.resolve(UserTimeZoneSyncHandler.self)
3433
_ = container.resolve(WidgetSyncEventHandler.self)
@@ -50,25 +49,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
5049
NotificationCenter.default.post(name: .didRequestUserTimeZoneSync, object: nil)
5150

5251
// Firebase Messaging 설정
53-
Messaging.messaging().delegate = self
54-
52+
container.resolve(PushMessagingService.self).setDelegate(self)
53+
5554
// 앱이 완전 종료되어도, 알림을 통해 앱이 시작된 경우 처리
5655
if let remoteNotification = launchOptions?[.remoteNotification] as? [AnyHashable: Any] {
5756
Task { @MainActor in
5857
PushNotificationRoute.shared.handlePushTap(userInfo: remoteNotification)
5958
}
6059
}
61-
60+
6261
return true
6362
}
64-
63+
6564
// APNs 등록 성공
6665
func application(
6766
_ application: UIApplication,
6867
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
6968
) {
7069
logger.info("APNs token: \(deviceToken.map { String(format: "%02.2hhx", $0) }.joined())")
71-
Messaging.messaging().apnsToken = deviceToken
70+
container.resolve(PushMessagingService.self).setAPNSToken(deviceToken)
7271
}
7372

7473
// APNs 등록 실패
@@ -78,10 +77,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
7877
logger.error("Failed to register APNs token", error: error)
7978
}
8079

81-
// FCMToken 갱신
82-
func messaging(
83-
_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?
84-
) {
80+
}
81+
82+
extension AppDelegate: PushMessagingServiceDelegate {
83+
func pushMessagingService(_ service: PushMessagingService, didReceiveRegistrationToken fcmToken: String?) {
8584
if let fcmToken = fcmToken {
8685
logger.info("FCM token: \(fcmToken)")
8786
NotificationCenter.default.post(

Application/DevLogData/DevLogData.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
3F09F91345793F8C14F5CC05 /* WidgetSnapshotUpdater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8178F2D3DAE010896141ED /* WidgetSnapshotUpdater.swift */; };
2020
410CB3F18CADB18146AE82B7 /* DataAssembler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29CDDE9287D2855E4AF14021 /* DataAssembler.swift */; };
2121
41371B777FE701652CA2E798 /* AuthenticationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7154773B586C2D41307CD49 /* AuthenticationService.swift */; };
22+
A7084A7C1DE34A0EA3E0E327 /* FirebaseAppService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A9508F58EA84409A10F12A8 /* FirebaseAppService.swift */; };
2223
4BD06832F56598B25183EF06 /* WebPageRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AAF764A3F6E025A18E6A0BC /* WebPageRepositoryImpl.swift */; };
2324
4C0F2F479581D2E091C429B2 /* TodoCategoryRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36E09221F6FBF67359105995 /* TodoCategoryRepositoryImpl.swift */; };
2425
50C769615D094189B739F055 /* UserPreferencesRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0202E26A972D5D274AF77C67 /* UserPreferencesRepositoryImpl.swift */; };
@@ -36,6 +37,7 @@
3637
7FD388EB6C3123479B304478 /* DevLogDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2039D0A2EB1ADD163DFC253D /* DevLogDomain.framework */; };
3738
90776FF719A37EAE1CB1BB1B /* TodoCategoryService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 082E30ECD7061C9E401FF2D0 /* TodoCategoryService.swift */; };
3839
922EECF001AF1EAC4EE5ACAA /* PushNotificationMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C564559DBDF765945456FA /* PushNotificationMapping.swift */; };
40+
D60472ECAF3C42569988BBE1 /* PushMessagingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0912860F6ED464D95F2D648 /* PushMessagingService.swift */; };
3941
94BC00B678F8511CC23BCA17 /* UserDefaultsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18D627D7628D41EE342DB1B2 /* UserDefaultsStore.swift */; };
4042
963AA368BA2E4A085206768C /* ThemeStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22359AD075B1EFEDD17A8A0C /* ThemeStore.swift */; };
4143
986DAE304B67FC8F8563FC40 /* AuthSessionRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80CBBE2B99B80E70DCD800ED /* AuthSessionRepositoryImpl.swift */; };
@@ -141,6 +143,7 @@
141143
48EFCDACF284D106254C4BF1 /* AuthDataResponse.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AuthDataResponse.swift; path = Sources/DTO/AuthDataResponse.swift; sourceTree = "<group>"; };
142144
4AB6E00A38C37CDBF82B57FD /* DevLogData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = DevLogData.framework; path = DevLogData.framework; sourceTree = BUILT_PRODUCTS_DIR; };
143145
F0A3B72D714B42CDB4E3E905 /* DevLogDataTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DevLogDataTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
146+
8A9508F58EA84409A10F12A8 /* FirebaseAppService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = FirebaseAppService.swift; path = Sources/Protocol/FirebaseAppService.swift; sourceTree = "<group>"; };
144147
550C0805BC3896C8868B6FB2 /* WebPageDTO.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = WebPageDTO.swift; path = Sources/DTO/WebPageDTO.swift; sourceTree = "<group>"; };
145148
60E716EC015A5805DD7C949B /* TodoService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TodoService.swift; path = Sources/Protocol/TodoService.swift; sourceTree = "<group>"; };
146149
6109198D924EFE51F0D884D4 /* PushNotificationResponse.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PushNotificationResponse.swift; path = Sources/DTO/PushNotificationResponse.swift; sourceTree = "<group>"; };
@@ -152,6 +155,7 @@
152155
80CBBE2B99B80E70DCD800ED /* AuthSessionRepositoryImpl.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AuthSessionRepositoryImpl.swift; path = Sources/Repository/AuthSessionRepositoryImpl.swift; sourceTree = "<group>"; };
153156
8B167270C81CB76E8F5ED9CA /* UserDataRepositoryImpl.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = UserDataRepositoryImpl.swift; path = Sources/Repository/UserDataRepositoryImpl.swift; sourceTree = "<group>"; };
154157
914EE1DC0A02968747B6B3A2 /* WebPageImageRepositoryImpl.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = WebPageImageRepositoryImpl.swift; path = Sources/Repository/WebPageImageRepositoryImpl.swift; sourceTree = "<group>"; };
158+
E0912860F6ED464D95F2D648 /* PushMessagingService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PushMessagingService.swift; path = Sources/Protocol/PushMessagingService.swift; sourceTree = "<group>"; };
155159
A7D76A08AAD3B63F20E01668 /* DataLayerError.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DataLayerError.swift; path = Sources/Common/DataLayerError.swift; sourceTree = "<group>"; };
156160
ADE1FE53786D11AC7B192698 /* WebPageService.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = WebPageService.swift; path = Sources/Protocol/WebPageService.swift; sourceTree = "<group>"; };
157161
B1ABB0ED51067433D3C90F02 /* TodoPageResponse.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = TodoPageResponse.swift; path = Sources/DTO/TodoPageResponse.swift; sourceTree = "<group>"; };
@@ -226,7 +230,9 @@
226230
children = (
227231
E7154773B586C2D41307CD49 /* AuthenticationService.swift */,
228232
7559825C27ED42F9F86EBAC1 /* AuthService.swift */,
233+
8A9508F58EA84409A10F12A8 /* FirebaseAppService.swift */,
229234
3B67886F72C946CBC709AFCB /* NWPathConnectivityProvider.swift */,
235+
E0912860F6ED464D95F2D648 /* PushMessagingService.swift */,
230236
2FF70E9CD388C10B69945D7C /* PushNotificationService.swift */,
231237
22359AD075B1EFEDD17A8A0C /* ThemeStore.swift */,
232238
082E30ECD7061C9E401FF2D0 /* TodoCategoryService.swift */,
@@ -490,7 +496,9 @@
490496
B3655250BCDBFAFBFA941F63 /* WebPageMetadataResponse.swift in Sources */,
491497
F515D3BD025E835AFFFAE8F6 /* AuthService.swift in Sources */,
492498
41371B777FE701652CA2E798 /* AuthenticationService.swift in Sources */,
499+
A7084A7C1DE34A0EA3E0E327 /* FirebaseAppService.swift in Sources */,
493500
36A48634DC1A350421118FEB /* NWPathConnectivityProvider.swift in Sources */,
501+
D60472ECAF3C42569988BBE1 /* PushMessagingService.swift in Sources */,
494502
2A057B6B7F6900E50AC2E031 /* PushNotificationService.swift in Sources */,
495503
963AA368BA2E4A085206768C /* ThemeStore.swift in Sources */,
496504
90776FF719A37EAE1CB1BB1B /* TodoCategoryService.swift in Sources */,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// FirebaseAppService.swift
3+
// DevLogData
4+
//
5+
// Created by opfic on 5/15/26.
6+
//
7+
8+
public protocol FirebaseAppService {
9+
func configure()
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// PushMessagingService.swift
3+
// DevLogData
4+
//
5+
// Created by opfic on 5/15/26.
6+
//
7+
8+
import Foundation
9+
10+
public protocol PushMessagingService: AnyObject {
11+
func setDelegate(_ delegate: PushMessagingServiceDelegate?)
12+
func setAPNSToken(_ deviceToken: Data)
13+
}
14+
15+
public protocol PushMessagingServiceDelegate: AnyObject {
16+
func pushMessagingService(_ service: PushMessagingService, didReceiveRegistrationToken fcmToken: String?)
17+
}

0 commit comments

Comments
 (0)