Skip to content

Commit fe967c1

Browse files
Merge branch 'main'
#Conflicts: # FirebaseRemoteConfig/CHANGELOG.md
2 parents cee7374 + c7ceee4 commit fe967c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+890
-304
lines changed

.github/workflows/abtesting.yml

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ jobs:
120120
key: ${{needs.spm-package-resolved.outputs.cache_key}}
121121
- name: Xcode
122122
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
123+
- name: Install visionOS, if needed.
124+
if: matrix.target == 'visionOS'
125+
run: xcodebuild -downloadPlatform visionOS
123126
- name: Initialize xcodebuild
124127
run: scripts/setup_spm_tests.sh
125128
- uses: nick-fields/retry@v3

.github/workflows/auth.yml

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ jobs:
141141
key: ${{needs.spm-package-resolved.outputs.cache_key}}
142142
- name: Xcode
143143
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
144+
- name: Install visionOS, if needed.
145+
if: matrix.target == 'visionOS spm'
146+
run: xcodebuild -downloadPlatform visionOS
144147
- name: Initialize xcodebuild
145148
run: scripts/setup_spm_tests.sh
146149
- uses: nick-fields/retry@v3

.github/workflows/check.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
check:
1616
# Don't run on private repo.
1717
if: github.repository == 'Firebase/firebase-ios-sdk'
18-
runs-on: macos-14
18+
runs-on: ubuntu-latest
1919
env:
2020
MINT_PATH: ${{ github.workspace }}/mint
2121
steps:
@@ -33,7 +33,13 @@ jobs:
3333
restore-keys: ${{ runner.os }}-mint-
3434

3535
- name: Setup check
36-
run: scripts/setup_check.sh
36+
run: |
37+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
38+
scripts/setup_check.sh
3739
3840
- name: Check
39-
run: scripts/check.sh --test-only
41+
run: |
42+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
43+
# Add Homebrew clang-format to first in PATH
44+
export PATH="/home/linuxbrew/.linuxbrew/opt/clang-format/bin:$PATH"
45+
scripts/check.sh --test-only

.github/workflows/core.yml

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ jobs:
101101
key: ${{needs.spm-package-resolved.outputs.cache_key}}
102102
- name: Xcode
103103
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
104+
- name: Install visionOS, if needed.
105+
if: matrix.target == 'visionOS'
106+
run: xcodebuild -downloadPlatform visionOS
104107
- name: Initialize xcodebuild
105108
run: scripts/setup_spm_tests.sh
106109
- name: Unit Tests

.github/workflows/crashlytics.yml

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ jobs:
116116
key: ${{needs.spm-package-resolved.outputs.cache_key}}
117117
- name: Xcode
118118
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
119+
- name: Install visionOS, if needed.
120+
if: matrix.target == 'visionOS'
121+
run: xcodebuild -downloadPlatform visionOS
119122
- name: Initialize xcodebuild
120123
run: scripts/setup_spm_tests.sh
121124
- uses: nick-fields/retry@v3

.github/workflows/generate_issues.yml

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
schedule:
99
# Run every day at 4am (PST) - cron uses UTC times
1010
- cron: '0 12 * * *'
11+
12+
permissions:
13+
issues: write
14+
1115
jobs:
1216
generate_an_issue:
1317
# Don't run on private repo.

.github/workflows/mlmodeldownloader.yml

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ jobs:
131131
key: ${{needs.spm-package-resolved.outputs.cache_key}}
132132
- name: Xcode
133133
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
134+
- name: Install visionOS, if needed.
135+
if: matrix.target == 'visionOS'
136+
run: xcodebuild -downloadPlatform visionOS
134137
- name: Initialize xcodebuild
135138
run: scripts/setup_spm_tests.sh
136139
- name: Unit Tests

.github/workflows/remoteconfig.yml

+3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ jobs:
155155
key: ${{needs.spm-package-resolved.outputs.cache_key}}
156156
- name: Xcode
157157
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
158+
- name: Install visionOS, if needed.
159+
if: matrix.target == 'visionOS'
160+
run: xcodebuild -downloadPlatform visionOS
158161
- name: Initialize xcodebuild
159162
run: scripts/setup_spm_tests.sh
160163
- name: Unit Tests

