From c1e3491091021d516f1d46934271a668dd8cda67 Mon Sep 17 00:00:00 2001 From: 00yhsp <00yhsp@naver.com> Date: Wed, 15 Nov 2023 13:48:35 +0900 Subject: [PATCH] week5 mission --- iOS_Study_A.xcodeproj/project.pbxproj | 162 +++++++++- iOS_Study_A/AppDelegate.swift | 4 + .../Contents.json | 21 ++ .../kakao_login_medium_narrow.png | Bin 0 -> 2946 bytes iOS_Study_A/Base.lproj/Main.storyboard | 24 -- iOS_Study_A/Info.plist | 2 - iOS_Study_A/SceneDelegate.swift | 28 +- iOS_Study_A/SecondViewController.swift | 59 ++++ iOS_Study_A/ViewController.swift | 287 +++++++++++++++++- 9 files changed, 541 insertions(+), 46 deletions(-) create mode 100644 iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/Contents.json create mode 100644 iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/kakao_login_medium_narrow.png delete mode 100644 iOS_Study_A/Base.lproj/Main.storyboard create mode 100644 iOS_Study_A/SecondViewController.swift diff --git a/iOS_Study_A.xcodeproj/project.pbxproj b/iOS_Study_A.xcodeproj/project.pbxproj index 1f5c336..e9f92ca 100644 --- a/iOS_Study_A.xcodeproj/project.pbxproj +++ b/iOS_Study_A.xcodeproj/project.pbxproj @@ -10,9 +10,21 @@ 954B6B612AC57BE100FDCFAB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954B6B602AC57BE100FDCFAB /* AppDelegate.swift */; }; 954B6B632AC57BE100FDCFAB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954B6B622AC57BE100FDCFAB /* SceneDelegate.swift */; }; 954B6B652AC57BE100FDCFAB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 954B6B642AC57BE100FDCFAB /* ViewController.swift */; }; - 954B6B682AC57BE100FDCFAB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B662AC57BE100FDCFAB /* Main.storyboard */; }; 954B6B6A2AC57BE200FDCFAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B692AC57BE200FDCFAB /* Assets.xcassets */; }; 954B6B6D2AC57BE200FDCFAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 954B6B6B2AC57BE200FDCFAB /* LaunchScreen.storyboard */; }; + DFB412F62B00F23100DA60B7 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = DFB412F52B00F23100DA60B7 /* SnapKit */; }; + DFB412F92B032BB900DA60B7 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = DFB412F82B032BB900DA60B7 /* Alamofire */; }; + DFB412FC2B03803100DA60B7 /* CombineMoya in Frameworks */ = {isa = PBXBuildFile; productRef = DFB412FB2B03803100DA60B7 /* CombineMoya */; }; + DFB412FE2B03803100DA60B7 /* Moya in Frameworks */ = {isa = PBXBuildFile; productRef = DFB412FD2B03803100DA60B7 /* Moya */; }; + DFB413002B03803100DA60B7 /* ReactiveMoya in Frameworks */ = {isa = PBXBuildFile; productRef = DFB412FF2B03803100DA60B7 /* ReactiveMoya */; }; + DFB413022B03803100DA60B7 /* RxMoya in Frameworks */ = {isa = PBXBuildFile; productRef = DFB413012B03803100DA60B7 /* RxMoya */; }; + DFB413052B0460E400DA60B7 /* KakaoSDK in Frameworks */ = {isa = PBXBuildFile; productRef = DFB413042B0460E400DA60B7 /* KakaoSDK */; }; + DFB413072B0460E400DA60B7 /* KakaoSDKAuth in Frameworks */ = {isa = PBXBuildFile; productRef = DFB413062B0460E400DA60B7 /* KakaoSDKAuth */; }; + DFB413092B0460E400DA60B7 /* KakaoSDKCert in Frameworks */ = {isa = PBXBuildFile; productRef = DFB413082B0460E400DA60B7 /* KakaoSDKCert */; }; + DFB4130B2B0460E400DA60B7 /* KakaoSDKCertCore in Frameworks */ = {isa = PBXBuildFile; productRef = DFB4130A2B0460E400DA60B7 /* KakaoSDKCertCore */; }; + DFB4130D2B0460E400DA60B7 /* KakaoSDKCommon in Frameworks */ = {isa = PBXBuildFile; productRef = DFB4130C2B0460E400DA60B7 /* KakaoSDKCommon */; }; + DFB4130F2B0460E400DA60B7 /* KakaoSDKUser in Frameworks */ = {isa = PBXBuildFile; productRef = DFB4130E2B0460E400DA60B7 /* KakaoSDKUser */; }; + DFB413112B0472B400DA60B7 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DFB413102B0472B400DA60B7 /* SecondViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -20,10 +32,10 @@ 954B6B602AC57BE100FDCFAB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 954B6B622AC57BE100FDCFAB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 954B6B642AC57BE100FDCFAB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; - 954B6B672AC57BE100FDCFAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 954B6B692AC57BE200FDCFAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 954B6B6C2AC57BE200FDCFAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 954B6B6E2AC57BE200FDCFAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DFB413102B0472B400DA60B7 /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -31,6 +43,18 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DFB413092B0460E400DA60B7 /* KakaoSDKCert in Frameworks */, + DFB4130D2B0460E400DA60B7 /* KakaoSDKCommon in Frameworks */, + DFB413022B03803100DA60B7 /* RxMoya in Frameworks */, + DFB4130B2B0460E400DA60B7 /* KakaoSDKCertCore in Frameworks */, + DFB412F62B00F23100DA60B7 /* SnapKit in Frameworks */, + DFB412F92B032BB900DA60B7 /* Alamofire in Frameworks */, + DFB412FE2B03803100DA60B7 /* Moya in Frameworks */, + DFB413002B03803100DA60B7 /* ReactiveMoya in Frameworks */, + DFB4130F2B0460E400DA60B7 /* KakaoSDKUser in Frameworks */, + DFB412FC2B03803100DA60B7 /* CombineMoya in Frameworks */, + DFB413052B0460E400DA60B7 /* KakaoSDK in Frameworks */, + DFB413072B0460E400DA60B7 /* KakaoSDKAuth in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -59,7 +83,7 @@ 954B6B602AC57BE100FDCFAB /* AppDelegate.swift */, 954B6B622AC57BE100FDCFAB /* SceneDelegate.swift */, 954B6B642AC57BE100FDCFAB /* ViewController.swift */, - 954B6B662AC57BE100FDCFAB /* Main.storyboard */, + DFB413102B0472B400DA60B7 /* SecondViewController.swift */, 954B6B692AC57BE200FDCFAB /* Assets.xcassets */, 954B6B6B2AC57BE200FDCFAB /* LaunchScreen.storyboard */, 954B6B6E2AC57BE200FDCFAB /* Info.plist */, @@ -83,6 +107,20 @@ dependencies = ( ); name = iOS_Study_A; + packageProductDependencies = ( + DFB412F52B00F23100DA60B7 /* SnapKit */, + DFB412F82B032BB900DA60B7 /* Alamofire */, + DFB412FB2B03803100DA60B7 /* CombineMoya */, + DFB412FD2B03803100DA60B7 /* Moya */, + DFB412FF2B03803100DA60B7 /* ReactiveMoya */, + DFB413012B03803100DA60B7 /* RxMoya */, + DFB413042B0460E400DA60B7 /* KakaoSDK */, + DFB413062B0460E400DA60B7 /* KakaoSDKAuth */, + DFB413082B0460E400DA60B7 /* KakaoSDKCert */, + DFB4130A2B0460E400DA60B7 /* KakaoSDKCertCore */, + DFB4130C2B0460E400DA60B7 /* KakaoSDKCommon */, + DFB4130E2B0460E400DA60B7 /* KakaoSDKUser */, + ); productName = iOS_Study_A; productReference = 954B6B5D2AC57BE100FDCFAB /* iOS_Study_A.app */; productType = "com.apple.product-type.application"; @@ -111,6 +149,12 @@ Base, ); mainGroup = 954B6B542AC57BE100FDCFAB; + packageReferences = ( + DFB412F42B00F23100DA60B7 /* XCRemoteSwiftPackageReference "SnapKit" */, + DFB412F72B032BB900DA60B7 /* XCRemoteSwiftPackageReference "Alamofire" */, + DFB412FA2B03803000DA60B7 /* XCRemoteSwiftPackageReference "Moya" */, + DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */, + ); productRefGroup = 954B6B5E2AC57BE100FDCFAB /* Products */; projectDirPath = ""; projectRoot = ""; @@ -127,7 +171,6 @@ files = ( 954B6B6D2AC57BE200FDCFAB /* LaunchScreen.storyboard in Resources */, 954B6B6A2AC57BE200FDCFAB /* Assets.xcassets in Resources */, - 954B6B682AC57BE100FDCFAB /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -138,6 +181,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + DFB413112B0472B400DA60B7 /* SecondViewController.swift in Sources */, 954B6B652AC57BE100FDCFAB /* ViewController.swift in Sources */, 954B6B612AC57BE100FDCFAB /* AppDelegate.swift in Sources */, 954B6B632AC57BE100FDCFAB /* SceneDelegate.swift in Sources */, @@ -147,14 +191,6 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 954B6B662AC57BE100FDCFAB /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 954B6B672AC57BE100FDCFAB /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; 954B6B6B2AC57BE200FDCFAB /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -285,13 +321,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iOS_Study_A/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -312,13 +348,13 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iOS_Study_A/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -356,6 +392,104 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + DFB412F42B00F23100DA60B7 /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; + DFB412F72B032BB900DA60B7 /* XCRemoteSwiftPackageReference "Alamofire" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Alamofire/Alamofire.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; + DFB412FA2B03803000DA60B7 /* XCRemoteSwiftPackageReference "Moya" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Moya/Moya.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 15.0.0; + }; + }; + DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/kakao/kakao-ios-sdk"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + DFB412F52B00F23100DA60B7 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = DFB412F42B00F23100DA60B7 /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; + DFB412F82B032BB900DA60B7 /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = DFB412F72B032BB900DA60B7 /* XCRemoteSwiftPackageReference "Alamofire" */; + productName = Alamofire; + }; + DFB412FB2B03803100DA60B7 /* CombineMoya */ = { + isa = XCSwiftPackageProductDependency; + package = DFB412FA2B03803000DA60B7 /* XCRemoteSwiftPackageReference "Moya" */; + productName = CombineMoya; + }; + DFB412FD2B03803100DA60B7 /* Moya */ = { + isa = XCSwiftPackageProductDependency; + package = DFB412FA2B03803000DA60B7 /* XCRemoteSwiftPackageReference "Moya" */; + productName = Moya; + }; + DFB412FF2B03803100DA60B7 /* ReactiveMoya */ = { + isa = XCSwiftPackageProductDependency; + package = DFB412FA2B03803000DA60B7 /* XCRemoteSwiftPackageReference "Moya" */; + productName = ReactiveMoya; + }; + DFB413012B03803100DA60B7 /* RxMoya */ = { + isa = XCSwiftPackageProductDependency; + package = DFB412FA2B03803000DA60B7 /* XCRemoteSwiftPackageReference "Moya" */; + productName = RxMoya; + }; + DFB413042B0460E400DA60B7 /* KakaoSDK */ = { + isa = XCSwiftPackageProductDependency; + package = DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */; + productName = KakaoSDK; + }; + DFB413062B0460E400DA60B7 /* KakaoSDKAuth */ = { + isa = XCSwiftPackageProductDependency; + package = DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */; + productName = KakaoSDKAuth; + }; + DFB413082B0460E400DA60B7 /* KakaoSDKCert */ = { + isa = XCSwiftPackageProductDependency; + package = DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */; + productName = KakaoSDKCert; + }; + DFB4130A2B0460E400DA60B7 /* KakaoSDKCertCore */ = { + isa = XCSwiftPackageProductDependency; + package = DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */; + productName = KakaoSDKCertCore; + }; + DFB4130C2B0460E400DA60B7 /* KakaoSDKCommon */ = { + isa = XCSwiftPackageProductDependency; + package = DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */; + productName = KakaoSDKCommon; + }; + DFB4130E2B0460E400DA60B7 /* KakaoSDKUser */ = { + isa = XCSwiftPackageProductDependency; + package = DFB413032B0460E400DA60B7 /* XCRemoteSwiftPackageReference "kakao-ios-sdk" */; + productName = KakaoSDKUser; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 954B6B552AC57BE100FDCFAB /* Project object */; } diff --git a/iOS_Study_A/AppDelegate.swift b/iOS_Study_A/AppDelegate.swift index a37563b..71f9c47 100644 --- a/iOS_Study_A/AppDelegate.swift +++ b/iOS_Study_A/AppDelegate.swift @@ -6,6 +6,9 @@ // import UIKit +import KakaoSDKCommon +import KakaoSDKAuth +import KakaoSDKUser @main class AppDelegate: UIResponder, UIApplicationDelegate { @@ -14,6 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. + //KakaoSDK.initSDK(appKey: "6991dad04e23fc94a5f6375804b13ae0") return true } diff --git a/iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/Contents.json b/iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/Contents.json new file mode 100644 index 0000000..8f851ed --- /dev/null +++ b/iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "kakao_login_medium_narrow.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/kakao_login_medium_narrow.png b/iOS_Study_A/Assets.xcassets/kakao_login_medium_narrow.imageset/kakao_login_medium_narrow.png new file mode 100644 index 0000000000000000000000000000000000000000..09bb358843a08576d0029ff8427120c9f5f5c36d GIT binary patch literal 2946 zcmV-|3w`v7P)Px=JV``BRCodHT?=$n#Tou~^I8JtArcY-;n7xG;YdSyzvLw#RsjQ?LV-plh_pbV z7&Y>!6{SGyQ7PIA1q-OyLJ?6xkSGWUhC(S+KzRr@5E4Up1d{9~+0K7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S#rQKkP0Y9hm;GtnB@I)L>T5HObW{%{J+& z-nPV?w;{*6m77doSFQt2pVR+(>8ZdYWA*dvItYv2%TiX%(B^O}BDK zv1=>4*=@458-ORDXaA!l#M^bh&jTio=J3{k{2{wxmbWMoZP^HV^3x*e3W}!`gZoyh z%JuNf`}I}OL*WQ>+1qnOGwj(|0y6S{@wcv}glFG8Pb2X9zm($hf6L1Z^7MA}L=2Y9 zaq&j6FQ=a{FLPSL?t)mvuzLpGJGs+4@w?eq*bKnD)OEG1E{$nvv!T)$W-~vEt)G2) zwj&pQEt&&eGl8)qz^2Qa55<}djhVYahu28WC8LkS2{V#$X0J=>L*?1>u}$*g&D*57 z{5rdm`9%y3y4u*=Q|~OznE5VR7CS#etkBt=aO1D0lvDVEi<;1HzUWf1D4=W1!i9aF^GY za=X|2O6%eA)y~Z9PV7be0)}6*3A0LPTJe swC^J>2!{xpAaAe;Fon)X-38(Q1DqPh - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iOS_Study_A/Info.plist b/iOS_Study_A/Info.plist index dd3c9af..0eb786d 100644 --- a/iOS_Study_A/Info.plist +++ b/iOS_Study_A/Info.plist @@ -15,8 +15,6 @@ Default Configuration UISceneDelegateClassName $(PRODUCT_MODULE_NAME).SceneDelegate - UISceneStoryboardFile - Main diff --git a/iOS_Study_A/SceneDelegate.swift b/iOS_Study_A/SceneDelegate.swift index aaf78de..1941d76 100644 --- a/iOS_Study_A/SceneDelegate.swift +++ b/iOS_Study_A/SceneDelegate.swift @@ -6,17 +6,41 @@ // import UIKit +import KakaoSDKCommon +import KakaoSDKAuth +import KakaoSDKUser class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions){ + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). - guard let _ = (scene as? UIWindowScene) else { return } + + guard let windowScene = (scene as? UIWindowScene) else { return } + window = UIWindow(windowScene: windowScene) // SceneDelegate의 프로퍼티에 설정해줌 + let mainViewController = ViewController() // 맨 처음 보여줄 ViewController + KakaoSDK.initSDK(appKey: "6991dad04e23fc94a5f6375804b13ae0") + window?.rootViewController = mainViewController + window?.makeKeyAndVisible() + /*if let url = URLContexts.first?.url { + if (AuthApi.isKakaoTalkLoginUrl(url)) { + _ = AuthController.handleOpenUrl(url: url) + } + }*/ + } + + func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { + if let url = URLContexts.first?.url { + if (AuthApi.isKakaoTalkLoginUrl(url)) { + + _ = AuthController.handleOpenUrl(url: url) + } + } } func sceneDidDisconnect(_ scene: UIScene) { diff --git a/iOS_Study_A/SecondViewController.swift b/iOS_Study_A/SecondViewController.swift new file mode 100644 index 0000000..e40a57b --- /dev/null +++ b/iOS_Study_A/SecondViewController.swift @@ -0,0 +1,59 @@ +// +// SecondViewController.swift +// iOS_Study_A +// +// Created by 박현수 on 2023/11/15. +// + +import UIKit +import SnapKit +import Alamofire +import KakaoSDKAuth +import KakaoSDKUser +import KakaoSDKCommon + +class SecondViewController: UIViewController { + + @objc func logOutButtonTapped() { + UserApi.shared.logout {(error) in + if let error = error { + print(error) + } + else { + print("logout() success.") + self.dismiss(animated: true, completion: nil) + } + } + } + + let logOutButton: UIButton = { + let button = UIButton() + button.setTitle("로그아웃", for: .normal) + button.backgroundColor = .systemBlue + button.layer.cornerRadius = 10 + return button + }() + + override func viewDidLoad() { + super.viewDidLoad() + view.addSubview(logOutButton) + logOutButton.snp.makeConstraints { make in + make.center.equalToSuperview() + make.width.height.equalTo(200) + } + logOutButton.addTarget(self, action: #selector(logOutButtonTapped), for: .touchUpInside) + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/iOS_Study_A/ViewController.swift b/iOS_Study_A/ViewController.swift index 0804a27..7c4a149 100644 --- a/iOS_Study_A/ViewController.swift +++ b/iOS_Study_A/ViewController.swift @@ -6,14 +6,293 @@ // import UIKit +import SnapKit +import Alamofire +import KakaoSDKAuth +import KakaoSDKUser +import KakaoSDKCommon class ViewController: UIViewController { - + + + let seoulUrl = "https://api.openweathermap.org/data/2.5/weather?appid=46bf119912a3aaa443360e604dfcaf40&units=metric&q=seoul&lang=kr" + let busanUrl = "https://api.openweathermap.org/data/2.5/weather?appid=46bf119912a3aaa443360e604dfcaf40&units=metric&q=busan&lang=kr" + let jejuUrl = "https://api.openweathermap.org/data/2.5/weather?appid=46bf119912a3aaa443360e604dfcaf40&units=metric&q=jeju&lang=kr" + + let apiKey = "46bf119912a3aaa443360e604dfcaf40" + + let seoul: UIView = { + let view = UIView() + view.backgroundColor = .systemGray4 + view.layer.cornerRadius = 10 + return view + }() + let seoulLabel: UILabel = { + let label = UILabel() + label.backgroundColor = .white + label.layer.cornerRadius = 5 + label.layer.masksToBounds = true + return label + }() + let seoulTemp: UILabel = { + let label = UILabel() + label.backgroundColor = .clear + return label + }() + let seoulDescription: UILabel = { + let label = UILabel() + label.backgroundColor = .clear + return label + }() + + let busan: UIView = { + let view = UIView() + view.backgroundColor = .systemGray4 + view.layer.cornerRadius = 10 + return view + }() + let busanLabel: UILabel = { + let label = UILabel() + label.backgroundColor = .systemBlue + label.layer.cornerRadius = 5 + label.layer.masksToBounds = true + return label + }() + let busanTemp: UILabel = { + let label = UILabel() + label.backgroundColor = .clear + return label + }() + let busanDescription: UILabel = { + let label = UILabel() + label.backgroundColor = .clear + return label + }() + + let jeju: UIView = { + let view = UIView() + view.backgroundColor = .systemGray4 + view.layer.cornerRadius = 10 + return view + }() + let jejuLabel: UILabel = { + let label = UILabel() + label.backgroundColor = .orange + label.layer.cornerRadius = 5 + label.layer.masksToBounds = true + return label + }() + let jejuTemp: UILabel = { + let label = UILabel() + label.backgroundColor = .clear + return label + }() + let jejuDescription: UILabel = { + let label = UILabel() + label.backgroundColor = .clear + return label + }() + + let kakaoLoginButton: UIButton = { + let button = UIButton() + button.setImage(UIImage(named: "kakao_login_medium_narrow"), for: .normal) + return button + }() + + @objc func signInButtonTapped() { + UserApi.shared.loginWithKakaoAccount {(oauthtoken, error) in + if let error = error { + print(error) + } + else { + print("loginWithKakaoAccount() success.") + let secondViewController = SecondViewController() + secondViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen + self.present(secondViewController, animated: true, completion: nil) + _ = oauthtoken + } + } + } + + func configureSubviews() { + view.addSubview(seoul) + seoul.addSubview(seoulLabel) + seoul.addSubview(seoulDescription) + seoul.addSubview(seoulTemp) + view.addSubview(busan) + busan.addSubview(busanLabel) + busan.addSubview(busanDescription) + busan.addSubview(busanTemp) + view.addSubview(jeju) + jeju.addSubview(jejuLabel) + jeju.addSubview(jejuDescription) + jeju.addSubview(jejuTemp) + view.addSubview(kakaoLoginButton) + kakaoLoginButton.addTarget(self, action: #selector(signInButtonTapped), for: .touchUpInside) + } + + func makeConstraints() { + seoul.snp.makeConstraints { make in + make.width.equalTo(300) + make.height.equalTo(200) + make.centerX.equalToSuperview() + make.top.equalToSuperview().offset(80) + } + seoulLabel.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalToSuperview().offset(10) + } + seoulDescription.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalTo(seoulLabel.snp.bottom).offset(10) + } + seoulTemp.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalTo(seoulDescription.snp.bottom).offset(10) + } + + busan.snp.makeConstraints { make in + make.width.equalTo(300) + make.height.equalTo(200) + make.centerX.equalToSuperview() + make.top.equalTo(seoul.snp.bottom).offset(30) + } + busanLabel.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalToSuperview().offset(10) + } + busanDescription.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalTo(busanLabel.snp.bottom).offset(10) + } + busanTemp.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalTo(busanDescription.snp.bottom).offset(10) + } + + jeju.snp.makeConstraints { make in + make.width.equalTo(300) + make.height.equalTo(200) + make.centerX.equalToSuperview() + make.top.equalTo(busan.snp.bottom).offset(30) + } + jejuLabel.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalToSuperview().offset(10) + } + jejuDescription.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalTo(jejuLabel.snp.bottom).offset(10) + } + jejuTemp.snp.makeConstraints { make in + make.width.equalTo(180) + make.height.equalTo(40) + make.left.equalToSuperview().offset(10) + make.top.equalTo(jejuDescription.snp.bottom).offset(10) + } + kakaoLoginButton.snp.makeConstraints { make in + make.width.equalTo(183) + make.height.equalTo(45) + make.centerX.equalToSuperview() + make.bottom.equalToSuperview().offset(-30) + } + } + override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. - } - + view.backgroundColor = .white + + configureSubviews() + makeConstraints() + + AF.request(seoulUrl, + method: .get, + parameters: nil, + encoding: URLEncoding.default) + .responseJSON { response in + switch response.result { + case .success(let data): + let dictData = data as! [String: Any] + let name = dictData["name"] as! String + let mainData = dictData["main"] as! [String: Any] + let tempData = mainData["temp"] as! NSNumber + let temp = tempData.floatValue + let weatherData = dictData["weather"] as! [[String: Any]] + let innerData = weatherData.first + let description = innerData?["description"] as! String + self.seoulLabel.text = "도시 : \(name)" + self.seoulDescription.text = "기상 : \(description)" + self.seoulTemp.text = "기온 : \(String(temp))" + case .failure(let error): + print("\(error)") + } + } + + + + AF.request(busanUrl, + method: .get, + parameters: nil, + encoding: URLEncoding.default) + .responseJSON { response in + switch response.result { + case .success(let data): + let dictData = data as! [String: Any] + let name = dictData["name"] as! String + let mainData = dictData["main"] as! [String: Any] + let tempData = mainData["temp"] as! NSNumber + let temp = tempData.floatValue + let weatherData = dictData["weather"] as! [[String: Any]] + let innerData = weatherData.first + let description = innerData?["description"] as! String + + self.busanLabel.text = "도시 : \(name)" + self.busanDescription.text = "기상 : \(description)" + self.busanTemp.text = "기온 : \(String(temp))" + case .failure(let error): + print("\(error)") + } + } + + AF.request(jejuUrl, + method: .get, + parameters: nil, + encoding: URLEncoding.default) + .responseJSON { response in + switch response.result { + case .success(let data): + let dictData = data as! [String: Any] + let name = dictData["name"] as! String + let mainData = dictData["main"] as! [String: Any] + let tempData = mainData["temp"] as! NSNumber + let temp = tempData.floatValue + let weatherData = dictData["weather"] as! [[String: Any]] + let innerData = weatherData.first + let description = innerData?["description"] as! String + self.jejuLabel.text = "도시 : \(name)" + self.jejuDescription.text = "기상 : \(description)" + self.jejuTemp.text = "기온 : \(String(temp))" + case .failure(let error): + print("\(error)") + } + } + } }