Migrates to Swift 4.2 via Xcode 10.1 migrator

This commit is contained in:
Riley Testut 2018-11-12 11:45:55 -08:00
parent 15b23c13e7
commit ba653037b1
22 changed files with 77 additions and 44 deletions

View File

@ -749,7 +749,7 @@
BFFA71D61AAC406100EE9DD1 = {
CreatedOnToolsVersion = 6.3;
DevelopmentTeam = 6XVY5G3U44;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.iCloud = {
@ -1145,8 +1145,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Delta/Supporting Files/Delta-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@ -1167,8 +1166,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Delta/Supporting Files/Delta-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
@ -96,7 +96,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@ -116,7 +115,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -20,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate
private let deepLinkController = DeepLinkController()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
Fabric.with([Crashlytics.self])
@ -93,7 +93,7 @@ extension AppDelegate
extension AppDelegate
{
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool
{
return self.openURL(url)
}

View File

@ -17,7 +17,7 @@ extension Action
case destructive
case selected
var alertActionStyle: UIAlertActionStyle
var alertActionStyle: UIAlertAction.Style
{
switch self
{
@ -27,7 +27,7 @@ extension Action
}
}
var previewActionStyle: UIPreviewActionStyle?
var previewActionStyle: UIPreviewAction.Style?
{
switch self
{
@ -90,7 +90,7 @@ extension RangeReplaceableCollection where Iterator.Element == Action
}
var previewActions: [UIPreviewAction] {
let actions = self.flatMap { UIPreviewAction($0) }
let actions = self.compactMap { UIPreviewAction($0) }
return actions
}
}

View File

@ -10,7 +10,7 @@ import UIKit
extension UINavigationBar
{
fileprivate var defaultTitleTextAttributes: [NSAttributedStringKey: Any]? {
fileprivate var defaultTitleTextAttributes: [NSAttributedString.Key: Any]? {
if let textAttributes = self._defaultTitleTextAttributes
{
return textAttributes
@ -35,7 +35,7 @@ extension UINavigationBar
return textAttributes
}
private var _defaultTitleTextAttributes: [NSAttributedStringKey: Any]? {
private var _defaultTitleTextAttributes: [NSAttributedString.Key: Any]? {
guard self.titleTextAttributes == nil else { return self.titleTextAttributes }
guard
@ -71,7 +71,7 @@ class PopoverMenuButton: UIControl
}
override var intrinsicContentSize: CGSize {
return self.stackView.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
return self.stackView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
}
init()
@ -90,7 +90,7 @@ class PopoverMenuButton: UIControl
self.stackView.spacing = 4.0
self.stackView.isUserInteractionEnabled = false
let intrinsicContentSize = self.stackView.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
let intrinsicContentSize = self.stackView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
super.init(frame: CGRect(origin: .zero, size: intrinsicContentSize))
self.addSubview(self.stackView, pinningEdgesWith: .zero)

View File

@ -19,7 +19,7 @@ class GamesDatabaseBrowserViewController: UITableViewController
private let dataSource: RSTArrayTableViewPrefetchingDataSource<GameMetadata, UIImage>
override init(style: UITableViewStyle) {
override init(style: UITableView.Style) {
fatalError()
}

View File

@ -29,11 +29,11 @@ extension UIApplicationShortcutItem
{
convenience init(localizedTitle: String, action: DeepLink.Action)
{
var userInfo: [AnyHashable: Any]?
var userInfo: [String: NSSecureCoding]?
switch action
{
case .launchGame(let identifier): userInfo = [DeepLink.Key.identifier.rawValue: identifier]
case .launchGame(let identifier): userInfo = [DeepLink.Key.identifier.rawValue: identifier as NSString]
}
self.init(type: action.type.rawValue, localizedTitle: localizedTitle, localizedSubtitle: nil, icon: nil, userInfo: userInfo)

View File

@ -110,7 +110,7 @@ class GameViewController: DeltaCore.GameViewController
private var _isLoadingSaveState = false
private var context = CIContext(options: [kCIContextWorkingColorSpace: NSNull()])
private var context = CIContext(options: convertToOptionalCIContextOptionDictionary([convertFromCIContextOption(CIContextOption.workingColorSpace): NSNull()]))
// Sustain Buttons
private var isSelectingSustainedButtons = false
@ -140,7 +140,7 @@ class GameViewController: DeltaCore.GameViewController
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.updateControllers), name: .externalGameControllerDidConnect, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.updateControllers), name: .externalGameControllerDidDisconnect, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.didEnterBackground(with:)), name: .UIApplicationDidEnterBackground, object: UIApplication.shared)
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.didEnterBackground(with:)), name: UIApplication.didEnterBackgroundNotification, object: UIApplication.shared)
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.settingsDidChange(with:)), name: .settingsDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.deepLinkControllerLaunchGame(with:)), name: .deepLinkControllerLaunchGame, object: nil)
}
@ -592,7 +592,7 @@ extension GameViewController: SaveStatesViewControllerDelegate
if
let outputImage = self.gameView.outputImage,
let quartzImage = self.context.createCGImage(outputImage, from: outputImage.extent),
let data = UIImagePNGRepresentation(UIImage(cgImage: quartzImage))
let data = UIImage(cgImage: quartzImage).pngData()
{
do
{
@ -939,7 +939,7 @@ private extension GameViewController
}
else if
let navigationController = self.presentedViewController as? UINavigationController,
let pageViewController = navigationController.topViewController?.childViewControllers.first as? UIPageViewController,
let pageViewController = navigationController.topViewController?.children.first as? UIPageViewController,
let gameCollectionViewController = pageViewController.viewControllers?.first as? GameCollectionViewController
{
let segue = UIStoryboardSegue(identifier: "unwindFromGames", source: gameCollectionViewController, destination: self)
@ -949,3 +949,14 @@ private extension GameViewController
self.dismiss(animated: true, completion: nil)
}
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToOptionalCIContextOptionDictionary(_ input: [String: Any]?) -> [CIContextOption: Any]? {
guard let input = input else { return nil }
return Dictionary(uniqueKeysWithValues: input.map { key, value in (CIContextOption(rawValue: key), value)})
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromCIContextOption(_ input: CIContextOption) -> String {
return input.rawValue
}

View File

@ -529,7 +529,7 @@ extension GameCollectionViewController: ImportControllerDelegate
if
let image = UIImage(data: imageData),
let resizedImage = image.resizing(toFit: CGSize(width: 300, height: 300)),
let resizedData = UIImageJPEGRepresentation(resizedImage, 0.85)
let resizedData = resizedImage.jpegData(compressionQuality: 0.85)
{
let destinationURL = DatabaseManager.artworkURL(for: game)
try resizedData.write(to: destinationURL, options: .atomic)
@ -661,7 +661,7 @@ extension GameCollectionViewController: UICollectionViewDelegateFlowLayout
self.configure(self.prototypeCell, for: indexPath)
let size = self.prototypeCell.contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
let size = self.prototypeCell.contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
return size
}
}

View File

@ -39,9 +39,12 @@ class PhotoLibraryImportOption: NSObject, ImportOption
extension PhotoLibraryImportOption: UIImagePickerControllerDelegate, UINavigationControllerDelegate
{
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any])
{
guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage, let data = UIImageJPEGRepresentation(image, 0.85) else {
// Local variable inserted by Swift 4.2 migrator.
let info = convertFromUIImagePickerControllerInfoKeyDictionary(info)
guard let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage)] as? UIImage, let data = image.jpegData(compressionQuality: 0.85) else {
self.completionHandler?([])
return
}
@ -59,3 +62,13 @@ extension PhotoLibraryImportOption: UIImagePickerControllerDelegate, UINavigatio
}
}
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromUIImagePickerControllerInfoKeyDictionary(_ input: [UIImagePickerController.InfoKey: Any]) -> [String: Any] {
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromUIImagePickerControllerInfoKey(_ input: UIImagePickerController.InfoKey) -> String {
return input.rawValue
}

View File

@ -26,7 +26,7 @@ class LaunchViewController: UIViewController
return self.gameViewController?.prefersStatusBarHidden ?? false
}
override func childViewControllerForHomeIndicatorAutoHidden() -> UIViewController? {
override var childForHomeIndicatorAutoHidden: UIViewController? {
return self.gameViewController
}
@ -47,7 +47,7 @@ class LaunchViewController: UIViewController
func showGameViewController()
{
self.view.bringSubview(toFront: self.gameViewContainerView)
self.view.bringSubviewToFront(self.gameViewContainerView)
self.setNeedsStatusBarAppearanceUpdate()

View File

@ -13,9 +13,9 @@ import DeltaCore
import Roxas
private extension NSAttributedStringKey
private extension NSAttributedString.Key
{
static let cheatPrefix = NSAttributedStringKey("CheatPrefix")
static let cheatPrefix = NSAttributedString.Key("CheatPrefix")
}
class CheatTextView: UITextView

View File

@ -181,7 +181,7 @@ extension CheatsViewController
return [deleteAction, editAction]
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)
{
// This method intentionally left blank because someone decided it was a Good Idea to require this method be implemented to use UITableViewRowActions
}

View File

@ -382,7 +382,7 @@ extension EditCheatViewController: UITextViewDelegate
// We need to manually add back the attributes when manually modifying the underlying text storage
// Otherwise, pasting text into an empty text view will result in the wrong font being used
let attributes = Dictionary(uniqueKeysWithValues: textView.typingAttributes.map { (key, value) in (NSAttributedStringKey(key), value) })
let attributes = Dictionary(uniqueKeysWithValues: convertFromNSAttributedStringKeyDictionary(textView.typingAttributes).map { (key, value) in (NSAttributedString.Key(key), value) })
let attributedString = NSAttributedString(string: sanitizedText, attributes: attributes)
textView.textStorage.replaceCharacters(in: range, with: attributedString)
@ -393,3 +393,8 @@ extension EditCheatViewController: UITextViewDelegate
return false
}
}
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromNSAttributedStringKeyDictionary(_ input: [NSAttributedString.Key: Any]) -> [String: Any] {
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
}

