Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support custom firebase.json path #8061

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CHOIMINSEOK
Copy link

Description

Currently, the firebase.json file is configured only when it is located in the parent directory of the Android project. However, React Native can be used in different ways, especially when integrating it into an existing native project.

In my case, I’m trying to integrate a React Native app into a brownfield native app as a submodule, so retrieving firebase.json from the upper directory always fails. I think providing an option to set a custom "firebaseJsonDir" would be very useful for people in my situation.

I add "customFirebaseJsonDir" option in same way to override firebase sdk versions and reactNativeDir.

I would appreciate any help to add this feature on iOS too.

Release Summary

  • Support custom firebase.json path

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-firebase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 1:01pm

@CLAassistant
Copy link

CLAassistant commented Oct 15, 2024

CLA assistant check
All committers have signed the CLA.

@CHOIMINSEOK CHOIMINSEOK changed the title feat: support custom firebase.json path feat(android): support custom firebase.json path Oct 15, 2024
@CHOIMINSEOK CHOIMINSEOK changed the title feat(android): support custom firebase.json path feat: support custom firebase.json path Oct 15, 2024
@mikehardy
Copy link
Collaborator

Hmm - the iOS side does a search for firebase.json in two places:

1- one in shell script installed as a build script inside the Xcode project, during build in order to pull values that it needs to put in the Info.plist:

while true; do
_CURRENT_SEARCH_DIR=$(dirname "$_CURRENT_SEARCH_DIR")
if [[ "$_CURRENT_SEARCH_DIR" == "/" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;
echo "info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file."
_SEARCH_RESULT=$(find "$_CURRENT_SEARCH_DIR" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | /usr/bin/head -n 1)
if [[ ${_SEARCH_RESULT} ]]; then
echo "info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT"
break;
fi;
_CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))
done

2- one in ruby which is pulled in to the RNFBApp podspec to get the SDK versions

i = 0
while i < 5
current_search_directory = File.join(current_search_directory, '..')
if is_test_project
firebase_json = File.expand_path(File.join(current_search_directory, 'tests', 'firebase.json'))
else
firebase_json = File.expand_path(File.join(current_search_directory, 'firebase.json'))
end
if File.exist?(firebase_json)
$firebase_json_path = firebase_json
begin
$firebase_json_config = JSON.parse(File.read(firebase_json))['react-native']
Pod::UI.puts "Using firebase.json from '#{firebase_json}'"
# Pod::UI.puts $firebase_json_config
rescue => error
Pod::UI.warn "An error occurred parsing the firebase.json located at '#{firebase_json}':"
Pod::UI.warn error
end
break
end
i += 1
end
end

I am not sure how to transmit to the Xcode build script that you have a specific firebase.json path, the only thing I can think of is an environment variable. For firebase_json.rb it could be a Podfile variable perhaps

I wonder if, in all these cases, it might be easier as part of your build / package process to determine which directories are actually being searched...and during build make sure the firebase.json is just copied/placed into a directory that is already searched?

That might be easier than complicating the build / config process here (which is already pretty touchy...)

@CHOIMINSEOK
Copy link
Author

Hi! @mikehardy Thanks for reply.

I wonder if, in all these cases, it might be easier as part of your build / package process to determine which directories are actually being searched...and during build make sure the firebase.json is just copied/placed into a directory that is already searched?

Yeah that might work, but all of those who have different rn app structure have to feature out where the build script of react-native-firebase resolves firebase.json. I just want to provide a convenient option for them. Besides, in some case like me the location might be outside of project which is so weird.

directory <= this is where react-native-firebase starts to resolve firebase.json
 ㄴ android project
  ㄴ react native project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants