Skip to content

Commit e9879a6

Browse files
committed
Merge branch 'master' into bs-firebasecore-version
* master: Auto-style swift sources (#847) Fixes clang warnings for Auth (#848) Add build infrastructure for Codable support in Firestore (#815)
2 parents bc9dacf + ac06a94 commit e9879a6

25 files changed

+938
-394
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ before_install:
1313
- bundle exec pod install --project-directory=Example --repo-update
1414
- bundle exec pod install --project-directory=Firestore/Example --no-repo-update
1515
- brew install clang-format
16+
- brew install swiftformat
1617
- brew install cmake
1718
- brew install go # Somehow the build for Abseil requires this.
1819
- echo "$TRAVIS_COMMIT_RANGE"

Example/tvOSSample/tvOSSample/AppDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import FirebaseCore
1717

1818
@UIApplicationMain
1919
class AppDelegate: UIResponder, UIApplicationDelegate {
20-
2120
var window: UIWindow?
2221

2322
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
@@ -26,4 +25,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2625
return true
2726
}
2827
}
29-

Example/tvOSSample/tvOSSample/AuthLoginViewController.swift

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,14 @@ import UIKit
1616
import FirebaseAuth
1717

1818
class AuthLoginViewController: UIViewController {
19+
override func viewDidLoad() {
20+
super.viewDidLoad()
1921

20-
override func viewDidLoad() {
21-
super.viewDidLoad()
22+
// Do any additional setup after loading the view.
23+
}
2224

23-
// Do any additional setup after loading the view.
24-
}
25-
26-
override func didReceiveMemoryWarning() {
27-
super.didReceiveMemoryWarning()
28-
// Dispose of any resources that can be recreated.
29-
}
30-
31-
/*
32-
// MARK: - Navigation
33-
34-
// In a storyboard-based application, you will often want to do a little preparation before navigation
35-
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
36-
// Get the new view controller using segue.destinationViewController.
37-
// Pass the selected object to the new view controller.
38-
}
39-
*/
25+
override func didReceiveMemoryWarning() {
26+
super.didReceiveMemoryWarning()
27+
// Dispose of any resources that can be recreated.
28+
}
4029
}

