Skip to content

Commit

Permalink
Updated to Swift 5.0, Removed Swift 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
amosavian committed Apr 4, 2019
1 parent 9384264 commit abf68a6
Show file tree
Hide file tree
Showing 26 changed files with 210 additions and 227 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10
osx_image: xcode10.2
xcode_project: $PROJECTNAME.xcodeproj
env:
global:
Expand All @@ -13,14 +13,14 @@ env:
- MACOS_SDK=macosx
- TVOS_SDK=appletvsimulator
matrix:
- DESTINATION="OS=11.0,name=iPad Pro (10.5-inch)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" CARTHAGEDEPLOY="YES"
- DESTINATION="OS=11.0,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" POD="YES"
- DESTINATION="OS=12.2,name=iPad Pro (10.5-inch)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" CARTHAGEDEPLOY="YES"
- DESTINATION="OS=12.2,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" POD="YES"
- DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" SDK="$MACOS_SDK"
- DESTINATION="arch=x86_64" SCHEME="FilesProviderTests" SDK="$MACOS_SDK" RUN_TESTS="YES"
- DESTINATION="OS=11.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK"
- DESTINATION="OS=12.2,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK"
before_install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-document --quiet
- gem install cocoapods --no-document --quiet
# - gem install xcpretty-travis-formatter

script:
Expand Down
4 changes: 2 additions & 2 deletions FilesProvider.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "FilesProvider"
s.version = "0.25.1"
s.version = "0.26.0"
s.summary = "FileManager replacement for Local and Remote (WebDAV/FTP/Dropbox/OneDrive/SMB2) files on iOS and macOS."

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -65,7 +65,7 @@ Pod::Spec.new do |s|
# the deployment target. You can optionally include the target after the platform.
#