.github/workflows/sessions.yml

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ jobs:
111111
key: ${{needs.spm-package-resolved.outputs.cache_key}}
112112
- name: Xcode
113113
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
114+
- name: Install visionOS, if needed.
115+
if: matrix.target == 'visionOS'
116+
run: xcodebuild -downloadPlatform visionOS
114117
- name: Initialize xcodebuild
115118
run: scripts/setup_spm_tests.sh
116119
- uses: nick-fields/retry@v3

.github/workflows/vertexai.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ jobs:
8181
run: scripts/update_vertexai_responses.sh
8282
- name: Xcode
8383
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
84+
- name: Install visionOS, if needed.
85+
if: matrix.target == 'visionOS'
86+
run: xcodebuild -downloadPlatform visionOS
8487
- name: Initialize xcodebuild
8588
run: scripts/setup_spm_tests.sh
8689
- uses: nick-fields/retry@v3
@@ -137,11 +140,10 @@ jobs:
137140
xcode: Xcode_16.2
138141
swift_version: 5.9
139142
warnings:
140-
#TODO: Fix remaining warning in GenerativeAIService and remove --allow-warnings.
141143
- os: macos-15
142144
xcode: Xcode_16.2
143145
swift_version: 6.0
144-
warnings: --allow-warnings
146+
warnings:
145147
runs-on: ${{ matrix.os }}
146148
steps:
147149
- uses: actions/checkout@v4

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ To develop Firebase software, **install**:
132132
To install [clang-format] and [mint] using [Homebrew]:
133133

134134
```console
135-
brew install clang-format@19
135+
brew install clang-format@20
136136
brew install mint
137137
```
138138

Crashlytics/Crashlytics/Components/FIRCLSApplication.h

-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ UIApplication* FIRCLSApplicationSharedInstance(void);
8383
id FIRCLSApplicationSharedInstance(void);
8484
#endif
8585

86-
void FIRCLSApplicationOpenURL(NSURL* url,
87-
NSExtensionContext* extensionContext,
88-
void (^completionBlock)(BOOL success));
89-
9086
id<NSObject> FIRCLSApplicationBeginActivity(NSActivityOptions options, NSString* reason);
9187
void FIRCLSApplicationEndActivity(id<NSObject> activity);
9288

Crashlytics/Crashlytics/Components/FIRCLSApplication.m

-26
Original file line numberDiff line numberDiff line change
@@ -155,32 +155,6 @@ id FIRCLSApplicationSharedInstance(void) {
155155
}
156156
#endif
157157