Example/tvOSSample/tvOSSample/AuthViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ class AuthViewController: UIViewController {
2020
// MARK: - User Interface
2121

2222
/// A stackview containing all of the buttons to providers (Email, OAuth, etc).
23-
@IBOutlet weak var providers: UIStackView!
23+
@IBOutlet var providers: UIStackView!
2424

2525
/// A stackview containing a signed in label and sign out button.
26-
@IBOutlet weak var signedIn: UIStackView!
26+
@IBOutlet var signedIn: UIStackView!
2727

2828
/// A label to display the status for the signed in user.
29-
@IBOutlet weak var signInStatus: UILabel!
29+
@IBOutlet var signInStatus: UILabel!
3030

3131
// MARK: - User Actions
3232

Example/tvOSSample/tvOSSample/DatabaseViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DatabaseViewController: UIViewController {
3030
// MARK: - Interface
3131

3232
/// Label to display the current value.
33-
@IBOutlet weak var currentValue: UILabel!
33+
@IBOutlet var currentValue: UILabel!
3434

3535
// MARK: - User Actions
3636

@@ -65,7 +65,7 @@ class DatabaseViewController: UIViewController {
6565
// Observe the current value, and update the UI every time it changes.
6666
let ref = Database.database().reference(withPath: Constants.databasePath)
6767

68-
ref.observe(.value) { [weak self] (snapshot) in
68+
ref.observe(.value) { [weak self] snapshot in
6969
guard let value = snapshot.value as? Int else {
7070
print("Error grabbing value from Snapshot!")
7171
return

Example/tvOSSample/tvOSSample/EmailLoginViewController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ protocol EmailLoginDelegate {
1919
func emailLogin(_ controller: EmailLoginViewController, signedInAs user: User)
2020
func emailLogin(_ controller: EmailLoginViewController, failedWithError error: Error)
2121
}
22+
2223
class EmailLoginViewController: UIViewController {
2324

2425
// MARK: - Public Properties
@@ -27,15 +28,15 @@ class EmailLoginViewController: UIViewController {
2728

2829
// MARK: - User Interface
2930

30-
@IBOutlet private weak var emailAddress: UITextField!
31-
@IBOutlet private weak var password: UITextField!
31+
@IBOutlet private var emailAddress: UITextField!
32+
@IBOutlet private var password: UITextField!
3233

3334
// MARK: - User Actions
3435

3536
@IBAction func logInButtonHit(_ sender: UIButton) {
3637
guard let (email, password) = validatedInputs() else { return }
3738

38-
Auth.auth().signIn(withEmail: email, password: password) { [unowned self] (user, error) in
39+
Auth.auth().signIn(withEmail: email, password: password) { [unowned self] user, error in
3940
guard let user = user else {
4041
print("Error signing in: \(error!)")
4142
self.delegate?.emailLogin(self, failedWithError: error!)
@@ -50,7 +51,7 @@ class EmailLoginViewController: UIViewController {
5051
@IBAction func signUpButtonHit(_ sender: UIButton) {
5152
guard let (email, password) = validatedInputs() else { return }
5253

53-
Auth.auth().createUser(withEmail: email, password: password) { [unowned self] (user, error) in
54+
Auth.auth().createUser(withEmail: email, password: password) { [unowned self] user, error in
5455
guard let user = user else {
5556
print("Error signing up: \(error!)")
5657
self.delegate?.emailLogin(self, failedWithError: error!)

Example/tvOSSample/tvOSSample/StorageViewController.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class StorageViewController: UIViewController {
3131
case failed(String)
3232

3333
/// Equatable support for UIState.
34-
static func ==(lhs: StorageViewController.UIState, rhs: StorageViewController.UIState) -> Bool {
34+
static func == (lhs: StorageViewController.UIState, rhs: StorageViewController.UIState) -> Bool {
3535
switch (lhs, rhs) {
3636
case (.cleared, .cleared): return true
3737
case (.downloading, .downloading): return true
@@ -52,16 +52,16 @@ class StorageViewController: UIViewController {
5252
// MARK: Interface
5353

5454
/// Image view to display the downloaded image.
55-
@IBOutlet weak var imageView: UIImageView!
55+
@IBOutlet var imageView: UIImageView!
5656

5757
/// The download button.
58-
@IBOutlet weak var downloadButton: UIButton!
58+
@IBOutlet var downloadButton: UIButton!
5959

6060
/// The clear button.
61-
@IBOutlet weak var clearButton: UIButton!
61+
@IBOutlet var clearButton: UIButton!
6262

6363
/// A visual representation of the state.
64-
@IBOutlet weak var stateLabel: UILabel!
64+
@IBOutlet var stateLabel: UILabel!
6565

6666
// MARK: - User Actions
6767

@@ -72,7 +72,7 @@ class StorageViewController: UIViewController {
7272
let storage = Storage.storage()
7373
let ref = storage.reference(withPath: Constants.downloadPath)
7474
// TODO: Show progress bar here using proper API.
75-
let task = ref.getData(maxSize: Constants.maxSize) { [unowned self] (data, error) in
75+
let task = ref.getData(maxSize: Constants.maxSize) { [unowned self] data, error in
7676
guard let data = data else {
7777
self.state = .failed("Error downloading: \(error!.localizedDescription)")
7878
return
@@ -114,7 +114,7 @@ class StorageViewController: UIViewController {
114114
stateLabel.text = "State: Downloading..."
115115

116116
// Download complete, ensure the download button is still off and enable the clear button.
117-
case (_, .downloaded(let image)):
117+
case let (_, .downloaded(image)):
118118
imageView.image = image
119119
stateLabel.text = "State: Image downloaded!"
120120

@@ -124,7 +124,7 @@ class StorageViewController: UIViewController {
124124
stateLabel.text = "State: Pending download"
125125

126126
// An error occurred.
127-
case (_, .failed(let error)):
127+
case let (_, .failed(error)):
128128
stateLabel.text = "State: \(error)"
129129

130130
// For now, as the default, throw a fatal error because it's an unexpected state. This will

Firebase/Auth/Source/AuthProviders/Phone/FIRPhoneAuthProvider.m

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ - (void)verifyPhoneNumber:(NSString *)phoneNumber
166166
FIRAuthURLCallbackMatcher callbackMatcher = ^BOOL(NSURL *_Nullable callbackURL) {
167167
return [self isVerifyAppURL:callbackURL eventID:eventID];
168168
};
169-
[_auth.authURLPresenter presentURL:reCAPTCHAURL
170-
UIDelegate:UIDelegate
171-
callbackMatcher:callbackMatcher
172-
completion:^(NSURL *_Nullable callbackURL,
173-
NSError *_Nullable error) {
169+
[self->_auth.authURLPresenter presentURL:reCAPTCHAURL
170+
UIDelegate:UIDelegate
171+
callbackMatcher:callbackMatcher
172+
completion:^(NSURL *_Nullable callbackURL,
173+
NSError *_Nullable error) {
174174
if (error) {
175175
callBackOnMainThread(nil, error);
176176
return;
@@ -185,7 +185,8 @@ - (void)verifyPhoneNumber:(NSString *)phoneNumber
185185
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:phoneNumber
186186
appCredential:nil
187187
reCAPTCHAToken:reCAPTCHAToken
188-
requestConfiguration:_auth.requestConfiguration];
188+
requestConfiguration:
189+
self->_auth.requestConfiguration];
189190
[FIRAuthBackend sendVerificationCode:request
190191
callback:^(FIRSendVerificationCodeResponse
191192
*_Nullable response, NSError *_Nullable error) {
@@ -361,14 +362,15 @@ - (void)verifyClientAndSendVerificationCodeToPhoneNumber:(NSString *)phoneNumber
361362
[[FIRSendVerificationCodeRequest alloc] initWithPhoneNumber:phoneNumber
362363
appCredential:appCredential
363364
reCAPTCHAToken:nil
364-
requestConfiguration:_auth.requestConfiguration];
365+
requestConfiguration:
366+
self->_auth.requestConfiguration];
365367
[FIRAuthBackend sendVerificationCode:request
366368
callback:^(FIRSendVerificationCodeResponse *_Nullable response,
367369
NSError *_Nullable error) {
368370
if (error) {
369371
if (error.code == FIRAuthErrorCodeInvalidAppCredential) {
370372
if (retryOnInvalidAppCredential) {
371-
[_auth.appCredentialManager clearCredential];
373+
[self->_auth.appCredentialManager clearCredential];
372374
[self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
373375
retryOnInvalidAppCredential:NO
374376
callback:callback];
@@ -404,15 +406,15 @@ - (void)verifyClientWithCompletion:(FIRVerifyClientCallback)completion {
404406
FIRVerifyClientRequest *request =
405407
[[FIRVerifyClientRequest alloc] initWithAppToken:token.string
406408
isSandbox:token.type == FIRAuthAPNSTokenTypeSandbox
407-
requestConfiguration:_auth.requestConfiguration];
409+
requestConfiguration:self->_auth.requestConfiguration];
408410
[FIRAuthBackend verifyClient:request callback:^(FIRVerifyClientResponse *_Nullable response,
409411
NSError *_Nullable error) {
410412
if (error) {
411413
completion(nil, error);
412414
return;
413415
}
414416
NSTimeInterval timeout = [response.suggestedTimeOutDate timeIntervalSinceNow];
415-
[_auth.appCredentialManager
417+
[self->_auth.appCredentialManager
416418
didStartVerificationWithReceipt:response.receipt
417419
timeout:timeout
418420
callback:^(FIRAuthAppCredential *credential) {
@@ -442,8 +444,8 @@ - (void)reCAPTCHAURLWithEventID:(NSString *)eventID completion:(FIRReCAPTCHAURLC
442444
return;
443445
}
444446
NSString *bundleID = [NSBundle mainBundle].bundleIdentifier;
445-
NSString *clienID = _auth.app.options.clientID;
446-
NSString *apiKey = _auth.requestConfiguration.APIKey;
447+
NSString *clienID = self->_auth.app.options.clientID;
448+
NSString *apiKey = self->_auth.requestConfiguration.APIKey;
447449
NSMutableDictionary *urlArguments = [[NSMutableDictionary alloc] initWithDictionary: @{
448450
@"apiKey" : apiKey,
449451
@"authType" : kAuthTypeVerifyApp,
@@ -452,8 +454,8 @@ - (void)reCAPTCHAURLWithEventID:(NSString *)eventID completion:(FIRReCAPTCHAURLC
452454
@"v" : [FIRAuthBackend authUserAgent],
453455
@"eventId" : eventID,
454456
}];
455-
if (_auth.requestConfiguration.languageCode) {
456-
urlArguments[@"hl"] = _auth.requestConfiguration.languageCode;
457+
if (self->_auth.requestConfiguration.languageCode) {
458+
urlArguments[@"hl"] = self->_auth.requestConfiguration.languageCode;
457459
}
458460
NSString *argumentsString = [urlArguments gtm_httpArgumentsString];
459461
NSString *URLString =

0 commit comments

Comments
 (0)