Unverified Commit e4760e69 authored by Zach Knox's avatar Zach Knox
Browse files

Swift 4.2!

parent 3467e34f
...@@ -34,9 +34,9 @@ Requirements: ...@@ -34,9 +34,9 @@ Requirements:
To get started, you'll need the following installed: To get started, you'll need the following installed:
* [Git](http://git-scm.com/book/en/Getting-Started-Installing-Git) * [Git](http://git-scm.com/book/en/Getting-Started-Installing-Git)
* The latest **public** build of [Xcode](https://developer.apple.com/xcode/) (and a compatible Mac). *Currently Xcode 9* (You can get this from the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12) if you want easy updates) * The latest **public** build of [Xcode](https://developer.apple.com/xcode/) (and a compatible Mac). *Currently Xcode 10* (You can get this from the [Mac App Store](https://itunes.apple.com/us/app/xcode/id497799835?mt=12) if you want easy updates)
* The latest **public** release of Swift. *Currently Swift 4.0* (bundled with Xcode) * The latest **public** release of Swift. *Currently Swift 4.2* (bundled with Xcode)
* Cocoapods, for dependency management. You can install this by running `sudo gem install cocoapods` in your terminal. (Dependency management may change in the future) * Cocoapods, for dependency management. You can install this by running `sudo gem install cocoapods` in your terminal. (Dependency management may change in the future)
...@@ -61,6 +61,7 @@ What Won't Work During Development ...@@ -61,6 +61,7 @@ What Won't Work During Development
--- ---
- Crashlytics won't load in under the "WhatsOpen" Scheme. Use Xcode's debugger. - Crashlytics won't load in under the "WhatsOpen" Scheme. Use Xcode's debugger.
- Alternate app icons won't work (and will probably crash if you try to use them) due to the build method of adding them to the info.plist file. If you're an artist and have some cool alternate app icons to add, you can still do so in the `AlternateAppIcons.xcassets` file in the main project folder, and adding a cell for them in the SetIconTableViewController. - Alternate app icons won't work (and will probably crash if you try to use them) due to the build method of adding them to the info.plist file. If you're an artist and have some cool alternate app icons to add, you can still do so in the `AlternateAppIcons.xcassets` file in the main project folder, and adding a cell for them in the SetIconTableViewController.
- Any App Extensions will likely be unable to connect to your database, as App Groups used for this require a special entitlement.
Troubleshooting Troubleshooting
--- ---
......
...@@ -374,6 +374,7 @@ ...@@ -374,6 +374,7 @@
}; };
9203CB822023D51A006ACC3B = { 9203CB822023D51A006ACC3B = {
DevelopmentTeam = K5MMVK2UFR; DevelopmentTeam = K5MMVK2UFR;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual; ProvisioningStyle = Manual;
SystemCapabilities = { SystemCapabilities = {
com.apple.SafariKeychain = { com.apple.SafariKeychain = {
...@@ -804,8 +805,7 @@ ...@@ -804,8 +805,7 @@
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "b7d91eb0-1140-4c4c-8a3e-a4b698a70a43"; PROVISIONING_PROFILE = "b7d91eb0-1140-4c4c-8a3e-a4b698a70a43";
PROVISIONING_PROFILE_SPECIFIER = "What's Open Development"; PROVISIONING_PROFILE_SPECIFIER = "What's Open Development";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.2;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
...@@ -835,8 +835,7 @@ ...@@ -835,8 +835,7 @@
PROVISIONING_PROFILE = "b7d91eb0-1140-4c4c-8a3e-a4b698a70a43"; PROVISIONING_PROFILE = "b7d91eb0-1140-4c4c-8a3e-a4b698a70a43";
PROVISIONING_PROFILE_SPECIFIER = "What's Open Development"; PROVISIONING_PROFILE_SPECIFIER = "What's Open Development";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.2;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
...@@ -868,8 +867,7 @@ ...@@ -868,8 +867,7 @@
PROVISIONING_PROFILE = "b7d91eb0-1140-4c4c-8a3e-a4b698a70a43"; PROVISIONING_PROFILE = "b7d91eb0-1140-4c4c-8a3e-a4b698a70a43";
PROVISIONING_PROFILE_SPECIFIER = "What's Open Development"; PROVISIONING_PROFILE_SPECIFIER = "What's Open Development";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.2;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
......
...@@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
#if APPSTORE #if APPSTORE
...@@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true return true
} }
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
dump(userActivity.userInfo) dump(userActivity.userInfo)
if userActivity.activityType == NSUserActivityTypeBrowsingWeb { if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let _ = userActivity.webpageURL let _ = userActivity.webpageURL
......
...@@ -19,17 +19,17 @@ class PaddedUILabel: UILabel { ...@@ -19,17 +19,17 @@ class PaddedUILabel: UILabel {
} }
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect { override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
let insetRect = UIEdgeInsetsInsetRect(bounds, textInsets) let insetRect = bounds.inset(by: textInsets)
let textRect = super.textRect(forBounds: insetRect, limitedToNumberOfLines: numberOfLines) let textRect = super.textRect(forBounds: insetRect, limitedToNumberOfLines: numberOfLines)
let invertedInsets = UIEdgeInsets(top: -textInsets.top, let invertedInsets = UIEdgeInsets(top: -textInsets.top,
left: -textInsets.left, left: -textInsets.left,
bottom: -textInsets.bottom, bottom: -textInsets.bottom,
right: -textInsets.right) right: -textInsets.right)
return UIEdgeInsetsInsetRect(textRect, invertedInsets) return textRect.inset(by: invertedInsets)
} }
override func drawText(in rect: CGRect) { override func drawText(in rect: CGRect) {
super.drawText(in: UIEdgeInsetsInsetRect(rect, textInsets)) super.drawText(in: rect.inset(by: textInsets))
} }
} }
......
...@@ -87,8 +87,8 @@ class AboutScreenViewController: UIViewController, UITableViewDelegate, UITableV ...@@ -87,8 +87,8 @@ class AboutScreenViewController: UIViewController, UITableViewDelegate, UITableV
switch indexPath.section { switch indexPath.section {
case 0: case 0:
cell.textLabel!.text = "Check out our code on Gitlab" cell.textLabel!.text = "Check out our code on Gitlab"
cell.selectionStyle = UITableViewCellSelectionStyle.blue cell.selectionStyle = UITableViewCell.SelectionStyle.blue
cell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator
case 1: case 1:
cell.textLabel!.text = contributors[indexPath.row] cell.textLabel!.text = contributors[indexPath.row]
default: default:
......
...@@ -40,19 +40,19 @@ class DetailViewButtonsViewController: UIViewController { ...@@ -40,19 +40,19 @@ class DetailViewButtonsViewController: UIViewController {
if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) { if appToUse == "Google Maps" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
if let url = URL(string: "comgooglemaps://?q=\((facility.facilityLocation?.coordinates?.coords?.last)!)),\((facility.facilityLocation?.coordinates?.coords?.first)!)") { if let url = URL(string: "comgooglemaps://?q=\((facility.facilityLocation?.coordinates?.coords?.last)!)),\((facility.facilityLocation?.coordinates?.coords?.first)!)") {
UIApplication.shared.open(url, options: [:], completionHandler: nil) UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
} }
} }
else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) { else if appToUse == "Waze" && UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
if let url = URL(string: "https://waze.com/ul?ll=\((facility.facilityLocation?.coordinates?.coords?.last)!)),\((facility.facilityLocation?.coordinates?.coords?.first)!))") { if let url = URL(string: "https://waze.com/ul?ll=\((facility.facilityLocation?.coordinates?.coords?.last)!)),\((facility.facilityLocation?.coordinates?.coords?.first)!))") {
UIApplication.shared.open(url, options: [:], completionHandler: nil) UIApplication.shared.open(url, options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
} }
} }
else { else {
let regionDistance:CLLocationDistance = 100 let regionDistance:CLLocationDistance = 100
let coordinates = CLLocationCoordinate2DMake((facility.facilityLocation?.coordinates?.coords?.last)!, (facility.facilityLocation?.coordinates?.coords?.first)!) let coordinates = CLLocationCoordinate2DMake((facility.facilityLocation?.coordinates?.coords?.last)!, (facility.facilityLocation?.coordinates?.coords?.first)!)
dump(coordinates) dump(coordinates)
let regionSpan = MKCoordinateRegionMakeWithDistance(coordinates, regionDistance, regionDistance) let regionSpan = MKCoordinateRegion.init(center: coordinates, latitudinalMeters: regionDistance, longitudinalMeters: regionDistance)
let options = [ let options = [
MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center), MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: regionSpan.center),
MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span) MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: regionSpan.span)
...@@ -90,7 +90,7 @@ class DetailViewButtonsViewController: UIViewController { ...@@ -90,7 +90,7 @@ class DetailViewButtonsViewController: UIViewController {
// Dealing with container views and subviews // Dealing with container views and subviews
// https://spin.atomicobject.com/2015/10/13/switching-child-view-controllers-ios-auto-layout/ // https://spin.atomicobject.com/2015/10/13/switching-child-view-controllers-ios-auto-layout/
self.detailViewController!.view.translatesAutoresizingMaskIntoConstraints = false self.detailViewController!.view.translatesAutoresizingMaskIntoConstraints = false
self.addChildViewController(self.detailViewController!) self.addChild(self.detailViewController!)
self.addSubview(self.detailViewController!.view, toView: self.facilityDetailView) self.addSubview(self.detailViewController!.view, toView: self.facilityDetailView)
super.viewDidLoad() super.viewDidLoad()
...@@ -150,3 +150,8 @@ class DetailViewButtonsViewController: UIViewController { ...@@ -150,3 +150,8 @@ class DetailViewButtonsViewController: UIViewController {
*/ */
} }
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
...@@ -100,7 +100,7 @@ class FilterSelectionTableViewController: UITableViewController { ...@@ -100,7 +100,7 @@ class FilterSelectionTableViewController: UITableViewController {
else { else {
let tableCell = tableView.cellForRow(at: indexPath) let tableCell = tableView.cellForRow(at: indexPath)
var res: Bool var res: Bool
if(tableCell?.accessoryType == UITableViewCellAccessoryType.none) { if(tableCell?.accessoryType == UITableViewCell.AccessoryType.none) {
res = true res = true
} }
else { else {
......
...@@ -57,7 +57,7 @@ class FiltersTableViewController: UITableViewController { ...@@ -57,7 +57,7 @@ class FiltersTableViewController: UITableViewController {
super.viewDidLoad() super.viewDidLoad()
tableView.estimatedRowHeight = 50 tableView.estimatedRowHeight = 50
tableView.rowHeight = UITableViewAutomaticDimension tableView.rowHeight = UITableView.automaticDimension
/* /*
for f in facilities { for f in facilities {
if(!allLocations.contains(f.facilityLocation!)) { if(!allLocations.contains(f.facilityLocation!)) {
......
...@@ -294,7 +294,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate, ...@@ -294,7 +294,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
super.viewDidLoad() super.viewDidLoad()
let nc = NotificationCenter.default let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(anyRefresh(_:)), name: .UIApplicationWillEnterForeground, object: nil) nc.addObserver(self, selector: #selector(anyRefresh(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
self.definesPresentationContext = true self.definesPresentationContext = true
...@@ -308,7 +308,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate, ...@@ -308,7 +308,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
settingsButton.accessibilityLabel = "Settings" settingsButton.accessibilityLabel = "Settings"
LocationsListLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10) LocationsListLayout.sectionInset = UIEdgeInsets.init(top: 10, left: 10, bottom: 10, right: 10)
refreshControl.addTarget(self, action: #selector(forceRefresh(_:)), for: .valueChanged) refreshControl.addTarget(self, action: #selector(forceRefresh(_:)), for: .valueChanged)
LocationsList.refreshControl = refreshControl LocationsList.refreshControl = refreshControl
...@@ -904,7 +904,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate, ...@@ -904,7 +904,7 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
// Get the new view controller using segue.destinationViewController. // Get the new view controller using segue.destinationViewController.
if(segue.identifier == "toDetailView") { if(segue.identifier == "toDetailView") {
let destination = segue.destination as! PullingViewController let destination = segue.destination as! PullingViewController
var destChild = destination.childViewControllers[0] as! FacilityDetailViewController var destChild = destination.children[0] as! FacilityDetailViewController
destChild = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! FacilityDetailViewController destChild = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! FacilityDetailViewController
let destDelegate = DeckTransitioningDelegate() let destDelegate = DeckTransitioningDelegate()
destination.transitioningDelegate = destDelegate destination.transitioningDelegate = destDelegate
......
...@@ -30,7 +30,7 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab ...@@ -30,7 +30,7 @@ class FacilityDetailViewController: UIViewController, UITableViewDelegate, UITab
else { else {
title = "Add to Favorites" title = "Add to Favorites"
} }
let favoritePreviewItem = UIPreviewAction(title: title, style: UIPreviewActionStyle.default, handler: markAsFavoritePreviewAction) let favoritePreviewItem = UIPreviewAction(title: title, style: UIPreviewAction.Style.default, handler: markAsFavoritePreviewAction)
return [favoritePreviewItem] return [favoritePreviewItem]
} }
......
...@@ -26,7 +26,7 @@ class PullingViewController: UIViewController { ...@@ -26,7 +26,7 @@ class PullingViewController: UIViewController {
// Dealing with container views and subviews // Dealing with container views and subviews
// https://spin.atomicobject.com/2015/10/13/switching-child-view-controllers-ios-auto-layout/ // https://spin.atomicobject.com/2015/10/13/switching-child-view-controllers-ios-auto-layout/
self.currentViewController!.view.translatesAutoresizingMaskIntoConstraints = false self.currentViewController!.view.translatesAutoresizingMaskIntoConstraints = false
self.addChildViewController(self.currentViewController!) self.addChild(self.currentViewController!)
self.addSubview(self.currentViewController!.view, toView: self.containerView) self.addSubview(self.currentViewController!.view, toView: self.containerView)
self.accessibilityCustomActions = [ self.accessibilityCustomActions = [
UIAccessibilityCustomAction(name: "Dismiss Detail View", target: self, selector: #selector(PullingViewController.willDismiss)) UIAccessibilityCustomAction(name: "Dismiss Detail View", target: self, selector: #selector(PullingViewController.willDismiss))
......
...@@ -29,7 +29,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr ...@@ -29,7 +29,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
super.viewDidLoad() super.viewDidLoad()
tableView.estimatedRowHeight = 44.0 tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension tableView.rowHeight = UITableView.automaticDimension
// Uncomment the following line to preserve selection between presentations // Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false // self.clearsSelectionOnViewWillAppear = false
...@@ -196,7 +196,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr ...@@ -196,7 +196,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
let urlString = "itms-apps://itunes.apple.com/us/app/whats-open-at-mason/id\(appId)?action=write-review" let urlString = "itms-apps://itunes.apple.com/us/app/whats-open-at-mason/id\(appId)?action=write-review"
if let url = URL(string: urlString) { if let url = URL(string: urlString) {
UIApplication.shared.open((url), options: [:], completionHandler: nil) UIApplication.shared.open((url), options: convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: nil)
} }
} }
else if settingcell.textLabel!.text == "About What's Open" { else if settingcell.textLabel!.text == "About What's Open" {
...@@ -312,3 +312,8 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr ...@@ -312,3 +312,8 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
} }
// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
...@@ -46,10 +46,10 @@ class OnlyOneChecked { ...@@ -46,10 +46,10 @@ class OnlyOneChecked {
func setCheckToCellWithID(_ id: Int) { func setCheckToCellWithID(_ id: Int) {
for cell in view.sortOptions { for cell in view.sortOptions {
if(id == cell.cellIndex) { if(id == cell.cellIndex) {
cell.accessoryType = UITableViewCellAccessoryType.checkmark cell.accessoryType = UITableViewCell.AccessoryType.checkmark
} }
else { else {
cell.accessoryType = UITableViewCellAccessoryType.none cell.accessoryType = UITableViewCell.AccessoryType.none
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment