Skip to content

Commit

Permalink
Merge branch 'main' into spm-firestore
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley authored Nov 7, 2024
2 parents 6d5f9b6 + 17dfff1 commit 728650f
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/e2e_tests_fdc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand All @@ -48,7 +48,7 @@ jobs:
channel: 'stable'
cache: true
- name: Setup PostgreSQL for Linux/macOS/Windows
uses: ikalnytskyi/action-setup-postgres@v6
uses: ikalnytskyi/action-setup-postgres@v7
- uses: bluefireteam/melos-action@c7dcb921b23cc520cace360b95d02b37bf09cdaa
with:
run-bootstrap: false
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand All @@ -105,7 +105,7 @@ jobs:
distribution: 'temurin'
java-version: '17'
- name: Setup PostgreSQL for Linux/macOS/Windows
uses: ikalnytskyi/action-setup-postgres@v6
uses: ikalnytskyi/action-setup-postgres@v7
- uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92
name: Xcode Compile Cache
with:
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand All @@ -185,7 +185,7 @@ jobs:
distribution: 'temurin'
java-version: '17'
- name: Setup PostgreSQL for Linux/macOS/Windows
uses: ikalnytskyi/action-setup-postgres@v6
uses: ikalnytskyi/action-setup-postgres@v7
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
with:
channel: 'stable'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ossf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: SARIF file
path: results.sarif
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
timeout-minutes: 15
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand Down Expand Up @@ -142,7 +142,7 @@ jobs:
['tests', 'packages/cloud_firestore/cloud_firestore/example']
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: '20'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: "20"
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
name: Install Node.js 20
with:
node-version: "20"
Expand Down
53 changes: 3 additions & 50 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,6 @@
import Foundation
import PackageDescription

enum ConfigurationError: Error {
case fileNotFound(String)
case parsingError(String)
case invalidFormat(String)
}

func loadFirebaseSDKVersion() throws -> String {
let firebaseCoreScriptPath = NSString.path(withComponents: [
"packages",
"firebase_core",
"firebase_core",
"ios",
"firebase_sdk_version.rb",
])

do {
let content = try String(contentsOfFile: firebaseCoreScriptPath, encoding: .utf8)
let pattern = #"def firebase_sdk_version!\(\)\n\s+'([^']+)'\nend"#
if let regex = try? NSRegularExpression(pattern: pattern, options: []),
let match = regex.firstMatch(
in: content,
range: NSRange(content.startIndex..., in: content)
) {
if let versionRange = Range(match.range(at: 1), in: content) {
return String(content[versionRange])
} else {
throw ConfigurationError.invalidFormat("Invalid format in firebase_sdk_version.rb")
}
} else {
throw ConfigurationError.parsingError("No match found in firebase_sdk_version.rb")
}
} catch {
throw ConfigurationError
.fileNotFound("Error loading or parsing firebase_sdk_version.rb: \(error)")
}
}

let firebase_sdk_version_string: String

do {
firebase_sdk_version_string = try loadFirebaseSDKVersion()
} catch {
fatalError("Failed to load configuration: \(error)")
}

guard let firebase_sdk_version = Version(firebase_sdk_version_string) else {
fatalError("Invalid Firebase SDK version: \(firebase_sdk_version_string)")
}

