Skip to content

Commit 03511e6

Browse files
authored
Merge pull request #691 from morganchen12/auth
Update Swift sample to Swift 5
2 parents c9d8e28 + 840e1fc commit 03511e6

17 files changed

+174
-167
lines changed

FirebaseUI.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Pod::Spec.new do |s|
22
s.name = 'FirebaseUI'
3-
s.version = '7.0.0'
3+
s.version = '8.0.0'
44
s.summary = 'UI binding libraries for Firebase.'
55
s.homepage = 'https://github.com/firebase/FirebaseUI-iOS'
66
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
7-
s.source = { :git => 'https://github.com/firebase/FirebaseUI-iOS.git', :tag => 'v' + s.version.to_s }
7+
s.source = { :git => 'https://github.com/firebase/FirebaseUI-iOS.git', :tag => 'v'}
88
s.author = 'Firebase'
99
s.platform = :ios
1010
s.ios.deployment_target = '9.0'

samples/swift/FirebaseUI-demo-swift.xcodeproj/project.pbxproj

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
8DABC9871D3D82D600453807 /* FirebaseUI-demo-swift */,
202202
8DABC99C1D3D82D600453807 /* FirebaseUI-demo-swiftTests */,
203203
8DABC9861D3D82D600453807 /* Products */,
204+
B9817BB8ABCEED12F89E5CF6 /* Pods */,
204205
);
205206
sourceTree = "<group>";
206207
};
@@ -236,6 +237,13 @@
236237
path = "FirebaseUI-demo-swiftTests";
237238
sourceTree = "<group>";
238239
};
240+
B9817BB8ABCEED12F89E5CF6 /* Pods */ = {
241+
isa = PBXGroup;
242+
children = (
243+
);
244+
path = Pods;
245+
sourceTree = "<group>";
246+
};
239247
C302C1D31D91CC7B00ADBD41 /* Samples */ = {
240248
isa = PBXGroup;
241249
children = (
@@ -340,7 +348,7 @@
340348
TargetAttributes = {
341349
8DABC9841D3D82D600453807 = {
342350
CreatedOnToolsVersion = 7.3.1;
343-
LastSwiftMigration = 0800;
351+
LastSwiftMigration = 1020;
344352
SystemCapabilities = {
345353
com.apple.BackgroundModes = {
346354
enabled = 1;
@@ -352,14 +360,14 @@
352360
};
353361
8DABC9981D3D82D600453807 = {
354362
CreatedOnToolsVersion = 7.3.1;
355-
LastSwiftMigration = 0800;
363+
LastSwiftMigration = 1020;
356364
TestTargetID = 8DABC9841D3D82D600453807;
357365
};
358366
};
359367
};
360368
buildConfigurationList = 8DABC9801D3D82D600453807 /* Build configuration list for PBXProject "FirebaseUI-demo-swift" */;
361369
compatibilityVersion = "Xcode 3.2";
362-
developmentRegion = English;
370+
developmentRegion = en;
363371
hasScannedForEncodings = 0;
364372
knownRegions = (
365373
en,
@@ -770,7 +778,7 @@
770778
PRODUCT_NAME = "$(TARGET_NAME)";
771779
SWIFT_OBJC_BRIDGING_HEADER = "";
772780
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
773-
SWIFT_VERSION = 3.0;
781+
SWIFT_VERSION = 5.0;
774782
};
775783
name = Debug;
776784
};
@@ -808,7 +816,7 @@
808816
PRODUCT_BUNDLE_IDENTIFIER = "com.google.firebase.firebaseui.FirebaseUI-demo-swift";
809817
PRODUCT_NAME = "$(TARGET_NAME)";
810818
SWIFT_OBJC_BRIDGING_HEADER = "";
811-
SWIFT_VERSION = 3.0;
819+
SWIFT_VERSION = 5.0;
812820
};
813821
name = Release;
814822
};
@@ -820,7 +828,7 @@
820828
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
821829
PRODUCT_BUNDLE_IDENTIFIER = "com.firebase.FirebaseUI-demo-swiftTests";
822830
PRODUCT_NAME = "$(TARGET_NAME)";
823-
SWIFT_VERSION = 3.0;
831+
SWIFT_VERSION = 5.0;
824832
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirebaseUI-demo-swift.app/FirebaseUI-demo-swift";
825833
};
826834
name = Debug;
@@ -833,7 +841,7 @@
833841
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
834842
PRODUCT_BUNDLE_IDENTIFIER = "com.firebase.FirebaseUI-demo-swiftTests";
835843
PRODUCT_NAME = "$(TARGET_NAME)";
836-
SWIFT_VERSION = 3.0;
844+
SWIFT_VERSION = 5.0;
837845
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FirebaseUI-demo-swift.app/FirebaseUI-demo-swift";
838846
};
839847
name = Release;

