Skip to content

Commit abf68a6

Browse files
committed
Updated to Swift 5.0, Removed Swift 3 support
1 parent 9384264 commit abf68a6

26 files changed

+210
-227
lines changed

.travis.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode10
2+
osx_image: xcode10.2
33
xcode_project: $PROJECTNAME.xcodeproj
44
env:
55
global:
@@ -13,14 +13,14 @@ env:
1313
- MACOS_SDK=macosx
1414
- TVOS_SDK=appletvsimulator
1515
matrix:
16-
- DESTINATION="OS=11.0,name=iPad Pro (10.5-inch)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" CARTHAGEDEPLOY="YES"
17-
- DESTINATION="OS=11.0,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" POD="YES"
16+
- DESTINATION="OS=12.2,name=iPad Pro (10.5-inch)" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" CARTHAGEDEPLOY="YES"
17+
- DESTINATION="OS=12.2,name=iPhone 8" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" POD="YES"
1818
- DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" SDK="$MACOS_SDK"
1919
- DESTINATION="arch=x86_64" SCHEME="FilesProviderTests" SDK="$MACOS_SDK" RUN_TESTS="YES"
20-
- DESTINATION="OS=11.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK"
20+
- DESTINATION="OS=12.2,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK"
2121
before_install:
22-
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
23-
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
22+
- gem install xcpretty --no-document --quiet
23+
- gem install cocoapods --no-document --quiet
2424
# - gem install xcpretty-travis-formatter
2525

2626
script:

FilesProvider.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

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

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

68-
s.swift_version = "4.2"
68+
s.swift_version = "5.0"
6969
s.ios.deployment_target = "8.0"
7070
s.osx.deployment_target = "10.10"
7171
# s.watchos.deployment_target = "2.0"

FilesProvider.xcodeproj/project.pbxproj

+8-3
Original file line numberDiff line numberDiff line change
@@ -511,22 +511,25 @@
511511
};
512512
799396741D48B80D00086753 = {
513513
CreatedOnToolsVersion = 7.3.1;
514+
LastSwiftMigration = 1020;
514515
};
515516
799396811D48B82700086753 = {
516517
CreatedOnToolsVersion = 7.3.1;
517518
};
518519
79D903501FAB647400D61D31 = {
519520
CreatedOnToolsVersion = 9.1;
521+
LastSwiftMigration = 1020;
520522
ProvisioningStyle = Automatic;
521523
};
522524
};
523525
};
524526
buildConfigurationList = 7993965F1D48B7BF00086753 /* Build configuration list for PBXProject "FilesProvider" */;
525527
compatibilityVersion = "Xcode 3.2";
526-
developmentRegion = English;
528+
developmentRegion = en;
527529
hasScannedForEncodings = 0;
528530
knownRegions = (
529531
en,
532+
Base,
530533
);
531534
mainGroup = 7993965B1D48B7BF00086753;
532535
productRefGroup = 799396681D48B7F600086753 /* Products */;
@@ -904,7 +907,7 @@
904907
PRODUCT_BUNDLE_IDENTIFIER = "com.mousavian.FilesProvider-OSX";
905908
SDKROOT = macosx;
906909
SKIP_INSTALL = YES;
907-
SWIFT_VERSION = 4.2;
910+
SWIFT_VERSION = 5.0;
908911
VERSIONING_SYSTEM = "apple-generic";
909912
VERSION_INFO_PREFIX = "";
910913
};
@@ -938,7 +941,7 @@
938941
PRODUCT_BUNDLE_IDENTIFIER = "com.mousavian.FilesProvider-OSX";
939942
SDKROOT = macosx;
940943
SKIP_INSTALL = YES;
941-
SWIFT_VERSION = 4.2;
944+
SWIFT_VERSION = 5.0;
942945
VERSIONING_SYSTEM = "apple-generic";
943946
VERSION_INFO_PREFIX = "";
944947
};
@@ -1051,6 +1054,7 @@
10511054
PRODUCT_NAME = "$(TARGET_NAME)";
10521055
SDKROOT = macosx;
10531056
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
1057+
SWIFT_VERSION = 5.0;
10541058
};
10551059
name = Debug;
10561060
};
@@ -1083,6 +1087,7 @@
10831087
PRODUCT_BUNDLE_IDENTIFIER = com.mousavian.FilesProviderTests;
10841088
PRODUCT_NAME = "$(TARGET_NAME)";
10851089
SDKROOT = macosx;
1090+
SWIFT_VERSION = 5.0;
10861091
};
10871092
name = Release;
10881093
};

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

Sources/AEXML/Element.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ internal class AEXMLElement {
192192
}
193193