View File

@ -145,7 +145,7 @@ extension GridMenuViewController: UICollectionViewDelegateFlowLayout
{
self.configure(self.prototypeCell, for: indexPath)
let size = self.prototypeCell.contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
let size = self.prototypeCell.contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
return size
}
}

View File

@ -19,7 +19,7 @@ class PauseViewController: UIViewController, PauseInfoProviding
}
var pauseItems: [MenuItem] {
return [self.saveStateItem, self.loadStateItem, self.cheatCodesItem, self.fastForwardItem, self.sustainButtonsItem].flatMap { $0 }
return [self.saveStateItem, self.loadStateItem, self.cheatCodesItem, self.fastForwardItem, self.sustainButtonsItem].compactMap { $0 }
}
/// Pause Items
@ -115,7 +115,7 @@ extension PauseViewController
extension PauseViewController: UINavigationControllerDelegate
{
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
let transitionCoordinator = PauseTransitionCoordinator(presentationController: self.presentationController!)
transitionCoordinator.presenting = (operation == .push)

View File

@ -677,7 +677,7 @@ extension SaveStatesViewController: UICollectionViewDelegateFlowLayout
{
self.configure(self.prototypeCell, for: indexPath)
let size = self.prototypeCell.contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
let size = self.prototypeCell.contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
return size
}
@ -685,7 +685,7 @@ extension SaveStatesViewController: UICollectionViewDelegateFlowLayout
{
self.configure(self.prototypeHeader, forSection: section)
let size = self.prototypeHeader.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
let size = self.prototypeHeader.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
return size
}
}

