From e897c33ba13f82781e44abd847d0e6c614dc5433 Mon Sep 17 00:00:00 2001 From: Morteza Date: Sun, 15 Sep 2019 10:34:09 +0430 Subject: [PATCH 1/2] Changed json Parsing to Codable --- SwiftWeather/City.swift | 22 +++++++ SwiftWeather/Cloud.swift | 15 +++++ SwiftWeather/Coord.swift | 16 +++++ SwiftWeather/Info.plist | 62 +++++++++---------- SwiftWeather/List.swift | 21 +++++++ SwiftWeather/Main.swift | 22 +++++++ SwiftWeather/OpenWeatherMapService.swift | 79 ++++++++++++++---------- SwiftWeather/Sy.swift | 15 +++++ SwiftWeather/WeatherResponse.swift | 18 ++++++ SwiftWeather/Wind.swift | 16 +++++ 10 files changed, 221 insertions(+), 65 deletions(-) create mode 100644 SwiftWeather/City.swift create mode 100644 SwiftWeather/Cloud.swift create mode 100644 SwiftWeather/Coord.swift create mode 100644 SwiftWeather/List.swift create mode 100644 SwiftWeather/Main.swift create mode 100644 SwiftWeather/Sy.swift create mode 100644 SwiftWeather/WeatherResponse.swift create mode 100644 SwiftWeather/Wind.swift diff --git a/SwiftWeather/City.swift b/SwiftWeather/City.swift new file mode 100644 index 0000000..5046551 --- /dev/null +++ b/SwiftWeather/City.swift @@ -0,0 +1,22 @@ +// +// City.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct City: Codable{ + + var coord : Coord! + var country : String! + var id : Int! + var name : String! + var population : Int! + var sunrise : Int! + var sunset : Int! + var timezone : Int! + + +} diff --git a/SwiftWeather/Cloud.swift b/SwiftWeather/Cloud.swift new file mode 100644 index 0000000..7f496ad --- /dev/null +++ b/SwiftWeather/Cloud.swift @@ -0,0 +1,15 @@ +// +// Cloud.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct Cloud: Codable{ + + var all : Int! + + +} diff --git a/SwiftWeather/Coord.swift b/SwiftWeather/Coord.swift new file mode 100644 index 0000000..4c08bd2 --- /dev/null +++ b/SwiftWeather/Coord.swift @@ -0,0 +1,16 @@ +// +// Coord.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct Coord: Codable{ + + var lat : Float! + var lon : Float! + + +} diff --git a/SwiftWeather/Info.plist b/SwiftWeather/Info.plist index 5b2d434..fe1ae56 100644 --- a/SwiftWeather/Info.plist +++ b/SwiftWeather/Info.plist @@ -2,17 +2,6 @@ - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - - NSLocationWhenInUseUsageDescription - Location is required to retrieve the weather info for your current place. - UIAppFonts - - weathericons-regular-webfont.ttf - CFBundleDevelopmentRegion en CFBundleExecutable @@ -29,10 +18,41 @@ 3.0 CFBundleSignature ???? + CFBundleURLTypes + + + CFBundleURLSchemes + + fb1725220270856995 + + + CFBundleVersion 1 + FacebookAppID + 1725220270856995 + FacebookDisplayName + Swift Weather + LSApplicationQueriesSchemes + + fbapi + fb-messenger-share-api + fbauth2 + fbshareextension + LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + NSLocationWhenInUseUsageDescription + Location is required to retrieve the weather info for your current place. + UIAppFonts + + weathericons-regular-webfont.ttf + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -54,25 +74,5 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - CFBundleURLTypes - - - CFBundleURLSchemes - - fb1725220270856995 - - - - FacebookAppID - 1725220270856995 - FacebookDisplayName - Swift Weather - LSApplicationQueriesSchemes - - fbapi - fb-messenger-share-api - fbauth2 - fbshareextension - diff --git a/SwiftWeather/List.swift b/SwiftWeather/List.swift new file mode 100644 index 0000000..ddaebd1 --- /dev/null +++ b/SwiftWeather/List.swift @@ -0,0 +1,21 @@ +// +// List.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct List: Codable{ + + var clouds : Cloud! + var dt : Int! + var dtTxt : String! + var main : Main! + var sys : Sy! + var weather : [Weatherr]! + var wind : Wind! + + +} diff --git a/SwiftWeather/Main.swift b/SwiftWeather/Main.swift new file mode 100644 index 0000000..5e59dc4 --- /dev/null +++ b/SwiftWeather/Main.swift @@ -0,0 +1,22 @@ +// +// Main.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct Main: Codable{ + + var grndLevel : Float! + var humidity : Int! + var pressure : Float! + var seaLevel : Float! + var temp : Float! + var tempKf : Int! + var tempMax : Float! + var tempMin : Float! + + +} diff --git a/SwiftWeather/OpenWeatherMapService.swift b/SwiftWeather/OpenWeatherMapService.swift index b8de361..bf1119a 100644 --- a/SwiftWeather/OpenWeatherMapService.swift +++ b/SwiftWeather/OpenWeatherMapService.swift @@ -10,21 +10,20 @@ import SwiftyJSON struct OpenWeatherMapService: WeatherServiceProtocol { fileprivate let urlPath = "http://api.openweathermap.org/data/2.5/forecast" - fileprivate func getFirstFourForecasts(_ json: JSON) -> [Forecast] { + fileprivate func getFirstFourForecasts(_ weather: WeatherResponse) -> [Forecast] { var forecasts: [Forecast] = [] for index in 0...3 { - guard let forecastTempDegrees = json["list"][index]["main"]["temp"].double, - let rawDateTime = json["list"][index]["dt"].double, - let forecastCondition = json["list"][index]["weather"][0]["id"].int, - let forecastIcon = json["list"][index]["weather"][0]["icon"].string else { + guard let forecastTempDegrees = weather.list[index].main.temp, + let rawDateTime = weather.list[index].dt, + let forecastCondition = weather.list[index].weather[0].id, + let forecastIcon = weather.list[index].weather[0].icon else { break } - - let country = json["city"]["country"].string + let country = weather.city.country let forecastTemperature = Temperature(country: country!, - openWeatherMapDegrees: forecastTempDegrees) - let forecastTimeString = ForecastDateTime(date: rawDateTime, timeZone: TimeZone.current).shortTime + openWeatherMapDegrees: Double(forecastTempDegrees)) + let forecastTimeString = ForecastDateTime(date: Double(rawDateTime), timeZone: TimeZone.current).shortTime let weatherIcon = WeatherIcon(condition: forecastCondition, iconString: forecastIcon) let forcastIconText = weatherIcon.iconText @@ -63,34 +62,45 @@ struct OpenWeatherMapService: WeatherServiceProtocol { return } - guard let json = try? JSON(data: data) else { + + // Get temperature, location and icon and check parsing error + + do{ + let decoder = JSONDecoder() + let weather = try decoder.decode(WeatherResponse.self, from: data) + + print(weather) + + guard let tempDegrees = weather.list[0].main.temp, + let country = weather.city.country, + let city = weather.city.name, + let weatherCondition = weather.list[0].weather[0].id, + let iconString = weather.list[0].weather[0].icon else { + let error = SWError(errorCode: .jsonParsingFailed) + completionHandler(nil, error) + return + } + + var weatherBuilder = WeatherBuilder() + let temperature = Temperature(country: country, openWeatherMapDegrees:Double(tempDegrees)) + weatherBuilder.temperature = temperature.degrees + weatherBuilder.location = city + + let weatherIcon = WeatherIcon(condition: weatherCondition, iconString: iconString) + weatherBuilder.iconText = weatherIcon.iconText + + weatherBuilder.forecasts = self.getFirstFourForecasts(weather) + + completionHandler(weatherBuilder.build(), nil) + + }catch let err{ let error = SWError(errorCode: .jsonParsingFailed) completionHandler(nil, error) - return } - // Get temperature, location and icon and check parsing error - guard let tempDegrees = json["list"][0]["main"]["temp"].double, - let country = json["city"]["country"].string, - let city = json["city"]["name"].string, - let weatherCondition = json["list"][0]["weather"][0]["id"].int, - let iconString = json["list"][0]["weather"][0]["icon"].string else { - let error = SWError(errorCode: .jsonParsingFailed) - completionHandler(nil, error) - return - } + - var weatherBuilder = WeatherBuilder() - let temperature = Temperature(country: country, openWeatherMapDegrees:tempDegrees) - weatherBuilder.temperature = temperature.degrees - weatherBuilder.location = city - - let weatherIcon = WeatherIcon(condition: weatherCondition, iconString: iconString) - weatherBuilder.iconText = weatherIcon.iconText - - weatherBuilder.forecasts = self.getFirstFourForecasts(json) - - completionHandler(weatherBuilder.build(), nil) + } task.resume() @@ -104,8 +114,9 @@ struct OpenWeatherMapService: WeatherServiceProtocol { // get appId from Info.plist let filePath = Bundle.main.path(forResource: "Info", ofType: "plist")! let parameters = NSDictionary(contentsOfFile:filePath) - let appId = parameters!["OWMAccessToken"]! as! String - +// let appId = parameters!["OWMAccessToken"]! as! String + let appId = "857f750037379e2c5deff86f861e3211" + let latitude = String(location.coordinate.latitude) let longitude = String(location.coordinate.longitude) diff --git a/SwiftWeather/Sy.swift b/SwiftWeather/Sy.swift new file mode 100644 index 0000000..49d31d8 --- /dev/null +++ b/SwiftWeather/Sy.swift @@ -0,0 +1,15 @@ +// +// Sy.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct Sy: Codable{ + + var pod : String! + + +} diff --git a/SwiftWeather/WeatherResponse.swift b/SwiftWeather/WeatherResponse.swift new file mode 100644 index 0000000..ca011fd --- /dev/null +++ b/SwiftWeather/WeatherResponse.swift @@ -0,0 +1,18 @@ +// +// WeatherResponse.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct WeatherResponse: Codable{ + + var city : City! + var cnt : Int! + var cod : String! + var list : [List]! + var message : Double! + +} diff --git a/SwiftWeather/Wind.swift b/SwiftWeather/Wind.swift new file mode 100644 index 0000000..fa40dc8 --- /dev/null +++ b/SwiftWeather/Wind.swift @@ -0,0 +1,16 @@ +// +// Wind.swift +// +// Create by Morteza Gharedaghi on 14/9/2019 +// Copyright © 2019 Solo. All rights reserved. +// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport + +import Foundation + +struct Wind: Codable{ + + var deg : Float! + var speed : Float! + + +} From d55fd98b16a3aae6c7f0c6139f173680ade5e46f Mon Sep 17 00:00:00 2001 From: Morteza Date: Sun, 15 Sep 2019 10:37:13 +0430 Subject: [PATCH 2/2] Changed Json Parsing To Coddle --- SwiftWeather.xcodeproj/project.pbxproj | 80 +++++++++++++++++------- SwiftWeather/WeatherViewController.swift | 16 ++--- 2 files changed, 66 insertions(+), 30 deletions(-) diff --git a/SwiftWeather.xcodeproj/project.pbxproj b/SwiftWeather.xcodeproj/project.pbxproj index 1913c14..acbbcc4 100644 --- a/SwiftWeather.xcodeproj/project.pbxproj +++ b/SwiftWeather.xcodeproj/project.pbxproj @@ -10,6 +10,15 @@ 1E8FF8444E2C29BD30B867EF /* Pods_Tests_SwiftWeatherUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 418594A8DD8093A647A30E12 /* Pods_Tests_SwiftWeatherUITests.framework */; }; 5120F2EFC3DE077315306794 /* Pods_SwiftWeather.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF971A1BA4A6D64984CB0A75 /* Pods_SwiftWeather.framework */; }; 655E8966C3E09626A8221261 /* Pods_Tests_SwiftWeatherTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 342A91306F3CF92DD999C97D /* Pods_Tests_SwiftWeatherTests.framework */; }; + 8D1F0CD1232E058A00C0B4F0 /* List.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CC8232E058900C0B4F0 /* List.swift */; }; + 8D1F0CD2232E058A00C0B4F0 /* Wind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CC9232E058900C0B4F0 /* Wind.swift */; }; + 8D1F0CD3232E058A00C0B4F0 /* Coord.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CCA232E058900C0B4F0 /* Coord.swift */; }; + 8D1F0CD4232E058A00C0B4F0 /* Cloud.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CCB232E058A00C0B4F0 /* Cloud.swift */; }; + 8D1F0CD5232E058A00C0B4F0 /* Weatherr.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CCC232E058A00C0B4F0 /* Weatherr.swift */; }; + 8D1F0CD6232E058A00C0B4F0 /* WeatherResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CCD232E058A00C0B4F0 /* WeatherResponse.swift */; }; + 8D1F0CD7232E058A00C0B4F0 /* City.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CCE232E058A00C0B4F0 /* City.swift */; }; + 8D1F0CD8232E058A00C0B4F0 /* Sy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CCF232E058A00C0B4F0 /* Sy.swift */; }; + 8D1F0CD9232E058A00C0B4F0 /* Main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F0CD0232E058A00C0B4F0 /* Main.swift */; }; AE09C4301B9723DE00C7CCED /* LocationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE09C42F1B9723DE00C7CCED /* LocationService.swift */; }; AE0DC2CD1B8E7B3900E67147 /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE0DC2CC1B8E7B3900E67147 /* Observable.swift */; }; AE26CCAB1B875C2400D518CB /* ForecastView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AE26CCAA1B875C2400D518CB /* ForecastView.xib */; }; @@ -62,6 +71,15 @@ 342A91306F3CF92DD999C97D /* Pods_Tests_SwiftWeatherTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests_SwiftWeatherTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 418594A8DD8093A647A30E12 /* Pods_Tests_SwiftWeatherUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests_SwiftWeatherUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 53EEE101C82E858E57980710 /* Pods-Tests-SwiftWeatherUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests-SwiftWeatherUITests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Tests-SwiftWeatherUITests/Pods-Tests-SwiftWeatherUITests.release.xcconfig"; sourceTree = ""; }; + 8D1F0CC8232E058900C0B4F0 /* List.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = List.swift; sourceTree = ""; }; + 8D1F0CC9232E058900C0B4F0 /* Wind.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wind.swift; sourceTree = ""; }; + 8D1F0CCA232E058900C0B4F0 /* Coord.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Coord.swift; sourceTree = ""; }; + 8D1F0CCB232E058A00C0B4F0 /* Cloud.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Cloud.swift; sourceTree = ""; }; + 8D1F0CCC232E058A00C0B4F0 /* Weatherr.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Weatherr.swift; path = ../../../../../../Desktop/classes/Weatherr.swift; sourceTree = ""; }; + 8D1F0CCD232E058A00C0B4F0 /* WeatherResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeatherResponse.swift; sourceTree = ""; }; + 8D1F0CCE232E058A00C0B4F0 /* City.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = City.swift; sourceTree = ""; }; + 8D1F0CCF232E058A00C0B4F0 /* Sy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Sy.swift; sourceTree = ""; }; + 8D1F0CD0232E058A00C0B4F0 /* Main.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Main.swift; sourceTree = ""; }; 900AFFBB41C69FC277CB0A33 /* Pods-SwiftWeather.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWeather.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftWeather/Pods-SwiftWeather.debug.xcconfig"; sourceTree = ""; }; 919B9EF9E5898277AD9C772A /* Pods-Tests-SwiftWeatherUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests-SwiftWeatherUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Tests-SwiftWeatherUITests/Pods-Tests-SwiftWeatherUITests.debug.xcconfig"; sourceTree = ""; }; AE09C42F1B9723DE00C7CCED /* LocationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocationService.swift; sourceTree = ""; }; @@ -143,6 +161,22 @@ name = Frameworks; sourceTree = ""; }; + 8D1F0CC7232E057300C0B4F0 /* Codable Models */ = { + isa = PBXGroup; + children = ( + 8D1F0CCE232E058A00C0B4F0 /* City.swift */, + 8D1F0CCB232E058A00C0B4F0 /* Cloud.swift */, + 8D1F0CCA232E058900C0B4F0 /* Coord.swift */, + 8D1F0CC8232E058900C0B4F0 /* List.swift */, + 8D1F0CD0232E058A00C0B4F0 /* Main.swift */, + 8D1F0CCD232E058A00C0B4F0 /* WeatherResponse.swift */, + 8D1F0CCF232E058A00C0B4F0 /* Sy.swift */, + 8D1F0CCC232E058A00C0B4F0 /* Weatherr.swift */, + 8D1F0CC9232E058900C0B4F0 /* Wind.swift */, + ); + name = "Codable Models"; + sourceTree = ""; + }; AE0DC2CB1B8E7ACE00E67147 /* Common */ = { isa = PBXGroup; children = ( @@ -268,6 +302,7 @@ AEF61B2B1BA23C2A00E8F259 /* Models */ = { isa = PBXGroup; children = ( + 8D1F0CC7232E057300C0B4F0 /* Codable Models */, AEBE64421B8D2370004A0814 /* Weather.swift */, AEEDF68C1B9F9B2900C6067B /* Temperature.swift */, EADFFD2F1CAEA22F008357FF /* TemperatureConverter.swift */, @@ -378,7 +413,7 @@ TargetAttributes = { AECBA5E11B836BF20004A536 = { CreatedOnToolsVersion = 7.0; - DevelopmentTeam = 32GB2HU6K5; + DevelopmentTeam = 4WQNG7UP85; LastSwiftMigration = 0900; }; AECBA5F51B836BF20004A536 = { @@ -398,6 +433,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -467,7 +503,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Tests-SwiftWeatherTests/Pods-Tests-SwiftWeatherTests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-Tests-SwiftWeatherTests/Pods-Tests-SwiftWeatherTests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework", "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", ); @@ -478,7 +514,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests-SwiftWeatherTests/Pods-Tests-SwiftWeatherTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Tests-SwiftWeatherTests/Pods-Tests-SwiftWeatherTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 6691608BB84CB91D5EDADE36 /* [CP] Embed Pods Frameworks */ = { @@ -487,26 +523,16 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-SwiftWeather/Pods-SwiftWeather-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Bolts/Bolts.framework", - "${BUILT_PRODUCTS_DIR}/FBSDKCoreKit/FBSDKCoreKit.framework", - "${BUILT_PRODUCTS_DIR}/FBSDKShareKit/FBSDKShareKit.framework", - "${BUILT_PRODUCTS_DIR}/FacebookCore/FacebookCore.framework", - "${BUILT_PRODUCTS_DIR}/FacebookShare/FacebookShare.framework", + "${PODS_ROOT}/Target Support Files/Pods-SwiftWeather/Pods-SwiftWeather-frameworks.sh", "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Bolts.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKCoreKit.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSDKShareKit.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FacebookCore.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FacebookShare.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwiftWeather/Pods-SwiftWeather-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftWeather/Pods-SwiftWeather-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 7E7F83383B6114FE2CC03BD6 /* [CP] Check Pods Manifest.lock */ = { @@ -556,7 +582,8 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "token_file=.access_tokens/openweathermap\ntoken=\"$(cat $token_file)\"\nif [ \"$token\" ]; then\nplutil -replace OWMAccessToken -string $token $TARGET_BUILD_DIR/$INFOPLIST_PATH\nelse\necho 'error: Missing OpenWeatherMap access token'\nopen 'http://openweathermap.org/appid'\necho \"error: Get an access token from , then create a new file at $token_file that contains the access token.\"\nexit 1\nfi"; + shellScript = " +"; }; EC9ED72913B1DE182823A53C /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; @@ -564,7 +591,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Tests-SwiftWeatherUITests/Pods-Tests-SwiftWeatherUITests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-Tests-SwiftWeatherUITests/Pods-Tests-SwiftWeatherUITests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework", "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", ); @@ -575,7 +602,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Tests-SwiftWeatherUITests/Pods-Tests-SwiftWeatherUITests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Tests-SwiftWeatherUITests/Pods-Tests-SwiftWeatherUITests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -586,7 +613,12 @@ buildActionMask = 2147483647; files = ( AE0DC2CD1B8E7B3900E67147 /* Observable.swift in Sources */, + 8D1F0CD3232E058A00C0B4F0 /* Coord.swift in Sources */, + 8D1F0CD2232E058A00C0B4F0 /* Wind.swift in Sources */, + 8D1F0CD8232E058A00C0B4F0 /* Sy.swift in Sources */, + 8D1F0CD9232E058A00C0B4F0 /* Main.swift in Sources */, AE2C7D6C1BA028C000A7A714 /* WeatherIcon.swift in Sources */, + 8D1F0CD4232E058A00C0B4F0 /* Cloud.swift in Sources */, AECBA5E81B836BF20004A536 /* WeatherViewController.swift in Sources */, AEBE643B1B8D1F90004A0814 /* ForecastViewModel.swift in Sources */, AECBA5E61B836BF20004A536 /* AppDelegate.swift in Sources */, @@ -594,14 +626,18 @@ AEEDF6891B9F09E300C6067B /* Error.swift in Sources */, AEEDF68B1B9F99F800C6067B /* WeatherBuilder.swift in Sources */, AEBE64451B8D23B8004A0814 /* WeatherViewModel.swift in Sources */, + 8D1F0CD6232E058A00C0B4F0 /* WeatherResponse.swift in Sources */, AED4B2C21B876E8B0003D765 /* ForecastView.swift in Sources */, + 8D1F0CD7232E058A00C0B4F0 /* City.swift in Sources */, EADFFD301CAEA22F008357FF /* TemperatureConverter.swift in Sources */, + 8D1F0CD5232E058A00C0B4F0 /* Weatherr.swift in Sources */, AE09C4301B9723DE00C7CCED /* LocationService.swift in Sources */, AEBE64431B8D2370004A0814 /* Weather.swift in Sources */, AEBE643E1B8D2108004A0814 /* Forecast.swift in Sources */, CAB56F4267B3BC487990A92D /* OpenWeatherMapService.swift in Sources */, AEEDF68D1B9F9B2900C6067B /* Temperature.swift in Sources */, CAB565DDADB61DF9053BD50F /* WeatherServiceProtocol.swift in Sources */, + 8D1F0CD1232E058A00C0B4F0 /* List.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -768,10 +804,10 @@ baseConfigurationReference = 900AFFBB41C69FC277CB0A33 /* Pods-SwiftWeather.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 32GB2HU6K5; + DEVELOPMENT_TEAM = 4WQNG7UP85; INFOPLIST_FILE = SwiftWeather/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.rushjet.SwiftWeather; + PRODUCT_BUNDLE_IDENTIFIER = "com.rushjet-Morteza.SwiftWeather"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; @@ -783,10 +819,10 @@ baseConfigurationReference = E835C39D4B929F35B6A57B12 /* Pods-SwiftWeather.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 32GB2HU6K5; + DEVELOPMENT_TEAM = 4WQNG7UP85; INFOPLIST_FILE = SwiftWeather/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.rushjet.SwiftWeather; + PRODUCT_BUNDLE_IDENTIFIER = "com.rushjet-Morteza.SwiftWeather"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; diff --git a/SwiftWeather/WeatherViewController.swift b/SwiftWeather/WeatherViewController.swift index 8fa0ba1..0090d0f 100644 --- a/SwiftWeather/WeatherViewController.swift +++ b/SwiftWeather/WeatherViewController.swift @@ -4,7 +4,7 @@ // import UIKit -import FacebookShare +//import FacebookShare import CoreSpotlight import MobileCoreServices @@ -103,13 +103,13 @@ class WeatherViewController: UIViewController { } func shareOnFacebook(){ - let photo = Photo(image: #imageLiteral(resourceName: "background"), userGenerated: false) - let myContent = PhotoShareContent(photos: [photo]) - let shareDialog = ShareDialog(content: myContent) - shareDialog.mode = .native - shareDialog.failsOnInvalidData = true - - try? shareDialog.show() +// let photo = Photo(image: #imageLiteral(resourceName: "background"), userGenerated: false) +// let myContent = PhotoShareContent(photos: [photo]) +// let shareDialog = ShareDialog(content: myContent) +// shareDialog.mode = .native +// shareDialog.failsOnInvalidData = true +// +// try? shareDialog.show() } //MARK: Private Functions