Skip to content

Commit

Permalink
feat: only update config and write plist file if they don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed May 16, 2022
1 parent 1a3e945 commit ccfa351
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
9 changes: 3 additions & 6 deletions packages/flutterfire_cli/lib/src/commands/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ class ConfigCommand extends FlutterFireCommand {

final file = File(googleServiceInfoFile);

await file.writeAsString(iosOptions.optionsSourceContent);
//check exists here. write if not.
if (!file.existsSync()) {
await file.writeAsString(iosOptions.optionsSourceContent);
}

final pathToScript = path.split(Platform.script.toFilePath());

Expand All @@ -416,12 +417,8 @@ class ConfigCommand extends FlutterFireCommand {

final xcodeProjFilePath = path.join(flutterApp!.iosDirectory.path, 'Runner.xcodeproj');


//TODO -check if google file already exists in project.pbxproj (update if not) & check if google file exists (update if not).
if (Platform.isMacOS) {
final result = await Process.run('ruby', [ pathToPbxScript,'--googleFile=$googleServiceInfoFile','--xcodeFile=$xcodeProjFilePath']);
print('stdout: ${result.stdout}');
print('stderr: ${result.stderr}');
}
}

Expand Down
19 changes: 14 additions & 5 deletions scripts/set_ios_pbxproj_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@
project_path = options[:xcodeFile]
# open the xcode project
project = Xcodeproj::Project.open(project_path)
# add GoogleService-Info.plist to your xcode project
file = project.new_file(options[:googleFile])
# save it
project.save

puts "Updated project.pbxproj file for Xcode project with GoogleService-Info.plist."
# check id GoogleService-Info.plist config is part of xcode project
googleConfigExists = false
project.files.each do |file|
if file.path == "Runner/GoogleService-Info.plist"
googleConfigExists = true
exit
end
end

# Write only if config doesn't exist
if googleConfigExists == false
project.new_file(options[:googleFile])
project.save
end

0 comments on commit ccfa351

Please sign in to comment.