View File

@ -281,7 +281,7 @@ extension AppIconShortcutsViewController
self.addShortcut(for: game)
}
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)
{
switch editingStyle
{
@ -307,7 +307,7 @@ extension AppIconShortcutsViewController
return NSLocalizedString("Remove", comment: "")
}
override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle
override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle
{
switch indexPath.section
{

View File

@ -224,7 +224,7 @@ private extension ControllerInputsViewController
else { return }
// Implicit assumption that all skins used for controller input mapping don't have multiple items with same input.
let mappedInputs = items.flatMap { $0.inputs.allInputs.flatMap(controllerViewInputMapping.input(forControllerInput:)) } + (self.supportedActionInputs as [Input])
let mappedInputs = items.flatMap { $0.inputs.allInputs.compactMap(controllerViewInputMapping.input(forControllerInput:)) } + (self.supportedActionInputs as [Input])
// Create callout view for each on-screen input.
for input in mappedInputs

View File

@ -307,7 +307,7 @@ extension ControllersSettingsViewController
return 1
}
return UITableViewAutomaticDimension
return UITableView.automaticDimension
}
}

View File

@ -81,7 +81,7 @@ class SettingsViewController: UITableViewController
{
// Update and temporarily re-select selected row.
self.tableView.reloadSections(IndexSet(integer: Section.controllers.rawValue), with: .none)
self.tableView.selectRow(at: indexPath, animated: false, scrollPosition: UITableViewScrollPosition.none)
self.tableView.selectRow(at: indexPath, animated: false, scrollPosition: UITableView.ScrollPosition.none)
}
self.tableView.deselectRow(at: indexPath, animated: true)