mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-09 22:36:01 +05:45
Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com> In a Simulator, AppCheckDebugProvider now uses the debug token that `firebase appcheck:debugtokens:create` saves to ~/.config/configstore/firebase-appcheck.json on the host, so apps launched from Xcode work without manually registering a token. The token is looked up by each app's Google App ID through SIMULATOR_HOST_HOME. The lookup is compiled out on devices, macOS and Mac Catalyst. No public API changes. Debug tokens are now resolved in this order: 1. AppCheckDebugToken or FIRAAppCheckDebugToken environment variable 2. Token from the CLI config store (Simulator only) 3. Token stored in UserDefaults 4. Newly generated UUID The config store comes before the stored token so a newly provisioned token takes effect without reinstalling the app. Logging: - I-FAA004003: debug token loaded from the config store. - I-FAA004004: exchanging the config store token failed; suggests re-running the CLI with --force and relaunching. - I-FAA004002: exchanging an environment variable token failed; now names the variables instead of showing an unrelated local token. - I-FAA004005: the config store exists but can't be read or parsed. A missing file, or a path where it can't exist (e.g., ~/.config is a regular file), is silent. Exchange-failure warnings are skipped when the server is unreachable, and no message includes the token.
52 lines
2.2 KiB
Objective-C
52 lines
2.2 KiB
Objective-C
/*
|
|
* Copyright 2026 Google LLC
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/// Reads App Check debug tokens provisioned by the Firebase CLI
|
|
/// (`firebase appcheck:debugtokens:create`) into the config store file on the developer's host
|
|
/// machine (`~/.config/configstore/firebase-appcheck.json`).
|
|
///
|
|
/// Only apps running in a Simulator (iOS, tvOS, watchOS, or visionOS) can reach the host file
|
|
/// system, using the `SIMULATOR_HOST_HOME` environment variable that the Simulator sets to the
|
|
/// host user's home directory. On devices, macOS, and Mac Catalyst the lookup is compiled out and
|
|
/// always returns `nil`.
|
|
@interface FIRAppCheckDebugTokenConfigStore : NSObject
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
+ (instancetype)new NS_UNAVAILABLE;
|
|
|
|
/// The path of the config store file, relative to the host user's home directory.
|
|
@property(class, nonatomic, readonly) NSString *relativePath;
|
|
|
|
/// Returns the debug token provisioned for the given app, or `nil` when not running in a
|
|
/// Simulator, when `SIMULATOR_HOST_HOME` is unset, or when the config store file is missing,
|
|
/// unreadable, or contains no token for the app.
|
|
///
|
|
/// @param googleAppID The Google App ID of the `FirebaseApp` to look up.
|
|
+ (nullable NSString *)debugTokenForGoogleAppID:(NSString *)googleAppID;
|
|
|
|
/// Variant of `+debugTokenForGoogleAppID:` that reads `SIMULATOR_HOST_HOME` from the given
|
|
/// environment rather than from the current process. Exposed for testing.
|
|
+ (nullable NSString *)debugTokenForGoogleAppID:(NSString *)googleAppID
|
|
environment:(NSDictionary<NSString *, NSString *> *)environment;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|