Skip to content

Update Swift sample to Swift 5 #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions FirebaseUI.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |s|
s.name = 'FirebaseUI'
s.version = '7.0.0'
s.version = '8.0.0'
s.summary = 'UI binding libraries for Firebase.'
s.homepage = 'https://github.com/firebase/FirebaseUI-iOS'
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
s.source = { :git => 'https://github.com/firebase/FirebaseUI-iOS.git', :tag => 'v' + s.version.to_s }
s.source = { :git => 'https://github.com/firebase/FirebaseUI-iOS.git', :tag => 'v'}
s.author = 'Firebase'
s.platform = :ios
s.ios.deployment_target = '9.0'
Expand Down
22 changes: 15 additions & 7 deletions samples/swift/FirebaseUI-demo-swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
8DABC9871D3D82D600453807 /* FirebaseUI-demo-swift */,
8DABC99C1D3D82D600453807 /* FirebaseUI-demo-swiftTests */,
8DABC9861D3D82D600453807 /* Products */,
B9817BB8ABCEED12F89E5CF6 /* Pods */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -236,6 +237,13 @@
path = "FirebaseUI-demo-swiftTests";
sourceTree = "<group>";
};
B9817BB8ABCEED12F89E5CF6 /* Pods */ = {
isa = PBXGroup;
children = (
);
path = Pods;
sourceTree = "<group>";
};
C302C1D31D91CC7B00ADBD41 /* Samples */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -340,7 +348,7 @@
TargetAttributes = {
8DABC9841D3D82D600453807 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1020;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand All @@ -352,14 +360,14 @@
};
8DABC9981D3D82D600453807 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1020;
TestTargetID = 8DABC9841D3D82D600453807;
};
};
};
buildConfigurationList = 8DABC9801D3D82D600453807 /* Build configuration list for PBXProject "FirebaseUI-demo-swift" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -770,7 +778,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -808,7 +816,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.google.firebase.firebaseui.FirebaseUI-demo-swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -820,7 +828,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.firebase.FirebaseUI-demo-swiftTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirebaseUI-demo-swift.app/FirebaseUI-demo-swift";
};
name = Debug;
Expand All @@ -833,7 +841,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.firebase.FirebaseUI-demo-swiftTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirebaseUI-demo-swift.app/FirebaseUI-demo-swift";
};
name = Release;
Expand Down
6 changes: 3 additions & 3 deletions samples/swift/FirebaseUI-demo-swift/FUIAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Successfully running this sample requires an app in Firebase and an
// accompanying valid GoogleService-Info.plist file.
FirebaseApp.configure()
Expand All @@ -33,8 +33,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

@available(iOS 9.0, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String?
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
let sourceApplication = options[UIApplication.OpenURLOptionsKey.sourceApplication] as! String?
return self.handleOpenUrl(url, sourceApplication: sourceApplication)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class FUIAuthViewController: UITableViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.rowHeight = UITableView.automaticDimension;
self.tableView.estimatedRowHeight = 240;

self.authStateDidChangeHandle =
Expand All @@ -116,7 +116,7 @@ class FUIAuthViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
return UITableView.automaticDimension
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import UIKit
import FirebaseUI

@objc(FUICustomAuthPickerViewController)

class FUICustomAuthPickerViewController: FUIAuthPickerViewController {

@IBAction func onClose(_ sender: AnyObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class FUICustomAuthDelegate: NSObject, FUIAuthDelegate {
return FUICustomPasswordSignUpViewController(nibName: "FUICustomPasswordSignUpViewController",
bundle: Bundle.main,
authUI: authUI,
email: email)
email: email,
requireDisplayName: true)
}

func passwordVerificationViewController(forAuthUI authUI: FUIAuth, email: String, newCredential: AuthCredential) -> FUIPasswordVerificationViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import UIKit
import FirebaseUI

@objc(FUICustomEmailEntryViewController)

class FUICustomEmailEntryViewController: FUIEmailEntryViewController, UITextFieldDelegate {
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var nextButton: UIBarButtonItem!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import UIKit
import FirebaseUI

@objc(FUICustomPasswordRecoveryViewController)

class FUICustomPasswordRecoveryViewController: FUIPasswordRecoveryViewController, UITextFieldDelegate {
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var recoverButton: UIBarButtonItem!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import UIKit
import FirebaseUI

@objc(FUICustomPasswordSignInViewController)

class FUICustomPasswordSignInViewController: FUIPasswordSignInViewController {
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@
import UIKit
import FirebaseUI

@objc(FUICustomPasswordSignUpViewController)

class FUICustomPasswordSignUpViewController: FUIPasswordSignUpViewController, UITextFieldDelegate {

@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var nextButton: UIBarButtonItem!

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?, authUI: FUIAuth, email: String?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil, authUI: authUI, email: email)

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?, authUI: FUIAuth, email: String?, requireDisplayName: Bool) {
super.init(nibName: nibNameOrNil,
bundle: nibBundleOrNil,
authUI: authUI,
email: email,
requireDisplayName: requireDisplayName)

emailTextField.text = email
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import UIKit
import FirebaseUI
import FirebaseAuth

@objc(FUICustomPasswordVerificationViewController)

class FUICustomPasswordVerificationViewController: FUIPasswordVerificationViewController, UITextFieldDelegate {
fileprivate(set) var userEmail: String

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ChatCollectionViewCell: UICollectionViewCell {
}

static func boundingRectForText(_ text: String, maxWidth: CGFloat) -> CGRect {
let attributes = [NSFontAttributeName: ChatCollectionViewCell.messageFont]
let attributes = [NSAttributedString.Key.font: ChatCollectionViewCell.messageFont]
let rect = text.boundingRect(with: CGSize(width: maxWidth, height: CGFloat.greatestFiniteMagnitude),
options: [.usesLineFragmentOrigin],
attributes: attributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ class ChatViewController: UIViewController, UICollectionViewDelegateFlowLayout {
// Notification boilerplate to handle keyboard appearance/disappearance
NotificationCenter.default.addObserver(self,
selector: #selector(keyboardWillShow),
name: NSNotification.Name.UIKeyboardWillShow,
name: UIResponder.keyboardWillShowNotification,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(keyboardWillHide),
name: NSNotification.Name.UIKeyboardWillHide,
name: UIResponder.keyboardWillHideNotification,
object: nil)
}

@objc fileprivate func didTapSend(_ sender: AnyObject) {
guard let user = self.auth.currentUser else { return }
let uid = user.uid
let name = "User " + uid[uid.characters.startIndex..<uid.characters.index(uid.characters.startIndex, offsetBy: 6)]
let name = "User " + uid[uid.startIndex..<uid.index(uid.startIndex, offsetBy: 6)]
let _text = self.textView.text as String?
guard let text = _text else { return }
if (text.isEmpty) { return }
Expand Down Expand Up @@ -142,13 +142,13 @@ class ChatViewController: UIViewController, UICollectionViewDelegateFlowLayout {

@objc fileprivate func keyboardWillShow(_ notification: Notification) {
let userInfo = (notification as NSNotification).userInfo!
let endFrameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue
let endFrameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue
let endHeight = endFrameValue.cgRectValue.size.height

self.bottomConstraint.constant = endHeight

let curve = UIViewAnimationCurve(rawValue: userInfo[UIKeyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as! Double
let curve = UIView.AnimationCurve(rawValue: userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double

UIView.setAnimationCurve(curve)
UIView.animate(withDuration: duration, animations: {
Expand All @@ -160,8 +160,8 @@ class ChatViewController: UIViewController, UICollectionViewDelegateFlowLayout {
self.bottomConstraint.constant = 6

let userInfo = (notification as NSNotification).userInfo!
let curve = UIViewAnimationCurve(rawValue: userInfo[UIKeyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as! Double
let curve = UIView.AnimationCurve(rawValue: userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double

UIView.setAnimationCurve(curve)
UIView.animate(withDuration: duration, animations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SampleCell: UITableViewCell {
@IBOutlet fileprivate var titleLabel: UILabel!
@IBOutlet fileprivate var subtitleLabel: UILabel!

override convenience init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override convenience init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
self.init(reuseIdentifier: reuseIdentifier!)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SamplesViewController: UIViewController, UITableViewDelegate, UITableViewD

// self-sizing cells
self.tableView.estimatedRowHeight = 85
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.rowHeight = UITableView.automaticDimension
}

// MARK: - UITableView Delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class StorageViewController: UIViewController {
// Notification boilerplate to handle keyboard appearance/disappearance
NotificationCenter.default.addObserver(self,
selector: #selector(keyboardWillShow),
name: NSNotification.Name.UIKeyboardWillShow,
name: UIResponder.keyboardWillShowNotification,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(keyboardWillHide),
name: NSNotification.Name.UIKeyboardWillHide,
name: UIResponder.keyboardWillHideNotification,
object: nil)
}

Expand All @@ -64,13 +64,13 @@ class StorageViewController: UIViewController {

@objc fileprivate func keyboardWillShow(_ notification: Notification) {
let userInfo = (notification as NSNotification).userInfo!
let endFrameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue
let endFrameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue
let endHeight = endFrameValue.cgRectValue.size.height

self.bottomConstraint.constant = endHeight

let curve = UIViewAnimationCurve(rawValue: userInfo[UIKeyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as! Double
let curve = UIView.AnimationCurve(rawValue: userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double

UIView.setAnimationCurve(curve)
UIView.animate(withDuration: duration, animations: {
Expand All @@ -82,8 +82,8 @@ class StorageViewController: UIViewController {
self.bottomConstraint.constant = 0

let userInfo = (notification as NSNotification).userInfo!
let curve = UIViewAnimationCurve(rawValue: userInfo[UIKeyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as! Double
let curve = UIView.AnimationCurve(rawValue: userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as! Int)!
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! Double

UIView.setAnimationCurve(curve)
UIView.animate(withDuration: duration, animations: {
Expand Down
Loading