From 7dfc4d751718bb3ab6cdefa6ce73616199a003f4 Mon Sep 17 00:00:00 2001 From: minsik Date: Wed, 15 Nov 2023 18:37:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=99=88=20add=20gitignore=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minsik/mentoring/MentoringWeatherAPI/.gitignore | 2 ++ .../MentoringWeatherAPI/Clima/Model/Secrets.xcconfig | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore create mode 100644 lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore b/lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore new file mode 100644 index 0000000..5bd0ce0 --- /dev/null +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/.gitignore @@ -0,0 +1,2 @@ +*.xcconfig + diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig new file mode 100644 index 0000000..5ef8181 --- /dev/null +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig @@ -0,0 +1,10 @@ +// +// Secrets.xcconfig +// Clima +// +// Created by 조민식 on 11/15/23. +// Copyright © 2023 App Brewery. All rights reserved. +// + +// Configuration settings file format documentation can be found at: +// https://help.apple.com/xcode/#/dev745c5c974 From 959c1a762318223f9c0b9a77e53567cad56f88bf Mon Sep 17 00:00:00 2001 From: minsik Date: Wed, 15 Nov 2023 18:47:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20api=20key=20secret=20c?= =?UTF-8?q?ode=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clima.xcodeproj/project.pbxproj | 3 +++ .../mentoring/MentoringWeatherAPI/Clima/Info.plist | 6 ++++-- .../MentoringWeatherAPI/Clima/Model/Secrets.xcconfig | 10 ---------- .../Clima/Model/WeatherManager.swift | 11 +++++++++-- 4 files changed, 16 insertions(+), 14 deletions(-) delete mode 100644 lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj index c0b0ed1..89c4dbc 100644 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ A45696542A330A480062BD12 /* WeatherManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherManager.swift; sourceTree = ""; }; A4AD65F82A4AD4390039746B /* WeatherData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherData.swift; sourceTree = ""; }; A4AD65FA2A4C21C50039746B /* WeatherModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeatherModel.swift; sourceTree = ""; }; + A4BD8A7C2B04BCF70084308A /* Secrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Secrets.xcconfig; path = Model/Secrets.xcconfig; sourceTree = ""; }; ADAA27AD231BBFAF00365194 /* Clima.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Clima.app; sourceTree = BUILT_PRODUCTS_DIR; }; ADAA27B0231BBFAF00365194 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -79,6 +80,7 @@ ADAA27AF231BBFAF00365194 /* Clima */ = { isa = PBXGroup; children = ( + A4BD8A7C2B04BCF70084308A /* Secrets.xcconfig */, ADAA27B0231BBFAF00365194 /* AppDelegate.swift */, ADAA27B2231BBFAF00365194 /* SceneDelegate.swift */, A45696532A330A2E0062BD12 /* Model */, @@ -330,6 +332,7 @@ }; ADAA27C2231BBFB300365194 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A4BD8A7C2B04BCF70084308A /* Secrets.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist index 761d1d7..f6f6e84 100644 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Info.plist @@ -2,8 +2,8 @@ - NSLocationWhenInUseUsageDescription - We need your location to get the current weather for where you are. + API_KEY + $(API_KEY) CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -22,6 +22,8 @@ 1 LSRequiresIPhoneOS + NSLocationWhenInUseUsageDescription + We need your location to get the current weather for where you are. UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig deleted file mode 100644 index 5ef8181..0000000 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/Secrets.xcconfig +++ /dev/null @@ -1,10 +0,0 @@ -// -// Secrets.xcconfig -// Clima -// -// Created by 조민식 on 11/15/23. -// Copyright © 2023 App Brewery. All rights reserved. -// - -// Configuration settings file format documentation can be found at: -// https://help.apple.com/xcode/#/dev745c5c974 diff --git a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift index 54246d9..818bddf 100644 --- a/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift +++ b/lecture/minsik/mentoring/MentoringWeatherAPI/Clima/Model/WeatherManager.swift @@ -9,13 +9,20 @@ import Foundation import CoreLocation + + protocol WeatherManagerDelegate { func didUpdateWeather(_ weatherManager: Weathermanager, weather: WeatherModel) func didFailWithError(error: Error) } -struct Weathermanager{ - let weatherURL = "https://api.openweathermap.org/data/2.5/weather?appid=ecc3373ffe347304fd4ab1e4bbec05b7&units=metric" +struct Weathermanager { + + private let apikey = Bundle.main.infoDictionary?["API_KEY"] as! String + + var weatherURL: String { + return "https://api.openweathermap.org/data/2.5/weather?units=metric&appid=\(apikey)" + } var delegate: WeatherManagerDelegate?