Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Configuration ###
Configuration/

### Firebase ###
GoogleService-Info*.plist

Expand Down
2 changes: 2 additions & 0 deletions Core/DesignSystem/DesignSystem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
buildSettings = {
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 5DFZR8RCQR;
Expand Down Expand Up @@ -314,6 +315,7 @@
buildSettings = {
ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 5DFZR8RCQR;
Expand Down
21 changes: 21 additions & 0 deletions Mark-In.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
57944D0C2DC52AEF00EF3D9A /* GoogleSignIn in Frameworks */ = {isa = PBXBuildFile; productRef = 57944D0B2DC52AEF00EF3D9A /* GoogleSignIn */; };
57AC56A22DA5120600BA84BD /* DesignSystem.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57AC56A12DA511F800BA84BD /* DesignSystem.framework */; };
57AC56A32DA5120600BA84BD /* DesignSystem.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 57AC56A12DA511F800BA84BD /* DesignSystem.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
57AC56A42DA5120600BA84BD /* LinkMetadataKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57AC567D2DA511F200BA84BD /* LinkMetadataKit.framework */; };
Expand Down Expand Up @@ -103,6 +104,7 @@
buildActionMask = 2147483647;
files = (
57AC56A82DA5120600BA84BD /* Util.framework in Frameworks */,
57944D0C2DC52AEF00EF3D9A /* GoogleSignIn in Frameworks */,
57E1F9852DA8F9B40033F30C /* FirebaseAuth in Frameworks */,
57AC56A62DA5120600BA84BD /* LinkMetadataKitInterface.framework in Frameworks */,
57AC56A42DA5120600BA84BD /* LinkMetadataKit.framework in Frameworks */,
Expand Down Expand Up @@ -211,6 +213,7 @@
57E1F9862DA8F9B40033F30C /* FirebaseCore */,
57E1F9882DA8F9B40033F30C /* FirebaseFirestore */,
57B5F82D2DC08B400061F0DE /* FirebaseStorage */,
57944D0B2DC52AEF00EF3D9A /* GoogleSignIn */,
);
productName = "Mark-In";
productReference = 57BFD8C32DA4E19600648AD4 /* Mark-In.app */;
Expand Down Expand Up @@ -242,6 +245,7 @@
minimizedProjectReferenceProxies = 1;
packageReferences = (
57E1F9832DA8F9B40033F30C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
57944D0A2DC52AEF00EF3D9A /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 57BFD8C42DA4E19600648AD4 /* Products */;
Expand Down Expand Up @@ -321,6 +325,8 @@
/* Begin XCBuildConfiguration section */
57BFD8CD2DA4E19700648AD4 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReferenceAnchor = 57BFD8C52DA4E19600648AD4 /* Mark-In */;
baseConfigurationReferenceRelativePath = Configuration/Debug.xcconfig;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
Expand Down Expand Up @@ -383,6 +389,8 @@
};
57BFD8CE2DA4E19700648AD4 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReferenceAnchor = 57BFD8C52DA4E19600648AD4 /* Mark-In */;
baseConfigurationReferenceRelativePath = Configuration/Release.xcconfig;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
Expand Down Expand Up @@ -541,6 +549,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
57944D0A2DC52AEF00EF3D9A /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/google/GoogleSignIn-iOS";
requirement = {
kind = exactVersion;
version = 7.0.0;
};
};
57E1F9832DA8F9B40033F30C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
Expand All @@ -552,6 +568,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
57944D0B2DC52AEF00EF3D9A /* GoogleSignIn */ = {
isa = XCSwiftPackageProductDependency;
package = 57944D0A2DC52AEF00EF3D9A /* XCRemoteSwiftPackageReference "GoogleSignIn-iOS" */;
productName = GoogleSignIn;
};
57B5F82D2DC08B400061F0DE /* FirebaseStorage */ = {
isa = XCSwiftPackageProductDependency;
package = 57E1F9832DA8F9B40033F30C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion Mark-In/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
<?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/>
<dict>
<key>GIDClientID</key>
<string>$(GID_CLIENT)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>$(URL_SCHEMES)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(URL_SCHEMES)</string>
</array>
</dict>
</array>
</dict>
</plist>
17 changes: 15 additions & 2 deletions Mark-In/Sources/App/Mark_InApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI

import FirebaseCore
import GoogleSignIn

import DesignSystem

Expand All @@ -17,19 +18,23 @@ struct Mark_InApp: App {
init() {
FontLoader.registerFont()

// Self.configureFirebase()
configureFirebase()
configureGoogleSignIn()
}

var body: some Scene {
WindowGroup {
MainView()
.frame(minWidth: 500, minHeight: 500)
.onOpenURL { url in
GIDSignIn.sharedInstance.handle(url)
}
Comment on lines +29 to +31

Choose a reason for hiding this comment

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

2개 이상일 때 체크

}
}
}

extension Mark_InApp {
static func configureFirebase() {
private func configureFirebase() {
#if DEBUG
let resource = "GoogleService-Info-Dev"
#else
Expand All @@ -45,4 +50,12 @@ extension Mark_InApp {

FirebaseApp.configure(options: options)
}

private func configureGoogleSignIn() {
guard let clientID = FirebaseApp.app()?.options.clientID else {
fatalError("No client ID found in Firebase configuration")
}
let config = GIDConfiguration(clientID: clientID)
GIDSignIn.sharedInstance.configuration = config
}
}
1 change: 1 addition & 0 deletions Mark-In/Sources/Feature/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private struct SignInButtonList: View {

SignInButton(provider: .google) {
// TODO: 구글 로그인 로직

Choose a reason for hiding this comment

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

주석 제거 필요

loginViewModel.send(.googleLoginButtonTapped)
}
}
}
Expand Down
41 changes: 36 additions & 5 deletions Mark-In/Sources/Feature/Login/LoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AuthenticationServices
import SwiftUI

import FirebaseAuth
import GoogleSignIn

import Util

Expand All @@ -21,6 +22,7 @@ final class LoginViewModel: Reducer {

enum Action {
case appleLoginButtonTapped(AuthorizationController)
case googleLoginButtonTapped

case signInError(SignInError)

Expand Down Expand Up @@ -48,15 +50,15 @@ final class LoginViewModel: Reducer {
return .run { [nonce = requestProvider.currentNonce] in

/// 중간에 로그인을 취소하거나, 애플 로그인 인증 방식이 아닌 경우는 빈 액션 반환
/// (에러 상황은 아니고, 어떠한 액션을 던질 필요가 없음)
/// (에러 상황은 아니기 때문에 어떠한 액션을 던질 필요가 없음)
guard let result = try? await authController.performRequest(request),
case let .appleID(idCredential) = result else { return .empty }

/// 애플 로그인 정보에 필요한 정보들이 누락되는 경우
guard let nonce,
let appleIDToken = idCredential.identityToken,
let idTokenString = String(data: appleIDToken, encoding: .utf8) else {
return .signInError(.invalid)
return .signInError(.missingData)
}

/// Firebase 인증 요청을 위한 AuthCredential 생성
Expand All @@ -69,11 +71,39 @@ final class LoginViewModel: Reducer {
return .firebaseAuthRequest(credential)
}

// TODO: 에러 처리 필요
case .googleLoginButtonTapped:

Choose a reason for hiding this comment

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

메서드 분리하면 좋을 것 같아요

guard let windowScene = NSApplication.shared.windows.first else {
return .none
}

return .run {
do {
/// 구글 로그인 요청
let result = try await GIDSignIn.sharedInstance.signIn(withPresenting: windowScene)

/// 로그인에 필요한 정보(IDToken)가 누락된 경우
guard let idToken = result.user.idToken?.tokenString else {
return .signInError(.missingData)
}

/// Firebase 인증 요청을 위한 AuthCredential 생성
let credential = GoogleAuthProvider.credential(
withIDToken: idToken,
accessToken: result.user.accessToken.tokenString
)

return .firebaseAuthRequest(credential)
} catch {
return .signInError(.invalid)
}
}

// TODO: 에러 처리 필요
case .signInError(_):
return .none

// TODO: 현재는 러프하고 구현된 상태. 구글 로그인까지 구현 후 디테일 수정
// TODO: 구글 로그인까지 구현 후 디테일 수정
case .firebaseAuthRequest(let credential):
return .run {
do {
Expand Down Expand Up @@ -109,14 +139,15 @@ final class LoginViewModel: Reducer {
case .run(let action):
Task {
let newAction = await action()
send(newAction)
await send(newAction)
}
}
}
}

extension LoginViewModel {
enum SignInError: Error {
case missingData
case invalid
}
}
Loading