invertase/flutterfire_cli

[bug]: Issues that occur when changing the Xcode target name 'Runner'

Closed this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues.

CLI Version

1.0.0

Firebase Tools version

13.4.0

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale ja-JP)
    • Flutter version 3.19.6 on channel stable at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (2 months ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at $HOME/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = $HOME/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)

[✓] VS Code (version 1.90.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Description

I changed the default Xcode target name 'Runner' generated by Flutter in order to use flavors. However, when running the flutterfire configure command, I received the following message.

Could not find target: $targetName in your Xcode workspace. Please create a target named $targetName and try again.

This is returned by the following Ruby script, but it is possible that null is being assigned to $targetName.

String _addServiceFileToTarget() {
return '''
require 'xcodeproj'
googleFile='$serviceFilePath'
xcodeFile='${getXcodeProjectPath(platform)}'
targetName='$target'
project = Xcodeproj::Project.open(xcodeFile)
target = project.targets.find { |target| target.name == targetName }
if(target)
# Check if GoogleService-Info.plist is already in the target's resources
serviceFileInResources = target.resources_build_phase.files.find do |file|
if defined? file && file.file_ref && file.file_ref.path
if file.file_ref.path.is_a? String
file.file_ref.path.include? 'GoogleService-Info.plist'
end
end
end
# Add GoogleService-Info.plist file if it's not already in the target's resources
if(!serviceFileInResources)
new_file = project.new_file(googleFile)
target.add_resources([new_file])
project.save
end
else
abort("Could not find target: \$targetName in your Xcode workspace. Please create a target named \$targetName and try again.")
end
''';
}

Steps to reproduce

  1. Create flutter project for ios platform
  2. Open xcode ios project
  3. Change target name from default target name 'Runner'
  4. Run flutterfire --verbose configure --platforms=ios -p $PROJECT_ID -i $BUNDLE_ID -o firebase_options.dart -y

Expected behavior

The issue wasn't resolved by using the option --ios-target=[changed target name].

Screenshots

No response

Additional context and comments

If I've overlooked something foolish, please close it.

I needed to combine it with the --ios-out option.

flutterfire --verbose configure --platforms=ios -p $PROJECT_ID -i $BUNDLE_ID -o firebase_options.dart --ios-target=[changed target name] --ios-out=ios/Runner/Environment -y

It would be cool if you could tell me more details.