Skip to content

Upgrade to use Xcode 10 #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 2 deletions Podfile → App/Podfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
platform :ios, '10.0'
platform :ios, '12.0'
use_frameworks!

target 'SwiftWeather' do
pod 'SwiftyJSON'
pod 'FacebookShare'
end

abstract_target 'Tests' do
Expand Down
24 changes: 24 additions & 0 deletions App/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PODS:
- Nimble (7.3.1)
- Quick (1.3.2)
- SwiftyJSON (4.2.0)

DEPENDENCIES:
- Nimble
- Quick
- SwiftyJSON

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Nimble
- Quick
- SwiftyJSON

SPEC CHECKSUMS:
Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae
Quick: 2623cb30d7a7f41ca62f684f679586558f483d46
SwiftyJSON: c4bcba26dd9ec7a027fc8eade48e2c911f229e96

PODFILE CHECKSUM: c56e55a868d15e020091a8d96e30e28b9f2b5aed

COCOAPODS: 1.5.3
923 changes: 923 additions & 0 deletions App/SwiftWeather.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
46 changes: 46 additions & 0 deletions App/SwiftWeather/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.swift
// SwiftWeather
//
// Created by Jake Lin on 20/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

16 changes: 16 additions & 0 deletions App/SwiftWeather/Common/AppError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// AppError.swift
// SwiftWeather
//
// Created by Jake Lin on 22/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//

import Foundation

enum AppError: Error {
case urlError
case networkRequestFailed
case jsonParsingFailed
case unableToFindLocation
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//
// Created by Jake Lin on 9/11/15.
// Copyright © 2015 Jake Lin. All rights reserved.
// ForecastDateTime.swift
// SwiftWeather
//
// Created by Jake Lin on 22/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//

import Foundation
Expand Down
38 changes: 38 additions & 0 deletions App/SwiftWeather/Common/LiveData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// LiveData.swift
// SwiftWeather
//
// Created by Jake Lin on 22/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//

import Foundation

/// `LiveData` is a data holder class that can be observed. It is a simplified version of Android Architecture component `LiveData`
class LiveData<T> {
typealias Observer = (T) -> Void
var observer: Observer?
private var value: T

init(_ value: T) {
self.value = value
}

func observe(_ observer: Observer?) {
self.observer = observer
observer?(value)
}

func setValue(value: T) {
self.value = value
self.observer?(value)
}

func postValue(value: T) {
self.value = value

DispatchQueue.main.async(execute: { [unowned self, value] in
self.observer?(value)
})
}
}
33 changes: 3 additions & 30 deletions SwiftWeather/Info.plist → App/SwiftWeather/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required to retrieve the weather info for your current place.</string>
<string></string>
<key>UIAppFonts</key>
<array>
<string>weathericons-regular-webfont.ttf</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -26,9 +21,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand All @@ -54,25 +47,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb1725220270856995</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>1725220270856995</string>
<key>FacebookDisplayName</key>
<string>Swift Weather</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
</dict>
</plist>
15 changes: 15 additions & 0 deletions App/SwiftWeather/Models/Forecast.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Forecast.swift
// SwiftWeather
//
// Created by Jake Lin on 22/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//

import Foundation

struct Forecast {
let time: String
let iconText: String
let temperature: String
}
22 changes: 22 additions & 0 deletions App/SwiftWeather/Models/TemperatureFormatter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Temperature.swift
// SwiftWeather
//
// Created by Jake Lin on 22/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//


import Foundation

struct TemperatureFormatter {
static func format(country: String?, openWeatherMapDegrees: Double) -> String {
guard let country = country else { return "" }

if country == "US" {
return "\(TemperatureConverter.kelvinToFahrenheit(openWeatherMapDegrees))\u{f045}"
} else {
return "\(TemperatureConverter.kelvinToCelsius(openWeatherMapDegrees))\u{f03c}"
}
}
}
16 changes: 16 additions & 0 deletions App/SwiftWeather/Models/Weather.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// File.swift
// SwiftWeather
//
// Created by Jake Lin on 22/10/18.
// Copyright © 2018 Jake Lin. All rights reserved.
//

import Foundation

struct Weather {
let location: String
let iconText: String
let temperature: String
let forecasts: [Forecast]
}
Loading