// Shared Swift package manager code for firebase core
let package = Package(
name: "remote_firebase_core",
Expand All @@ -68,7 +19,9 @@ let package = Package(
.library(name: "firebase-core-shared", targets: ["firebase_core_shared"]),
],
dependencies: [
.package(url: "https://github.com/firebase/firebase-ios-sdk", exact: firebase_sdk_version),
// TODO: this is fine for now, but will require a way of retrieving the firebase-ios-sdk
// likely create a script that runs in preCommit hook of melos
.package(url: "https://github.com/firebase/firebase-ios-sdk", from: "11.0.0"),
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ private FirebaseFirestore readFirestoreInstance(ByteBuffer buffer) {
String databaseURL = (String) readValue(buffer);
FirebaseFirestoreSettings settings = (FirebaseFirestoreSettings) readValue(buffer);
synchronized (FlutterFirebaseFirestorePlugin.firestoreInstanceCache) {
if (FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
appName, databaseURL)
!= null) {
return FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
appName, databaseURL);
FirebaseFirestore cachedFirestoreInstance =
FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
appName, databaseURL);
if (cachedFirestoreInstance != null) {
return cachedFirestoreInstance;
}

FirebaseApp app = FirebaseApp.getInstance(appName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ static FirebaseFirestoreSettings getSettingsFromPigeon(
public static FirebaseFirestore getFirestoreFromPigeon(
GeneratedAndroidFirebaseFirestore.FirestorePigeonFirebaseApp pigeonApp) {
synchronized (FlutterFirebaseFirestorePlugin.firestoreInstanceCache) {
if (FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
pigeonApp.getAppName(), pigeonApp.getDatabaseURL())
!= null) {
return FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
pigeonApp.getAppName(), pigeonApp.getDatabaseURL());
FirebaseFirestore cachedFirestoreInstance =
FlutterFirebaseFirestorePlugin.getFirestoreInstanceByNameAndDatabaseUrl(
pigeonApp.getAppName(), pigeonApp.getDatabaseURL());
if (cachedFirestoreInstance != null) {
return cachedFirestoreInstance;
}

FirebaseApp app = FirebaseApp.getInstance(pigeonApp.getAppName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://firebase.google.com/support/release-notes/ios
def firebase_sdk_version!()
'11.2.0'
'11.4.0'
end
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ class Query<T extends database_interop.QueryJsImpl> extends JsObjectWrapper<T> {
streamController = StreamController<QueryEvent>.broadcast(
onListen: startListen,
onCancel: stopListen,
sync: true,
);
return streamController.stream;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ @implementation FLTFirebaseMessagingPlugin {
NSObject<FlutterPluginRegistrar> *_registrar;
NSData *_apnsToken;
NSDictionary *_initialNotification;
bool simulatorToken;

// Used to track if everything as been initialized before answering
// to the initialNotification request
Expand Down Expand Up @@ -57,7 +56,6 @@ - (instancetype)initWithFlutterMethodChannel:(FlutterMethodChannel *)channel
_initialNotificationGathered = NO;
_channel = channel;
_registrar = registrar;
simulatorToken = false;
// Application
// Dart -> `getInitialNotification`
// ObjC -> Initialize other delegates & observers
Expand Down Expand Up @@ -1005,29 +1003,12 @@ + (NSDictionary *)remoteMessageUserInfoToDict:(NSDictionary *)userInfo {
- (void)ensureAPNSTokenSetting {
FIRMessaging *messaging = [FIRMessaging messaging];

// With iOS SDK >= 10.4, an APNS token is required for getting/deleting token. We set a dummy
// token for the simulator for test environments. Historically, a simulator will not work for
// messaging. It will work if environment: iOS 16, running on macOS 13+ & silicon chip. We check
// the `_apnsToken` is nil. If it is, then the environment does not support and we set dummy
// token.
#if TARGET_IPHONE_SIMULATOR
if (simulatorToken == false && _apnsToken == nil) {
NSString *str = @"fake-apns-token-for-simulator";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
[[FIRMessaging messaging] setAPNSToken:data type:FIRMessagingAPNSTokenTypeSandbox];
}
// We set this either way. We set dummy token once as `_apnsToken` could be nil next time
// which could possibly set dummy token unnecessarily
simulatorToken = true;
#endif

if (messaging.APNSToken == nil && _apnsToken != nil) {
#ifdef DEBUG
[[FIRMessaging messaging] setAPNSToken:_apnsToken type:FIRMessagingAPNSTokenTypeSandbox];
#else
[[FIRMessaging messaging] setAPNSToken:_apnsToken type:FIRMessagingAPNSTokenTypeProd];
#endif

_apnsToken = nil;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ private void tearDownChannel() {
channel = null;
eventChannel.setStreamHandler(null);
eventChannel = null;
for (ConfigUpdateListenerRegistration listener : listenersMap.values()) {
listener.remove();
listenersMap.remove(listener);
}
removeEventListeners();
}

private FirebaseRemoteConfig getRemoteConfig(Map<String, Object> arguments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,17 @@ class MethodChannelFirebaseRemoteConfig extends FirebaseRemoteConfigPlatform {
static const EventChannel _eventChannelConfigUpdated =
EventChannel('plugins.flutter.io/firebase_remote_config_updated');

Stream<RemoteConfigUpdate>? _onConfigUpdatedStream;

@override
Stream<RemoteConfigUpdate> get onConfigUpdated {
return _eventChannelConfigUpdated.receiveBroadcastStream(<String, dynamic>{
_onConfigUpdatedStream ??=
_eventChannelConfigUpdated.receiveBroadcastStream(<String, dynamic>{
'appName': app.name,
}).map((event) {
final updatedKeys = Set<String>.from(event);
return RemoteConfigUpdate(updatedKeys);
});
return _onConfigUpdatedStream!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,16 @@ final class ServiceApiNotEnabled implements VertexAIException {
'The Vertex AI in Firebase SDK requires the Vertex AI in Firebase API '
'(`firebasevertexai.googleapis.com`) to be enabled in your Firebase project. Enable this API '
'by visiting the Firebase Console at '
'https://console.firebase.google.com/$_projectId/genai '
'https://console.firebase.google.com/project/$_id/genai '
'and clicking "Get started". If you enabled this API recently, wait a few minutes for the '
'action to propagate to our systems and then retry.';

@override
String toString() => message;

String get _id {
return _projectId.replaceAll('projects/', '');
}
}

/// Exception thrown when the quota is exceeded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:tests/firebase_options.dart';

// ignore: do_not_use_environment
const bool skipTestsOnCI = bool.fromEnvironment('CI');

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

Expand Down Expand Up @@ -40,6 +43,7 @@ void main() {
expect(result, isA<int?>());
}
},
skip: skipTestsOnCI && defaultTargetPlatform == TargetPlatform.iOS,
);

test('isSupported', () async {
Expand Down
Loading

0 comments on commit 728650f

Please sign in to comment.