Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class WelcomeWidget extends AnimatedWidget {
const SizedBox(
height: 20,
),
Text('Nested object: ${remoteConfig.getJson('locale')}'),
Text('(${remoteConfig.getValue('welcome').source})'),
Text('(${remoteConfig.lastFetchTime})'),
Text('(${remoteConfig.lastFetchStatus})'),
Expand Down Expand Up @@ -85,6 +86,10 @@ Future<RemoteConfig> setupRemoteConfig() async {
await remoteConfig.setDefaults(<String, dynamic>{
'welcome': 'default welcome',
'hello': 'default hello',
'locale': {
'languageCode': 'en',
'countryCode': 'US',
}
});
RemoteConfigValue(null, ValueSource.valueStatic);
return remoteConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,32 @@ project 'Runner', {
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end

def pubspec_supports_macos(file)
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return false;
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
File.foreach(file_abs_path) { |line|
return true if line =~ /^\s*macos:/
}
return false
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_macos_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
ephemeral_dir = File.join('Flutter', 'ephemeral')
symlink_dir = File.join(ephemeral_dir, '.symlinks')
symlink_plugins_dir = File.join(symlink_dir, 'plugins')
system("rm -rf #{symlink_dir}")
system("mkdir -p #{symlink_plugins_dir}")
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end

# Flutter Pods
generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig'))
if generated_xcconfig.empty?
puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
generated_xcconfig.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join(symlink_dir, 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path]))
end
}

# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join(symlink_plugins_dir, p[:name])
File.symlink(p[:path], symlink)
if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml'))
pod p[:name], :path => File.join(symlink, 'macos')
end
}
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
B550B1FE23F53792007DADD5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B550B1FD23F53792007DADD5 /* GoogleService-Info.plist */; };
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E1A3C0FEB219DE3059F49DD9 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2EDA759B4F18DE63DF0790FB /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

Expand All @@ -51,8 +47,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
);
name = "Bundle Framework";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -72,7 +66,6 @@
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
Expand All @@ -82,16 +75,13 @@
B51643519054BD100F273F38 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
B550B1FD23F53792007DADD5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
D71BFD332DFDD49FEC2851C7 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
33CC10EA2044A3C60003C045 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
E1A3C0FEB219DE3059F49DD9 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -157,8 +147,6 @@
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
D73912EF22F37F9E000D13A0 /* App.framework */,
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
);
path = Flutter;
sourceTree = "<group>";
Expand Down Expand Up @@ -284,7 +272,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
};
33CC111E2044C6BF0003C045 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -311,10 +299,29 @@
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FirebaseABTesting/FirebaseABTesting.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseCoreDiagnostics/FirebaseCoreDiagnostics.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework",
"${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseABTesting.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreDiagnostics.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseInstallations.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfig.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -574,7 +581,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.firebaseRemoteConfigExample;
PRODUCT_BUNDLE_IDENTIFIER = com.firebase.firebaseRemoteConfigExample;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AD_UNIT_ID_FOR_BANNER_TEST</key>
<string>ca-app-pub-3940256099942544/2934735716</string>
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
<string>ca-app-pub-3940256099942544/4411468910</string>
<key>CLIENT_ID</key>
<string>297855924061-g2np3o504qtqpuip8ud0f884j8kfp9jf.apps.googleusercontent.com</string>
<string>448618578101-t3qs2qlt33t53bemq7lhqdarkuc9a6rq.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.297855924061-g2np3o504qtqpuip8ud0f884j8kfp9jf</string>
<string>com.googleusercontent.apps.448618578101-t3qs2qlt33t53bemq7lhqdarkuc9a6rq</string>
<key>ANDROID_CLIENT_ID</key>
<string>448618578101-26jgjs0rtl4ts2i667vjb28kldvs2kp6.apps.googleusercontent.com</string>
<key>API_KEY</key>
<string>AIzaSyBq6mcufFXfyqr79uELCiqM_O_1-G72PVU</string>
<string>AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0</string>
<key>GCM_SENDER_ID</key>
<string>297855924061</string>
<string>448618578101</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>io.flutter.plugins.firebase.firebaseRemoteConfigExample</string>
<string>com.firebase.firebaseRemoteConfigExample</string>
<key>PROJECT_ID</key>
<string>flutterfire-cd2f7</string>
<string>react-native-firebase-testing</string>
<key>STORAGE_BUCKET</key>
<string>flutterfire-cd2f7.appspot.com</string>
<string>react-native-firebase-testing.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<true></true>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<false></false>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:297855924061:ios:ea6d07263d05c514</string>
<string>1:448618578101:ios:285b06fe16e960bbac3efc</string>
<key>DATABASE_URL</key>
<string>https://flutterfire-cd2f7.firebaseio.com</string>
<string>https://react-native-firebase-testing.firebaseio.com</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ void testsMain() {
expect(remoteConfig.getString('hello'), 'default hello');
expect(remoteConfig.getValue('hello').source, ValueSource.valueDefault);

