Skip to content

Commit

Permalink
Merge pull request #158 from DJBen/swift-4.1
Browse files Browse the repository at this point in the history
Bump to Xcode 9.3 and Swift 4.1
  • Loading branch information
DJBen authored Apr 10, 2018
2 parents c9bf03c + 9383453 commit 8058fdc
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ excluded:
- Carthage
- Pods
- OrbitsTests
- StarryNightTests
- SpaceTimeTests
- YinYang
- YinYangTests
identifier_name:
min_length: 1
force_try:
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
language: objective-c
osx_image: xcode9.2
osx_image: xcode9.3

cache:
directories:
- Carthage
before_install:
- brew update
- travis_wait 40 carthage bootstrap --platform iOS --cache-builds
before_script:
- swiftlint
script:
- xcodebuild -scheme Graviton -project Graviton.xcodeproj -sdk iphonesimulator11.2 -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.2' build test
- xcodebuild -scheme Graviton -project Graviton.xcodeproj -sdk iphonesimulator11.3 -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.3' build test
6 changes: 5 additions & 1 deletion Graviton.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Ben Lu";
TargetAttributes = {
EF4BD3801E57E58D009D2698 = {
Expand Down Expand Up @@ -1893,13 +1893,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -1950,13 +1952,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
4 changes: 1 addition & 3 deletions Graviton.xcodeproj/xcshareddata/xcschemes/Graviton.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -76,7 +75,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Graviton/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

private func displaySceneKitBrokenWarning() {
let forumUrl = URL(string:"https://forums.developer.apple.com/thread/92671")!
let forumUrl = URL(string: "https://forums.developer.apple.com/thread/92671")!
guard Device.isSceneKitBroken && UIApplication.shared.canOpenURL(forumUrl) && OccationalPrompt.shouldShowPrompt(forKey: "sceneKitBrokenWarning", timeInterval: 86400) else {
return
}
Expand Down
2 changes: 1 addition & 1 deletion Graviton/Information/Models/ObserverInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct ObserverInfo {

extension RiseTransitSetElevation {
var tableRows: [String] {
return zip(["Rises at ", "Transits at ", "Sets at "], [riseAt, transitAt, setAt]).flatMap { (str, julianDay) -> String? in
return zip(["Rises at ", "Transits at ", "Sets at "], [riseAt, transitAt, setAt]).compactMap { (str, julianDay) -> String? in
if julianDay == nil { return nil }
dateFormatter.timeZone = LocationManager.default.timeZone
return str + dateFormatter.string(from: julianDay!.date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ extension ObserveTarget {

extension Star.Identity {
func contentAtRow(_ row: Int) -> (String, String) {
return zip(["Proper Name", "Bayer-Flamsteed", "Gliese catalog", "Harvard Revised", "Henry Draper", "Hipparcos catalog"], [properName, bayerFlamsteedDesignation, gl, stringify(hrId), stringify(hdId), stringify(hipId)])
let titles: [String] = ["Proper Name", "Bayer-Flamsteed", "Gliese catalog", "Harvard Revised", "Henry Draper", "Hipparcos catalog"]
let properties: [String?] = [properName, bayerFlamsteedDesignation, gl, stringify(hrId), stringify(hdId), stringify(hipId)]
return (zip(titles, properties)
.filter { $1 != nil }
.map { ($0, $1!) }[row]
.map { ($0, $1!) })[row]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protocol ObserverLocationMenuControllerDelegate: NSObjectProtocol {
class ObserverLocationMenuController: ObserverTableViewController, UISearchControllerDelegate, UISearchResultsUpdating, UISearchBarDelegate {

lazy var searchController: UISearchController = {
let searchController = UISearchController(searchResultsController: nil)
let searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.delegate = self
searchController.searchBar.delegate = self
Expand Down
2 changes: 1 addition & 1 deletion Orbits/Models/Naif.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum Naif: Comparable, Hashable, ExpressibleByIntegerLiteral, CustomStrin
case pluto = 999

public var moons: [Moon] {
return (1...98).flatMap { Moon(rawValue: $0) }
return (1...98).compactMap { Moon(rawValue: $0) }
}
}

Expand Down
10 changes: 5 additions & 5 deletions Orbits/Networking/Horizons/Horizons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public class Horizons {
}
}

let operations = queries.flatMap { (query) -> BlockOperation? in
let operations = queries.compactMap { (query) -> BlockOperation? in
if query.command == Sun.sol.naifId {
return nil
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public class Horizons {
logger.verbose("reponse has no data: \(String(describing: response))")
}
}
let tasks = queries.flatMap { (query) -> URLSessionTask? in
let tasks = queries.compactMap { (query) -> URLSessionTask? in
return URLSession.shared.dataTask(with: query.url, completionHandler: taskComplete)
}
tasks.enumerated().forEach { (index: Int, task: URLSessionTask) in
Expand Down Expand Up @@ -228,7 +228,7 @@ public class Horizons {
/// - complete: Block to execute upon completion
public func fetchEphemeris(preferredDate: JulianDay = JulianDay.now, naifs: [Naif] = [Naif.sun] + Horizons.motionDefaultNaifs, mode: FetchMode = .mixed, update: ((Ephemeris) -> Void)? = nil, complete: ((Ephemeris?, [Error]?) -> Void)? = nil) {
// load local data
var cachedBodies = Set<CelestialBody>(mode == .onlineOnly ? [] : (naifs.flatMap {
var cachedBodies = Set<CelestialBody>(mode == .onlineOnly ? [] : (naifs.compactMap {
CelestialBody.load(naifId: $0.rawValue)
}))
if cachedBodies.isEmpty && mode == .localOnly {
Expand Down Expand Up @@ -259,7 +259,7 @@ public class Horizons {
}
return
}
var bodies = Set<CelestialBody>(rawData.flatMap { (_, content) -> CelestialBody? in
var bodies = Set<CelestialBody>(rawData.compactMap { (_, content) -> CelestialBody? in
if let body = CelestialBodyParser.default.parse(content: content) {
body.save()
return body
Expand Down Expand Up @@ -291,7 +291,7 @@ public class Horizons {
}

private func fetchObserverInfo<T, P>(preferredDate: Date = Date(), observerSite site: ObserverSite, timeZone: TimeZone, naifs: [Naif], mode: FetchMode = .preferLocal, queryMethod: (Set<Naif>, ObserverSite, Date) -> [HorizonsQuery], parser: P, update: (([Naif: T]) -> Void)? = nil, complete: (([Naif: T], [Error]?) -> Void)? = nil) where T: ObserverLoadable, P: Parser {
let list: [T] = (mode == .onlineOnly ? [] : naifs.flatMap {
let list: [T] = (mode == .onlineOnly ? [] : naifs.compactMap {
T.load(naifId: $0.rawValue, optimalJulianDay: JulianDay(date: preferredDate), site: site, timeZone: timeZone)
})
var dict = [Naif: T]()
Expand Down
2 changes: 1 addition & 1 deletion Orbits/Networking/Horizons/HorizonsQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public struct HorizonsQuery: Hashable {
let thisMonth = calendar.date(from: monthComponents)!
let thisMonthLittleBitLater = thisMonth.addingTimeInterval(1800)

return Array(Set<Naif>(naifs)).sorted().flatMap { (naif) -> HorizonsQuery? in
return Array(Set<Naif>(naifs)).sorted().compactMap { (naif) -> HorizonsQuery? in
switch naif {
case .majorBody(let planet):
return HorizonsQuery(center: String(Naif.sun.rawValue), command: planet.rawValue, tableType: .elements, startTime: thisYear, stopTime: thisYearLittleBitLater)
Expand Down
4 changes: 2 additions & 2 deletions Orbits/Networking/Horizons/ObserverField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public extension HorizonsQuery {

/// J2000.0 astrometric right ascension and declination of target center.
/// Adjusted for light-time. Units: HMS (HH MM SS.ff) and DMS (DD MM SS.f)
public static let astrometricRaAndDec = ObserverField(rawValue: 1 << 1)
public static let astrometricRaAndDec = ObserverField(rawValue: 1 << 1)

/// Airless apparent azimuth and elevation of target center. Adjusted for light-time, the gravitational deflection of light, stellar aberration, precession and nutation. Azimuth measured North(0) -> East(90) -> South(180) -> West(270) -> North (360). Elevation is with respect to plane perpendicular to local zenith direction.
public static let apparentAzimuthAndElevation = ObserverField(rawValue: 1 << 4)
Expand Down Expand Up @@ -71,7 +71,7 @@ public extension HorizonsQuery {

/// Generated quantity string for JPL Horizons
public var quantities: String {
return (0..<64).flatMap { 1 & rawValue >> UInt64($0) == 1 ? String($0) : nil }.joined(separator: ",")
return (0..<64).compactMap { 1 & rawValue >> UInt64($0) == 1 ? String($0) : nil }.joined(separator: ",")
}

public static let geocentricObserverFields: ObserverField = [
Expand Down
2 changes: 1 addition & 1 deletion Orbits/Networking/Parsers/CelestialBodyParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public final class CelestialBodyParser: CommonParser, Parser {
let noHead = lines.drop(while: { $0.matches(regex: "\\*\\*\\*") == false }).dropFirst()
let remaining = noHead.prefix(while: { $0.matches(regex: "\\*\\*\\*") == false })
var results = [String: String]()
remaining.flatMap { (line) -> [(String, String)]? in
remaining.compactMap { (line) -> [(String, String)]? in
guard let result = parseDoubleColumn(line) else { return nil }
if let col2 = result.1 {
return [result.0, col2]
Expand Down
4 changes: 2 additions & 2 deletions Orbits/Networking/Parsers/CommonParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class CommonParser {
let regex = "^([^:]+):\\s([^\\{]+)(\\{[^\\}]+\\})?$"
var results = [String: (String, String?)]()
info.map { (i) -> [(String, String, String?)] in
return i.matches(for: regex).flatMap { (matches) -> (String, String, String?)? in
return i.matches(for: regex).compactMap { (matches) -> (String, String, String?)? in
guard matches.count == 4 else { return nil }
let m = matches.map { $0.trimmed() }
return (m[1], m[2], m[3].isEmpty ? nil : m[3])
Expand All @@ -29,7 +29,7 @@ public class CommonParser {

func extractCoordinate(_ coord: (String, String?)?) -> CLLocation? {
guard let coord = coord else { return nil }
let components = coord.0.components(separatedBy: ",").flatMap { Double($0.trimmed()) }
let components = coord.0.components(separatedBy: ",").compactMap { Double($0.trimmed()) }
guard components.count == 3 else { return nil }
// TODO: calculate height regarding reference ellipsoid
// https://en.wikipedia.org/wiki/Reference_ellipsoid
Expand Down
2 changes: 1 addition & 1 deletion Orbits/Networking/Parsers/EphemerisMotionParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public final class EphemerisMotionParser: CommonParser, Parser {
let systemGm = systemGM(systemInfo["Keplerian GM"]?.0 ?? systemInfo["System GM"]?.0)
let lines = breakEphemerisIntoLines(content: content)
guard let naifId = extractNameId(systemInfo["Target body name"])?.1 else { fatalError() }
return lines.flatMap { self.parseEphemerisLine(naifId: naifId, gm: systemGm, line: $0, save: save) }
return lines.compactMap { self.parseEphemerisLine(naifId: naifId, gm: systemGm, line: $0, save: save) }
}
}
2 changes: 1 addition & 1 deletion Orbits/Networking/Parsers/ObserverEphemerisParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public final class ObserverEphemerisParser: CommonParser, Parser {
let labels = lines[soeIndex - 2].components(separatedBy: ",").map { $0.trimmed() }

func extractContent(of components: [String], for field: Field) -> String {
let index = field.strings.flatMap { labels.index(of: $0) }.first!
let index = field.strings.compactMap { labels.index(of: $0) }.first!
return components[index]
}

Expand Down

0 comments on commit 8058fdc

Please sign in to comment.