s.swift_version = "4.2"
s.swift_version = "5.0"
s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.10"
# s.watchos.deployment_target = "2.0"
Expand Down
11 changes: 8 additions & 3 deletions FilesProvider.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -511,22 +511,25 @@
};
799396741D48B80D00086753 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1020;
};
799396811D48B82700086753 = {
CreatedOnToolsVersion = 7.3.1;
};
79D903501FAB647400D61D31 = {
CreatedOnToolsVersion = 9.1;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 7993965F1D48B7BF00086753 /* Build configuration list for PBXProject "FilesProvider" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 7993965B1D48B7BF00086753;
productRefGroup = 799396681D48B7F600086753 /* Products */;
Expand Down Expand Up @@ -904,7 +907,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.mousavian.FilesProvider-OSX";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -938,7 +941,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.mousavian.FilesProvider-OSX";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1051,6 +1054,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1083,6 +1087,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mousavian.FilesProviderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.0
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
4 changes: 2 additions & 2 deletions Sources/AEXML/Element.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ internal class AEXMLElement {
}

fileprivate func removeChild(_ child: AEXMLElement) {
if let childIndex = children.index(where: { $0 === child }) {
if let childIndex = children.firstIndex(where: { $0 === child }) {
children.remove(at: childIndex)
}
}
Expand Down Expand Up @@ -266,7 +266,7 @@ internal class AEXMLElement {

}

public extension String {
extension String {

/// String representation of self with XML special characters escaped.
public var xmlEscaped: String {
Expand Down
11 changes: 2 additions & 9 deletions Sources/CloudFileProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ open class CloudFileProvider: LocalFileProvider, FileProviderSharing {
super.init(baseURL: baseURL)
self.isCoorinating = true

#if swift(>=3.1)
let queueLabel = "FileProvider.\(Swift.type(of: self).type)"
#else
let queueLabel = "FileProvider.\(type(of: self).type)"
#endif
let queueLabel = "FileProvider.\(Swift.type(of: self).type)"
dispatch_queue = DispatchQueue(label: queueLabel, attributes: .concurrent)
operation_queue = OperationQueue()
operation_queue.name = "\(queueLabel).Operation"
Expand Down Expand Up @@ -570,6 +566,7 @@ extension CloudFileProvider {
case .and: return NSCompoundPredicate(andPredicateWithSubpredicates: newSub)
case .not: return NSCompoundPredicate(notPredicateWithSubpredicate: newSub.first!)
case .or: return NSCompoundPredicate(orPredicateWithSubpredicates: newSub)
@unknown default: fatalError()
}
} else if let cQuery = queryComponent as? NSComparisonPredicate {
var newLeft = cQuery.leftExpression
Expand Down Expand Up @@ -599,11 +596,7 @@ extension CloudFileProvider {
}

let path = self.relativePathOf(url: url)
#if swift(>=4.0)
let rpath = path.hasPrefix("/") ? String(path[path.index(after: path.startIndex)...]) : path
#else
let rpath = path.hasPrefix("/") ? path.substring(from: path.index(after: path.startIndex)) : path
#endif
let relativeUrl = URL(string: rpath.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? rpath, relativeTo: self.baseURL)
let file = FileObject(url: relativeUrl ?? url, name: name, path: path)

Expand Down
6 changes: 3 additions & 3 deletions Sources/DropboxFileProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ extension DropboxFileProvider: ExtendedFileProvider {
case "jpg", "jpeg", "gif", "bmp", "png", "tif", "tiff":
return true
case "doc", "docx", "docm", "xls", "xlsx", "xlsm":
return true
return false
case "ppt", "pps", "ppsx", "ppsm", "pptx", "pptm":
return true
return false
case "rtf":
return true
return false
default:
return false
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/DropboxHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public final class DropboxFileObject: FileObject {
}
}

internal extension DropboxFileProvider {
internal func correctPath(_ path: String?) -> String? {
extension DropboxFileProvider {
func correctPath(_ path: String?) -> String? {
guard let path = path else { return nil }
if path.hasPrefix("id:") || path.hasPrefix("rev:") {
return path
Expand All @@ -85,7 +85,7 @@ internal extension DropboxFileProvider {
return p
}

internal func listRequest(path: String, queryStr: String? = nil, recursive: Bool = false) -> ((_ token: String?) -> URLRequest?) {
func listRequest(path: String, queryStr: String? = nil, recursive: Bool = false) -> ((_ token: String?) -> URLRequest?) {
if let queryStr = queryStr {
return { [weak self] (token) -> URLRequest? in
guard let `self` = self else { return nil }
Expand Down
20 changes: 2 additions & 18 deletions Sources/ExtendedLocalFileProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ public struct LocalFileInformationGenerator {
static public var audioThumbnail: (_ fileURL: URL, _ dimension: CGSize?) -> ImageClass? = { fileURL, dimension in
let playerItem = AVPlayerItem(url: fileURL)
let metadataList = playerItem.asset.commonMetadata
#if swift(>=4.0)
let commonKeyArtwork = AVMetadataKey.commonKeyArtwork
#else
let commonKeyArtwork = AVMetadataCommonKeyArtwork
#endif
for item in metadataList {
if item.commonKey == commonKeyArtwork {
if let data = item.dataValue {
Expand Down Expand Up @@ -356,11 +352,7 @@ public struct LocalFileInformationGenerator {
let playerItem = AVPlayerItem(url: fileURL)
let metadataList = playerItem.asset.commonMetadata
for item in metadataList {
#if swift(>=4.0)
let commonKey = item.commonKey?.rawValue
#else
let commonKey = item.commonKey
#endif
let commonKey = item.commonKey?.rawValue
if let key = makeKeyDescription(commonKey) {
if commonKey == "location", let value = item.stringValue, let loc = parseLocationData(value) {
keys.append(key)
Expand Down Expand Up @@ -401,16 +393,12 @@ public struct LocalFileInformationGenerator {
dic = audioprops.prop
keys = audioprops.keys
dic.removeValue(forKey: "Duration")
if let index = keys.index(of: "Duration") {
if let index = keys.firstIndex(of: "Duration") {
keys.remove(at: index)
}
}
let asset = AVURLAsset(url: fileURL, options: nil)
#if swift(>=4.0)
let videoTracks = asset.tracks(withMediaType: AVMediaType.video)
#else
let videoTracks = asset.tracks(withMediaType: AVMediaTypeVideo)
#endif
if let videoTrack = videoTracks.first {
var bitrate: Float = 0
let width = Int(videoTrack.naturalSize.width)
Expand All @@ -424,11 +412,7 @@ public struct LocalFileInformationGenerator {
add(key: "Duration", value: TimeInterval(duration).formatshort)
add(key: "Video Bitrate", value: "\(Int(ceil(bitrate / 1000))) kbps")
}
#if swift(>=4.0)
let audioTracks = asset.tracks(withMediaType: AVMediaType.audio)
#else
let audioTracks = asset.tracks(withMediaType: AVMediaTypeAudio)
#endif
// dic["Audio channels"] = audioTracks.count
var bitrate: Float = 0
for track in audioTracks {
Expand Down
Loading

0 comments on commit abf68a6

Please sign in to comment.