From ed0ac0989de9fc2ac5c6a803a018d34a206fb547 Mon Sep 17 00:00:00 2001 From: Rens Verhoeven Date: Thu, 26 Oct 2017 11:35:19 +0200 Subject: [PATCH 1/2] Swift 3.2 and Xcode 9 support --- Ocarina.xcodeproj/project.pbxproj | 14 +++++++++++++- .../xcschemes/Ocarina Example.xcscheme | 4 +++- .../xcshareddata/xcschemes/Ocarina.xcscheme | 4 +++- Ocarina/Ocarina.h | 2 +- Ocarina/OcarinaManagerDelegate.swift | 2 +- Ocarina/OcarinaPrefetcher.swift | 2 +- Ocarina/URLInformation.swift | 2 +- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Ocarina.xcodeproj/project.pbxproj b/Ocarina.xcodeproj/project.pbxproj index 1a9b1e7..d366177 100644 --- a/Ocarina.xcodeproj/project.pbxproj +++ b/Ocarina.xcodeproj/project.pbxproj @@ -317,7 +317,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = awkward; TargetAttributes = { 0C879D9F1E535182004606F2 = { @@ -476,7 +476,9 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; @@ -484,7 +486,11 @@ 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -525,7 +531,9 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; @@ -533,7 +541,11 @@ 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina Example.xcscheme b/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina Example.xcscheme index 0a803bf..9ab4a3e 100644 --- a/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina Example.xcscheme +++ b/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina Example.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina.xcscheme b/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina.xcscheme index d739c63..fdd4038 100644 --- a/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina.xcscheme +++ b/Ocarina.xcodeproj/xcshareddata/xcschemes/Ocarina.xcscheme @@ -1,6 +1,6 @@ +#import //! Project version number for Ocarina. FOUNDATION_EXPORT double OcarinaVersionNumber; diff --git a/Ocarina/OcarinaManagerDelegate.swift b/Ocarina/OcarinaManagerDelegate.swift index 9178a62..ce924cf 100644 --- a/Ocarina/OcarinaManagerDelegate.swift +++ b/Ocarina/OcarinaManagerDelegate.swift @@ -6,7 +6,7 @@ // Copyright © 2017 awkward. All rights reserved. // -import UIKit +import Foundation public protocol OcarinaManagerDelegate: class { diff --git a/Ocarina/OcarinaPrefetcher.swift b/Ocarina/OcarinaPrefetcher.swift index 30e66fa..0ac84a7 100644 --- a/Ocarina/OcarinaPrefetcher.swift +++ b/Ocarina/OcarinaPrefetcher.swift @@ -6,7 +6,7 @@ // Copyright © 2017 awkward. All rights reserved. // -import UIKit +import Foundation open class OcarinaPrefetcher: NSObject { diff --git a/Ocarina/URLInformation.swift b/Ocarina/URLInformation.swift index 6c49f72..34dd80b 100644 --- a/Ocarina/URLInformation.swift +++ b/Ocarina/URLInformation.swift @@ -6,7 +6,7 @@ // Copyright © 2017 awkward. All rights reserved. // -import Foundation +import UIKit import AVFoundation public enum URLInformationType: String { From 801158715c5d702ba537174c3b46cc52500417e0 Mon Sep 17 00:00:00 2001 From: Rens Verhoeven Date: Thu, 26 Oct 2017 11:37:00 +0200 Subject: [PATCH 2/2] Crash fix --- Ocarina/OcarinaManager.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Ocarina/OcarinaManager.swift b/Ocarina/OcarinaManager.swift index cf5525d..1f8a1ed 100644 --- a/Ocarina/OcarinaManager.swift +++ b/Ocarina/OcarinaManager.swift @@ -187,7 +187,9 @@ extension OcarinaManager: URLSessionDataDelegate { completionHandler(URLSession.ResponseDisposition.allow) } - public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { + // Note: Using optional `Data` to fix a crash: https://github.com/Alamofire/Alamofire/issues/2138 + public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data?) { + guard let data = data else { return } self.barrierQueue.sync { if var existingData = self.dataPerTask[dataTask.taskIdentifier] { existingData.append(data)