samples/swift/FirebaseUI-demo-swift/FUIAppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2424

2525
var window: UIWindow?
2626

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

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

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUIAuthViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class FUIAuthViewController: UITableViewController {
9797
override func viewWillAppear(_ animated: Bool) {
9898
super.viewWillAppear(animated)
9999

100-
self.tableView.rowHeight = UITableViewAutomaticDimension;
100+
self.tableView.rowHeight = UITableView.automaticDimension;
101101
self.tableView.estimatedRowHeight = 240;
102102

103103
self.authStateDidChangeHandle =
@@ -116,7 +116,7 @@ class FUIAuthViewController: UITableViewController {
116116
}
117117

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

122122
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomAuthPickerViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import UIKit
1818
import FirebaseUI
1919

20-
@objc(FUICustomAuthPickerViewController)
21-
2220
class FUICustomAuthPickerViewController: FUIAuthPickerViewController {
2321

2422
@IBAction func onClose(_ sender: AnyObject) {

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomAuthUIDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class FUICustomAuthDelegate: NSObject, FUIAuthDelegate {
6363
return FUICustomPasswordSignUpViewController(nibName: "FUICustomPasswordSignUpViewController",
6464
bundle: Bundle.main,
6565
authUI: authUI,
66-
email: email)
66+
email: email,
67+
requireDisplayName: true)
6768
}
6869

6970
func passwordVerificationViewController(forAuthUI authUI: FUIAuth, email: String, newCredential: AuthCredential) -> FUIPasswordVerificationViewController {

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomEmailEntryViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import UIKit
1818
import FirebaseUI
1919

20-
@objc(FUICustomEmailEntryViewController)
21-
2220
class FUICustomEmailEntryViewController: FUIEmailEntryViewController, UITextFieldDelegate {
2321
@IBOutlet weak var emailTextField: UITextField!
2422
@IBOutlet weak var nextButton: UIBarButtonItem!

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomPasswordRecoveryViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import UIKit
1818
import FirebaseUI
1919

20-
@objc(FUICustomPasswordRecoveryViewController)
21-
2220
class FUICustomPasswordRecoveryViewController: FUIPasswordRecoveryViewController, UITextFieldDelegate {
2321
@IBOutlet weak var emailTextField: UITextField!
2422
@IBOutlet weak var recoverButton: UIBarButtonItem!

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomPasswordSignInViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import UIKit
1818
import FirebaseUI
1919

20-
@objc(FUICustomPasswordSignInViewController)
21-
2220
class FUICustomPasswordSignInViewController: FUIPasswordSignInViewController {
2321
@IBOutlet weak var emailTextField: UITextField!
2422
@IBOutlet weak var passwordTextField: UITextField!

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomPasswordSignUpViewController.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@
1717
import UIKit
1818
import FirebaseUI
1919

20-
@objc(FUICustomPasswordSignUpViewController)
21-
2220
class FUICustomPasswordSignUpViewController: FUIPasswordSignUpViewController, UITextFieldDelegate {
2321

2422
@IBOutlet weak var emailTextField: UITextField!
2523
@IBOutlet weak var usernameTextField: UITextField!
2624
@IBOutlet weak var passwordTextField: UITextField!
2725
@IBOutlet weak var nextButton: UIBarButtonItem!
28-
29-
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?, authUI: FUIAuth, email: String?) {
30-
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil, authUI: authUI, email: email)
26+
27+
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?, authUI: FUIAuth, email: String?, requireDisplayName: Bool) {
28+
super.init(nibName: nibNameOrNil,
29+
bundle: nibBundleOrNil,
30+
authUI: authUI,
31+
email: email,
32+
requireDisplayName: requireDisplayName)
3133

3234
emailTextField.text = email
3335
}

samples/swift/FirebaseUI-demo-swift/Samples/Auth/FUICustomPasswordVerificationViewController.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import UIKit
1818
import FirebaseUI
1919
import FirebaseAuth
2020

21-
@objc(FUICustomPasswordVerificationViewController)
22-
2321
class FUICustomPasswordVerificationViewController: FUIPasswordVerificationViewController, UITextFieldDelegate {
2422
fileprivate(set) var userEmail: String
2523

samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatCollectionViewCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ChatCollectionViewCell: UICollectionViewCell {
2626
}
2727

2828
static func boundingRectForText(_ text: String, maxWidth: CGFloat) -> CGRect {
29-
let attributes = [NSFontAttributeName: ChatCollectionViewCell.messageFont]
29+
let attributes = [NSAttributedString.Key.font: ChatCollectionViewCell.messageFont]
3030
let rect = text.boundingRect(with: CGSize(width: maxWidth, height: CGFloat.greatestFiniteMagnitude),
3131
options: [.usesLineFragmentOrigin],
3232
attributes: attributes,

samples/swift/FirebaseUI-demo-swift/Samples/Chat/ChatViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ class ChatViewController: UIViewController, UICollectionViewDelegateFlowLayout {
9191
// Notification boilerplate to handle keyboard appearance/disappearance
9292
NotificationCenter.default.addObserver(self,
9393
selector: #selector(keyboardWillShow),
94-
name: NSNotification.Name.UIKeyboardWillShow,
94+
name: UIResponder.keyboardWillShowNotification,
9595
object: nil)
9696
NotificationCenter.default.addObserver(self,
9797
selector: #selector(keyboardWillHide),
98-
name: NSNotification.Name.UIKeyboardWillHide,
98+
name: UIResponder.keyboardWillHideNotification,
9999
object: nil)
100100
}
101101

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

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

148148
self.bottomConstraint.constant = endHeight
149149

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

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

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

166166
UIView.setAnimationCurve(curve)
167167
UIView.animate(withDuration: duration, animations: {

samples/swift/FirebaseUI-demo-swift/Samples/SampleCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SampleCell: UITableViewCell {
2121
@IBOutlet fileprivate var titleLabel: UILabel!
2222
@IBOutlet fileprivate var subtitleLabel: UILabel!
2323

24-
override convenience init(style: UITableViewCellStyle, reuseIdentifier: String?) {
24+
override convenience init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
2525
self.init(reuseIdentifier: reuseIdentifier!)
2626
}
2727

samples/swift/FirebaseUI-demo-swift/Samples/SamplesViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SamplesViewController: UIViewController, UITableViewDelegate, UITableViewD
3232

3333
// self-sizing cells
3434
self.tableView.estimatedRowHeight = 85
35-
self.tableView.rowHeight = UITableViewAutomaticDimension
35+
self.tableView.rowHeight = UITableView.automaticDimension
3636
}
3737

3838
// MARK: - UITableView Delegate

samples/swift/FirebaseUI-demo-swift/Samples/StorageViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class StorageViewController: UIViewController {
3434
// Notification boilerplate to handle keyboard appearance/disappearance
3535
NotificationCenter.default.addObserver(self,
3636
selector: #selector(keyboardWillShow),
37-
name: NSNotification.Name.UIKeyboardWillShow,
37+
name: UIResponder.keyboardWillShowNotification,
3838
object: nil)
3939
NotificationCenter.default.addObserver(self,
4040
selector: #selector(keyboardWillHide),
41-
name: NSNotification.Name.UIKeyboardWillHide,
41+
name: UIResponder.keyboardWillHideNotification,
4242
object: nil)
4343
}
4444

@@ -64,13 +64,13 @@ class StorageViewController: UIViewController {
6464

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

7070
self.bottomConstraint.constant = endHeight
7171

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

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

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

8888
UIView.setAnimationCurve(curve)
8989
UIView.animate(withDuration: duration, animations: {

0 commit comments

Comments
 (0)