Migrates to Swift 5

This commit is contained in:
Riley Testut 2019-02-25 12:40:30 -08:00
parent 14e2eefc42
commit fe6701c82c
19 changed files with 42 additions and 68 deletions

@ -1 +1 @@
Subproject commit 20dad9d006d8047588461f91e56d5b5757ece658
Subproject commit cae35b190131ff47fe8b323b11f98b726f54cc62

@ -1 +1 @@
Subproject commit 21ba9850fb0812148d0826069f8cc3000d476a07
Subproject commit 4ccd3b4ef105339a45aa3b1386c7f6f04f631c32

@ -1 +1 @@
Subproject commit 473474019bd2e3be623cd593da4c1e8c4e51fb80
Subproject commit c374ab03af8fad108a0456483e453c3cfb8b2776

@ -1 +1 @@
Subproject commit d83e51d06020045adc4403b9d77e604cf46e34f5
Subproject commit c4968f5ada470a3c557cc580f429e9238526cc2c

@ -1 +1 @@
Subproject commit 5f341a67ad326829d3557d01df6977d02722a5da
Subproject commit a8e9b8a7faee76c8ffe595c7a363825ae9ef53c3

View File

@ -844,7 +844,7 @@
BFFA71D61AAC406100EE9DD1 = {
CreatedOnToolsVersion = 6.3;
DevelopmentTeam = 6XVY5G3U44;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.iCloud = {
@ -1260,7 +1260,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Delta/Supporting Files/Delta-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@ -1282,7 +1282,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Delta/Supporting Files/Delta-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"

View File

@ -22,41 +22,13 @@ extension DatabaseManager
extension DatabaseManager
{
enum ImportError: Error, Hashable
enum ImportError: Error, Hashable, Equatable
{
case doesNotExist(URL)
case invalid(URL)
case unsupported(URL)
case unknown(URL, NSError)
case saveFailed(Set<URL>, NSError)
var hashValue: Int {
switch self
{
case .doesNotExist: return 0
case .invalid: return 1
case .unsupported: return 2
case .unknown: return 3
case .saveFailed: return 4
}
}
static func ==(lhs: ImportError, rhs: ImportError) -> Bool
{
switch (lhs, rhs)
{
case (let .doesNotExist(url1), let .doesNotExist(url2)) where url1 == url2: return true
case (let .invalid(url1), let .invalid(url2)) where url1 == url2: return true
case (let .unsupported(url1), let .unsupported(url2)) where url1 == url2: return true
case (let .unknown(url1, error1), let .unknown(url2, error2)) where url1 == url2 && error1 == error2: return true
case (let .saveFailed(urls1, error1), let .saveFailed(urls2, error2)) where urls1 == urls2 && error1 == error2: return true
case (.doesNotExist, _): return false
case (.invalid, _): return false
case (.unsupported, _): return false
case (.unknown, _): return false
case (.saveFailed, _): return false
}
}
}
}

View File

@ -18,7 +18,7 @@ internal extension UILabel
context.minimumScaleFactor = self.minimumScaleFactor
// Using self.attributedString returns incorrect calculations, so we create our own attributed string
let attributedString = NSAttributedString(string: text, attributes: [.font: self.font])
let attributedString = NSAttributedString(string: text, attributes: [.font: self.font!])
attributedString.boundingRect(with: self.bounds.size, options: [.usesLineFragmentOrigin, .usesFontLeading], context: context)
let scaleFactor = context.actualScaleFactor

View File

@ -244,7 +244,7 @@ private extension GamesViewController
if let viewController = self.pageViewController.viewControllers?.first as? GameCollectionViewController, let gameCollection = viewController.gameCollection
{
if let index = self.fetchedResultsController.fetchedObjects?.index(where: { $0 as! GameCollection == gameCollection })
if let index = self.fetchedResultsController.fetchedObjects?.firstIndex(where: { $0 as! GameCollection == gameCollection })
{
self.pageControl.currentPage = index
}
@ -273,7 +273,7 @@ private extension GamesViewController
if let gameCollection = Settings.previousGameCollection
{
if let gameCollectionIndex = self.fetchedResultsController.fetchedObjects?.index(where: { $0 as! GameCollection == gameCollection })
if let gameCollectionIndex = self.fetchedResultsController.fetchedObjects?.firstIndex(where: { $0 as! GameCollection == gameCollection })
{
index = gameCollectionIndex
}
@ -451,7 +451,7 @@ extension GamesViewController: UIPageViewControllerDataSource, UIPageViewControl
{
if let viewController = pageViewController.viewControllers?.first as? GameCollectionViewController, let gameCollection = viewController.gameCollection
{
let index = self.fetchedResultsController.fetchedObjects?.index(where: { $0 as! GameCollection == gameCollection }) ?? 0
let index = self.fetchedResultsController.fetchedObjects?.firstIndex(where: { $0 as! GameCollection == gameCollection }) ?? 0
self.pageControl.currentPage = index
Settings.previousGameCollection = gameCollection

View File

@ -151,7 +151,7 @@ extension EditCheatViewController
self.typeSegmentedControl.insertSegment(withTitle: format.name, at: index, animated: false)
}
if let index = self.supportedCheatFormats.index(where: { $0.type == type })
if let index = self.supportedCheatFormats.firstIndex(where: { $0.type == type })
{
self.typeSegmentedControl.selectedSegmentIndex = index
}

View File

@ -290,6 +290,8 @@ extension AppIconShortcutsViewController
case .insert:
let game = self.dataSource.item(at: indexPath)
self.addShortcut(for: game)
@unknown default: break
}
self.updateShortcuts()

View File

@ -327,7 +327,7 @@ private extension ControllerInputsViewController
let menuItem: MenuItem?
if let input = self.calloutViews.first(where: { $0.value == calloutView })?.key, let index = self.supportedActionInputs.index(where: { $0 == input })
if let input = self.calloutViews.first(where: { $0.value == calloutView })?.key, let index = self.supportedActionInputs.firstIndex(where: { $0 == input })
{
menuItem = self.actionsMenuViewController.items[index]
}
@ -455,7 +455,7 @@ private extension ControllerInputsViewController
return presentationFrame
}
}
else if let index = self.supportedActionInputs.index(where: { $0 == input })
else if let index = self.supportedActionInputs.firstIndex(where: { $0 == input })
{
// Input is an ActionInput.

View File

@ -188,7 +188,7 @@ private extension ControllersSettingsViewController
self.connectedControllers.append(controller)
}
if let index = self.connectedControllers.index(where: { $0 == controller })
if let index = self.connectedControllers.firstIndex(where: { $0 == controller })
{
self.tableView.beginUpdates()
@ -220,7 +220,7 @@ private extension ControllersSettingsViewController
{
guard let controller = notification.object as? GameController else { return }
if let index = self.connectedControllers.index(where: { $0 == controller })
if let index = self.connectedControllers.firstIndex(where: { $0 == controller })
{
self.connectedControllers.remove(at: index)
@ -322,7 +322,7 @@ extension ControllersSettingsViewController
{
previousIndexPath = IndexPath(row: 0, section: Section.localDevice.rawValue)
}
else if let row = self.connectedControllers.index(where: { $0 == gameController })
else if let row = self.connectedControllers.firstIndex(where: { $0 == gameController })
{
previousIndexPath = IndexPath(row: row, section: Section.externalControllers.rawValue)
}

View File

@ -114,8 +114,8 @@ extension Settings
fetchRequest.returnsObjectsAsFaults = false
let games = try DatabaseManager.shared.viewContext.fetch(fetchRequest).sorted(by: { (game1, game2) -> Bool in
let index1 = identifiers.index(of: game1.identifier)!
let index2 = identifiers.index(of: game2.identifier)!
let index1 = identifiers.firstIndex(of: game1.identifier)!
let index2 = identifiers.firstIndex(of: game2.identifier)!
return index1 < index2
})

View File

@ -258,7 +258,7 @@ extension SettingsViewController
{
cell.detailTextLabel?.text = UIDevice.current.name
}
else if let index = ExternalGameControllerManager.shared.connectedControllers.index(where: { $0.playerIndex == indexPath.row })
else if let index = ExternalGameControllerManager.shared.connectedControllers.firstIndex(where: { $0.playerIndex == indexPath.row })
{
let controller = ExternalGameControllerManager.shared.connectedControllers[index]
cell.detailTextLabel?.text = controller.name

2
External/Harmony vendored

@ -1 +1 @@
Subproject commit d3d5a3c8e6c9d584802e233856733afaac3bc58e
Subproject commit be948ee142edc3477e7ba5e8071350963348c9e2

2
External/Roxas vendored

@ -1 +1 @@
Subproject commit 8a5be70fd3221e9e3151351906b1fd938bca0e1d
Subproject commit 91eaa0876c7c0f83c3800873c2dff7f445265d88

View File

@ -144,7 +144,7 @@
557CF7419840B4A6491AE0D6F7B248B7 /* SDWebImage-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-prefix.pch"; sourceTree = "<group>"; };
55FAC0793F816073733844CCB1C6BB96 /* Pods-Delta.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-Delta.modulemap"; sourceTree = "<group>"; };
5C963DB8AE33E77F3F78613319B3AA04 /* Pods-Delta.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Delta.release.xcconfig"; sourceTree = "<group>"; };
5D8A16BFAF974C8480E88C1CCE36FB8A /* SDWebImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SDWebImage.framework; path = SDWebImage.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5D8A16BFAF974C8480E88C1CCE36FB8A /* SDWebImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImage.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6311C71DA6DFF76DA6072A9271C47249 /* Helpers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Helpers.swift; path = Sources/SQLite/Helpers.swift; sourceTree = "<group>"; };
685520FF242A9E1E00F39F956B35BD67 /* UIImage+GIF.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+GIF.m"; path = "SDWebImage/UIImage+GIF.m"; sourceTree = "<group>"; };
69D55F84D9F3D57CA545166F6AA4A592 /* SMCalloutView-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SMCalloutView-prefix.pch"; sourceTree = "<group>"; };
@ -161,13 +161,13 @@
8CBD3738952094DC052525D17195862F /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+MultiFormat.h"; path = "SDWebImage/UIImage+MultiFormat.h"; sourceTree = "<group>"; };
8D35756B1C14A4658AB4544BE16C9578 /* SMCalloutView-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SMCalloutView-umbrella.h"; sourceTree = "<group>"; };
8D58E0AD62A87DFCC19FCFF60B562745 /* SQLite.swift-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SQLite.swift-prefix.pch"; sourceTree = "<group>"; };
93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
93BD0D8B83E15DAF488D100A42D191CD /* SDWebImagePrefetcher.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImagePrefetcher.m; path = SDWebImage/SDWebImagePrefetcher.m; sourceTree = "<group>"; };
93C18E53294E58D4E76D468FF49C6202 /* SMClassicCalloutView.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = SMClassicCalloutView.h; sourceTree = "<group>"; };
95C39202A4EB05C4CAB3FE80A39F0F82 /* UIView+WebCacheOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCacheOperation.m"; path = "SDWebImage/UIView+WebCacheOperation.m"; sourceTree = "<group>"; };
96DEEBF1E781EDBC78474E40EF85E682 /* CLSAttributes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = CLSAttributes.h; path = iOS/Crashlytics.framework/Headers/CLSAttributes.h; sourceTree = "<group>"; };
97591C72953278B70565BBE7139427B9 /* UIImageView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+WebCache.m"; path = "SDWebImage/UIImageView+WebCache.m"; sourceTree = "<group>"; };
A72951A2B85A2C960D7B8E8C466416D9 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SQLite.framework; path = SQLite.swift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A72951A2B85A2C960D7B8E8C466416D9 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A7A966B899B6C2A2E06CE373CF339331 /* SDWebImage-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-umbrella.h"; sourceTree = "<group>"; };
AA3B6B44CCABD240B81D21711AC5968A /* CLSStackFrame.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = CLSStackFrame.h; path = iOS/Crashlytics.framework/Headers/CLSStackFrame.h; sourceTree = "<group>"; };
AA50820D47457DC81A95FD3AAA2E363F /* Crashlytics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Crashlytics.framework; path = iOS/Crashlytics.framework; sourceTree = "<group>"; };
@ -184,13 +184,13 @@
C6258146D8E24AD2999B1040D5C2A6F2 /* SDImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCache.h; path = SDWebImage/SDImageCache.h; sourceTree = "<group>"; };
C6811BB8A4BE4E04E52AB5AAD830105A /* Pods-Delta-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Delta-frameworks.sh"; sourceTree = "<group>"; };
CD3F038BA3A3ACB78C893A06CEC828F0 /* UIImageView+HighlightedWebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+HighlightedWebCache.m"; path = "SDWebImage/UIImageView+HighlightedWebCache.m"; sourceTree = "<group>"; };
CD964CDC1209915A1490C8EE65F8E1DB /* SMCalloutView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SMCalloutView.framework; path = SMCalloutView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CD964CDC1209915A1490C8EE65F8E1DB /* SMCalloutView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SMCalloutView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D6089B540E88A4DBBE44FB7B3C472481 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D75A8954A7BF855C1F4A117B8BD9B832 /* Pods-Delta-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Delta-umbrella.h"; sourceTree = "<group>"; };
D9696C5A8B0B772EA7EC7542E21AFDEA /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+MultiFormat.m"; path = "SDWebImage/UIImage+MultiFormat.m"; sourceTree = "<group>"; };
DADE3023F80C3FEB78D227650AC7B993 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
DAE3BA7002E0F96CEA7635E2BF4ABADC /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DF24DDBE1929E32C83DF0577FF823E7F /* Pods_Delta.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_Delta.framework; path = "Pods-Delta.framework"; sourceTree = BUILT_PRODUCTS_DIR; };
DF24DDBE1929E32C83DF0577FF823E7F /* Pods_Delta.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Delta.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E33485CF6A10A9C1F0647FC75A2AB40D /* SQLite.swift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = SQLite.swift.modulemap; sourceTree = "<group>"; };
E46D526A184E70145FCCFFDA63990551 /* SDWebImageCompat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCompat.h; path = SDWebImage/SDWebImageCompat.h; sourceTree = "<group>"; };
E4D8F9F3A766B64DC395B48B9ADDE2DB /* UIButton+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+WebCache.h"; path = "SDWebImage/UIButton+WebCache.h"; sourceTree = "<group>"; };
@ -287,7 +287,6 @@
783C003A5C9A0A7247956CB50183C2EB /* Fabric.h */,
4E46707FEF20EA78AC6559052FD32212 /* Frameworks */,
);
name = Fabric;
path = Fabric;
sourceTree = "<group>";
};
@ -474,7 +473,6 @@
040DACE73F54B3184AA41E60A6C1D6B9 /* Crashlytics.h */,
93FCC35CECA232AE9EB0CBF4B43AEB87 /* Frameworks */,
);
name = Crashlytics;
path = Crashlytics;
sourceTree = "<group>";
};
@ -484,7 +482,6 @@
9DB185E8D1C7F64B662CE1D3D3233BE7 /* Core */,
04222A5719AFB024056FE1576A57AF2D /* Support Files */,
);
name = SDWebImage;
path = SDWebImage;
sourceTree = "<group>";
};
@ -497,7 +494,6 @@
37D05DA178B749BEE506084B2FED69EC /* SMClassicCalloutView.m */,
99325B0F89D5930DC0A4D4F41D4ADA9E /* Support Files */,
);
name = SMCalloutView;
path = SMCalloutView;
sourceTree = "<group>";
};
@ -507,7 +503,6 @@
851CBD722DC9A60CCFFF80135A75EDB4 /* standard */,
56ADA9CCC74D54293AC8780A1AB539A1 /* Support Files */,
);
name = SQLite.swift;
path = SQLite.swift;
sourceTree = "<group>";
};
@ -651,7 +646,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0930;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
TargetAttributes = {
81A9EC22E9C1B2AB9AD8F0B36EC21266 = {
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */;
compatibilityVersion = "Xcode 3.2";
@ -659,6 +659,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 7DB346D0F39D3F0E887471402A8071AB;
productRefGroup = 7C01FF07D6B0EFD78D74AB7BBEBDCDA4 /* Products */;
@ -926,8 +927,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
@ -1117,6 +1117,7 @@
MTL_FAST_MATH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
STRIP_INSTALLED_PRODUCT = NO;
SWIFT_COMPILATION_MODE = wholemodule;
SYMROOT = "${SRCROOT}/../build";
};
name = Release;
@ -1177,8 +1178,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) ";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;