final locale = remoteConfig.getJson('locale');
expect(locale['languageCode'], 'de');
expect(locale['countryCode'], 'DE');
expect(remoteConfig.getValue('locale').source, ValueSource.valueRemote);

expect(remoteConfig.getInt('nonexisting'), 0);

expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ + (NSDictionary *)ErrorCodeAndMessageFromNSError:(NSError *)error {
switch (error.code) {
case FIRRemoteConfigErrorInternalError:
[codeAndMessage setValue:@"internal" forKey:@"code"];
[codeAndMessage setValue:@"internal remote config fetch error" forKey:@"message"];
[codeAndMessage setValue:error.userInfo[NSLocalizedDescriptionKey] forKey:@"message"];
break;
case FIRRemoteConfigErrorThrottled:
[codeAndMessage setValue:@"throttled" forKey:@"code"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
library firebase_remote_config;

import 'dart:async';
import 'dart:convert';

import 'package:firebase_remote_config_platform_interface/firebase_remote_config_platform_interface.dart';
import 'package:firebase_core/firebase_core.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {
return _delegate.getString(key);
}

/// Gets the value for a given key as json (calls json.decode on underlying string value)
Map<String, dynamic>? getJson(String key) {
return _delegate.getJson(key);
}

/// Gets the [RemoteConfigValue] for a given key.
RemoteConfigValue getValue(String key) {
return _delegate.getValue(key);
Expand All @@ -132,6 +137,19 @@ class RemoteConfig extends FirebasePluginPlatform with ChangeNotifier {

/// Sets the default parameter values for the current instance.
Future<void> setDefaults(Map<String, dynamic> defaultParameters) {
return _delegate.setDefaults(defaultParameters);
final encodedParams = defaultParameters
.map(
(key, value) => MapEntry(
key,
_isSupportedType(value) ? value : json.encode(value),
),
)
.cast<String, dynamic>();

return _delegate.setDefaults(encodedParams);
}

bool _isSupportedType(dynamic value) {
return value is bool || value is num || value is String;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ class MethodChannelFirebaseRemoteConfig extends FirebaseRemoteConfigPlatform {
return _activeParameters[key]!.asString();
}

@override
Map<String, dynamic>? getJson(String key) {
return _activeParameters[key]?.asJson();
}

@override
RemoteConfigValue getValue(String key) {
if (!_activeParameters.containsKey(key)) {
Expand Down Expand Up @@ -224,7 +229,7 @@ class MethodChannelFirebaseRemoteConfig extends FirebaseRemoteConfigPlatform {
try {
await channel.invokeMethod('RemoteConfig#setDefaults', <String, dynamic>{
'appName': app.name,
'defaults': defaultParameters
'defaults': defaultParameters,
});
await _updateConfigParameters();
} catch (exception, stackTrace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ abstract class FirebaseRemoteConfigPlatform extends PlatformInterface {
throw UnimplementedError('getString() is not implemented');
}

/// Gets the value for a given key as json (calls json.decode on underlying string value)
Map<String, dynamic>? getJson(String key) {
throw UnimplementedError('getJson() is not implemented');
}

/// Gets the [RemoteConfigValue] for a given key.
RemoteConfigValue getValue(String key) {
throw UnimplementedError('getValue() is not implemented');
Expand Down
Loading