158-
void FIRCLSApplicationOpenURL(NSURL* url,
159-
NSExtensionContext* extensionContext,
160-
void (^completionBlock)(BOOL success)) {
161-
if (extensionContext) {
162-
[extensionContext openURL:url completionHandler:completionBlock];
163-
return;
164-
}
165-
166-
BOOL result = NO;
167-
168-
#if TARGET_OS_IOS
169-
// What's going on here is the value returned is a scalar, but we really need an object to
170-
// call this dynamically. Hoops must be jumped.
171-
NSInvocationOperation* op =
172-
[[NSInvocationOperation alloc] initWithTarget:FIRCLSApplicationSharedInstance()
173-
selector:@selector(openURL:)
174-
object:url];
175-
[op start];
176-
[op.result getValue:&result];
177-
#elif CLS_TARGET_OS_OSX
178-
result = [[NSClassFromString(@"NSWorkspace") sharedWorkspace] openURL:url];
179-
#endif
180-
181-
completionBlock(result);
182-
}
183-
184158
id<NSObject> FIRCLSApplicationBeginActivity(NSActivityOptions options, NSString* reason) {
185159
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions:
186160
reason:)]) {

FirebaseFunctions/Sources/Functions.swift

+19-9
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ enum FunctionsConstants {
401401

402402
do {
403403
let rawData = try await fetcher.beginFetch()
404-
return try callableResult(fromResponseData: rawData)
404+
return try callableResult(fromResponseData: rawData, endpointURL: url)
405405
} catch {
406-
throw processedError(fromResponseError: error)
406+
throw processedError(fromResponseError: error, endpointURL: url)
407407
}
408408
}
409409

@@ -454,10 +454,10 @@ enum FunctionsConstants {
454454
fetcher.beginFetch { [self] data, error in
455455
let result: Result<HTTPSCallableResult, any Error>
456456
if let error {
457-
result = .failure(processedError(fromResponseError: error))
457+
result = .failure(processedError(fromResponseError: error, endpointURL: url))
458458
} else if let data {
459459
do {
460-
result = try .success(callableResult(fromResponseData: data))
460+
result = try .success(callableResult(fromResponseData: data, endpointURL: url))
461461
} catch {
462462
result = .failure(error)
463463
}
@@ -523,11 +523,14 @@ enum FunctionsConstants {
523523
return fetcher
524524
}
525525

526-
private func processedError(fromResponseError error: any Error) -> any Error {
526+
private func processedError(fromResponseError error: any Error,
527+
endpointURL url: URL) -> any Error {
527528
let error = error as NSError
528529
let localError: (any Error)? = if error.domain == kGTMSessionFetcherStatusDomain {
529530
FunctionsError(
530531
httpStatusCode: error.code,
532+
region: region,
533+
url: url,
531534
body: error.userInfo["data"] as? Data,
532535
serializer: serializer
533536
)
@@ -538,16 +541,23 @@ enum FunctionsConstants {
538541
return localError ?? error
539542
}
540543

541-
private func callableResult(fromResponseData data: Data) throws -> HTTPSCallableResult {
542-
let processedData = try processedData(fromResponseData: data)
544+
private func callableResult(fromResponseData data: Data,
545+
endpointURL url: URL) throws -> HTTPSCallableResult {
546+
let processedData = try processedData(fromResponseData: data, endpointURL: url)
543547
let json = try responseDataJSON(from: processedData)
544548
let payload = try serializer.decode(json)
545549
return HTTPSCallableResult(data: payload)
546550
}
547551

548-
private func processedData(fromResponseData data: Data) throws -> Data {
552+
private func processedData(fromResponseData data: Data, endpointURL url: URL) throws -> Data {
549553
// `data` might specify a custom error. If so, throw the error.
550-
if let bodyError = FunctionsError(httpStatusCode: 200, body: data, serializer: serializer) {
554+
if let bodyError = FunctionsError(
555+
httpStatusCode: 200,
556+
region: region,
557+
url: url,
558+
body: data,
559+
serializer: serializer
560+
) {
551561
throw bodyError
552562
}
553563

FirebaseFunctions/Sources/FunctionsError.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ struct FunctionsError: CustomNSError {
180180
/// }
181181
/// ```
182182
/// - serializer: The `FunctionsSerializer` used to decode `details` in the error body.
183-
init?(httpStatusCode: Int, body: Data?, serializer: FunctionsSerializer) {
183+
init?(httpStatusCode: Int, region: String, url: URL, body: Data?,
184+
serializer: FunctionsSerializer) {
184185
// Start with reasonable defaults from the status code.
185186
var code = FunctionsErrorCode(httpStatusCode: httpStatusCode)
186187
var description = Self.errorDescription(from: code)
@@ -224,6 +225,8 @@ struct FunctionsError: CustomNSError {
224225

225226
var userInfo = [String: Any]()
226227
userInfo[NSLocalizedDescriptionKey] = description
228+
userInfo["region"] = region
229+
userInfo["url"] = url
227230
if let details {
228231
userInfo[FunctionsErrorDetailsKey] = details
229232
}

FirebaseFunctions/Sources/Internal/FunctionsSerializer.swift

+7-12
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,23 @@ extension FunctionsSerializer {
3131
final class FunctionsSerializer {
3232
// MARK: - Internal APIs
3333

34-
func encode(_ object: Any) throws -> AnyObject {
34+
func encode(_ object: Any) throws -> Any {
3535
if object is NSNull {
36-
return object as AnyObject
36+
return object
3737
} else if object is NSNumber {
3838
return try encodeNumber(object as! NSNumber)
3939
} else if object is NSString {
40-
return object as AnyObject
41-
} else if object is NSDictionary {
42-
let dict = object as! NSDictionary
40+
return object
41+
} else if let dict = object as? NSDictionary {
4342
let encoded = NSMutableDictionary()
4443
try dict.forEach { key, value in
4544
encoded[key] = try encode(value)
4645
}
4746
return encoded
48-
} else if object is NSArray {
49-
let array = object as! NSArray
50-
let encoded = NSMutableArray()
51-
try array.forEach { element in
52-
try encoded.add(encode(element))
47+
} else if let array = object as? NSArray {
48+
return try array.map { element in
49+
try encode(element)
5350
}
54-
return encoded
55-
5651
} else {
5752
throw Error.unsupportedType(typeName: typeName(of: object))
5853
}

0 commit comments

Comments
 (0)