194194
fileprivate func removeChild(_ child: AEXMLElement) {
195-
if let childIndex = children.index(where: { $0 === child }) {
195+
if let childIndex = children.firstIndex(where: { $0 === child }) {
196196
children.remove(at: childIndex)
197197
}
198198
}
@@ -266,7 +266,7 @@ internal class AEXMLElement {
266266

267267
}
268268

269-
public extension String {
269+
extension String {
270270

271271
/// String representation of self with XML special characters escaped.
272272
public var xmlEscaped: String {

Sources/CloudFileProvider.swift

+2-9
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ open class CloudFileProvider: LocalFileProvider, FileProviderSharing {
8282
super.init(baseURL: baseURL)
8383
self.isCoorinating = true
8484

85-
#if swift(>=3.1)
86-
let queueLabel = "FileProvider.\(Swift.type(of: self).type)"
87-
#else
88-
let queueLabel = "FileProvider.\(type(of: self).type)"
89-
#endif
85+
let queueLabel = "FileProvider.\(Swift.type(of: self).type)"
9086
dispatch_queue = DispatchQueue(label: queueLabel, attributes: .concurrent)
9187
operation_queue = OperationQueue()
9288
operation_queue.name = "\(queueLabel).Operation"
@@ -570,6 +566,7 @@ extension CloudFileProvider {
570566
case .and: return NSCompoundPredicate(andPredicateWithSubpredicates: newSub)
571567
case .not: return NSCompoundPredicate(notPredicateWithSubpredicate: newSub.first!)
572568
case .or: return NSCompoundPredicate(orPredicateWithSubpredicates: newSub)
569+
@unknown default: fatalError()
573570
}
574571
} else if let cQuery = queryComponent as? NSComparisonPredicate {
575572
var newLeft = cQuery.leftExpression
@@ -599,11 +596,7 @@ extension CloudFileProvider {
599596
}
600597

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

Sources/DropboxFileProvider.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,11 @@ extension DropboxFileProvider: ExtendedFileProvider {
436436
case "jpg", "jpeg", "gif", "bmp", "png", "tif", "tiff":
437437
return true
438438
case "doc", "docx", "docm", "xls", "xlsx", "xlsm":
439-
return true
439+
return false
440440
case "ppt", "pps", "ppsx", "ppsm", "pptx", "pptm":
441-
return true
441+
return false
442442
case "rtf":
443-
return true
443+
return false
444444
default:
445445
return false
446446
}

Sources/DropboxHelper.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public final class DropboxFileObject: FileObject {
7272
}
7373
}
7474

75-
internal extension DropboxFileProvider {
76-
internal func correctPath(_ path: String?) -> String? {
75+
extension DropboxFileProvider {
76+
func correctPath(_ path: String?) -> String? {
7777
guard let path = path else { return nil }
7878
if path.hasPrefix("id:") || path.hasPrefix("rev:") {
7979
return path
@@ -85,7 +85,7 @@ internal extension DropboxFileProvider {
8585
return p
8686
}
8787

88-
internal func listRequest(path: String, queryStr: String? = nil, recursive: Bool = false) -> ((_ token: String?) -> URLRequest?) {
88+
func listRequest(path: String, queryStr: String? = nil, recursive: Bool = false) -> ((_ token: String?) -> URLRequest?) {
8989
if let queryStr = queryStr {
9090
return { [weak self] (token) -> URLRequest? in
9191
guard let `self` = self else { return nil }

Sources/ExtendedLocalFileProvider.swift

+2-18
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,7 @@ public struct LocalFileInformationGenerator {
199199
static public var audioThumbnail: (_ fileURL: URL, _ dimension: CGSize?) -> ImageClass? = { fileURL, dimension in
200200
let playerItem = AVPlayerItem(url: fileURL)
201201
let metadataList = playerItem.asset.commonMetadata
202-
#if swift(>=4.0)
203202
let commonKeyArtwork = AVMetadataKey.commonKeyArtwork
204-
#else
205-
let commonKeyArtwork = AVMetadataCommonKeyArtwork
206-
#endif
207203
for item in metadataList {
208204
if item.commonKey == commonKeyArtwork {
209205
if let data = item.dataValue {
@@ -356,11 +352,7 @@ public struct LocalFileInformationGenerator {
356352
let playerItem = AVPlayerItem(url: fileURL)
357353
let metadataList = playerItem.asset.commonMetadata
358354
for item in metadataList {
359-
#if swift(>=4.0)
360-
let commonKey = item.commonKey?.rawValue
361-
#else
362-
let commonKey = item.commonKey
363-
#endif
355+
let commonKey = item.commonKey?.rawValue
364356
if let key = makeKeyDescription(commonKey) {
365357
if commonKey == "location", let value = item.stringValue, let loc = parseLocationData(value) {
366358
keys.append(key)
@@ -401,16 +393,12 @@ public struct LocalFileInformationGenerator {
401393
dic = audioprops.prop
402394
keys = audioprops.keys
403395
dic.removeValue(forKey: "Duration")
404-
if let index = keys.index(of: "Duration") {
396+
if let index = keys.firstIndex(of: "Duration") {
405397
keys.remove(at: index)
406398
}
407399
}
408400
let asset = AVURLAsset(url: fileURL, options: nil)
409-
#if swift(>=4.0)
410401
let videoTracks = asset.tracks(withMediaType: AVMediaType.video)
411-
#else
412-
let videoTracks = asset.tracks(withMediaType: AVMediaTypeVideo)
413-
#endif
414402
if let videoTrack = videoTracks.first {
415403
var bitrate: Float = 0
416404
let width = Int(videoTrack.naturalSize.width)
@@ -424,11 +412,7 @@ public struct LocalFileInformationGenerator {
424412
add(key: "Duration", value: TimeInterval(duration).formatshort)
425413
add(key: "Video Bitrate", value: "\(Int(ceil(bitrate / 1000))) kbps")
426414
}
427-
#if swift(>=4.0)
428415
let audioTracks = asset.tracks(withMediaType: AVMediaType.audio)
429-
#else
430-
let audioTracks = asset.tracks(withMediaType: AVMediaTypeAudio)
431-
#endif
432416
// dic["Audio channels"] = audioTracks.count
433417
var bitrate: Float = 0
434418
for track in audioTracks {

0 commit comments

Comments
 (0)