Skip to content

Commit 2cbb180

Browse files
authored
App Distro: fix async/await issue (#9634)
* App Distro: fix async/await issue Right now we're calling a completion handler with `nil, nil` when releases are fetched but none are marked as "latest". This shouldn't happen, and is considered an error. * Mark return type as optional * Swfit tests * Remove extra space * Formatting * Style again * SwiftPM tests * Revert version change * [skip ci] Update CHANGELOG
1 parent 5d0cd61 commit 2cbb180

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

FirebaseAppDistribution.podspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ iOS SDK for App Distribution for Firebase.
4343

4444
s.test_spec 'unit' do |unit_tests|
4545
unit_tests.scheme = { :code_coverage => true }
46-
unit_tests.source_files = 'FirebaseAppDistribution/Tests/Unit*/*.[mh]'
46+
unit_tests.source_files = [
47+
'FirebaseAppDistribution/Tests/Unit*/*.[mh]',
48+
'FirebaseAppDistribution/Tests/Unit/Swift*/*.swift',
49+
]
4750
unit_tests.resources = 'FirebaseAppDistribution/Tests/Unit/Resources/*'
4851
unit_tests.dependency 'OCMock'
4952
end

FirebaseAppDistribution/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# v9.0.0-beta
2-
- [fixed] Marked `releaseNotes` as `nullable` as they don't always exist. (#8602)
2+
- [fixed] Marked `releaseNotes` as `nullable` as they don't always exist (#8602).
3+
- [fixed] **Breaking change:** Fixed an ObjC-to-Swift API conversion error where`checkForUpdate()`
4+
returned a non-optional type. This change is breaking for Swift users only (#9604).
35

46
# v8.3.0-beta
57
- [changed] Sign out the Tester when the call to fetch releases fails with an unauthorized error (#8270).

FirebaseAppDistribution/Sources/Public/FirebaseAppDistribution/FIRAppDistribution.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ NS_SWIFT_NAME(AppDistribution)
4646
/**
4747
* Check to see whether a new distribution is available
4848
*/
49-
- (void)checkForUpdateWithCompletion:
50-
(void (^)(FIRAppDistributionRelease *_Nullable release, NSError *_Nullable error))completion
49+
- (void)checkForUpdateWithCompletion:(void (^)(FIRAppDistributionRelease *_Nullable_result release,
50+
NSError *_Nullable error))completion
5151
NS_SWIFT_NAME(checkForUpdate(completion:));
5252

5353
/**
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import XCTest
16+
@testable import FirebaseAppDistribution
17+
18+
class AppDistributionAPITests: XCTestCase {
19+
@available(iOS 13.0.0, *)
20+
func asyncAPIs() async throws {
21+
let distro = AppDistribution.appDistribution()
22+
23+
// Release should be optional if there are no new releases.
24+
let _: AppDistributionRelease? = try await distro.checkForUpdate()
25+
try await distro.signInTester()
26+
}
27+
}

Package.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,20 @@ let package = Package(
410410
name: "AppDistributionUnit",
411411
dependencies: ["FirebaseAppDistribution", "OCMock"],
412412
path: "FirebaseAppDistribution/Tests/Unit",
413+
exclude: ["Swift/"],
413414
resources: [.process("Resources")],
414415
cSettings: [
415416
.headerSearchPath("../../.."),
416417
]
417418
),
419+
.testTarget(
420+
name: "AppDistributionUnitSwift",
421+
dependencies: ["FirebaseAppDistribution"],
422+
path: "FirebaseAppDistribution/Tests/Unit/Swift",
423+
cSettings: [
424+
.headerSearchPath("../../../.."),
425+
]
426+
),
418427

419428
.target(
420429
name: "FirebaseAuth",

0 commit comments

Comments
 (0)