react-native-firebase
react-native-firebase copied to clipboard
[🐛] Script Phases not added on iOS when using abstract targets in pod file
Issue
This issue is linked to #2800.
tl;dr: the issue seems to be on @react-native-community/cli
side, but it impacts @react-native-firebase
users. One easy solution is to stop using abstract_target
in Podfile
.
In order to automatically add script_phases, since v6
this package make use of react-native.config.js
file, using scriptPhases
.
Example for @react-native-firebase/app
:
module.exports = {
dependency: {
platforms: {
android: {
packageImportPath: 'import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;',
},
ios: {
scriptPhases: [
{
name: '[RNFB] Core Configuration',
path: './ios_config.sh',
execution_position: 'after_compile',
input_files: ['$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)'],
},
],
},
},
},
};
In #2800, due to an issue with abstract_targets
@Salakar make this PR on @react-native-community/cli
.
It seems (at least on my side, cf Podfile
above) this fix do not really resolve the issue. In fact, the scriptPhases
are not added for abstract targets (nor real targets narrowed inside abstract targets).
If I "manually" add the script directly into the RNFBApp.podspec
(= bypassing the use of @react-native-community/cli
) the script is correctly added on my final target. This means that somehow, cocoapods
can succeed into adding scripts for targets inside abstract targets.
RNFBApp.podspec
require 'json'
require './firebase_json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
firebase_sdk_version = package['sdkVersions']['ios']['firebase']
Pod::Spec.new do |s|
s.name = "RNFBApp"
s.version = package["version"]
s.description = package["description"]
s.summary = <<-DESC
A well tested feature rich Firebase implementation for React Native, supporting iOS & Android.
DESC
s.homepage = "http://invertase.io/oss/react-native-firebase"
s.license = package['license']
s.authors = "Invertase Limited"
s.source = { :git => "https://github.com/invertase/react-native-firebase.git", :tag => "v#{s.version}" }
s.social_media_url = 'http://twitter.com/invertaseio'
s.ios.deployment_target = "10.0"
s.cocoapods_version = '>= 1.10.0'
s.source_files = "ios/**/*.{h,m}"
# React Native dependencies
s.dependency 'React-Core'
if defined?($FirebaseSDKVersion)
Pod::UI.puts "#{s.name}: Using user specified Firebase SDK version '#{$FirebaseSDKVersion}'"
firebase_sdk_version = $FirebaseSDKVersion
end
# Firebase dependencies
s.dependency 'Firebase/CoreOnly', firebase_sdk_version
if defined?($RNFirebaseAsStaticFramework)
Pod::UI.puts "#{s.name}: Using overridden static_framework value of '#{$RNFirebaseAsStaticFramework}'"
s.static_framework = $RNFirebaseAsStaticFramework
else
s.static_framework = false
end
s.script_phase = {
name: '[RNFB] Core Configuration',
input_files: ['$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)'],
execution_position: :after_compile,
script: %(
set -e
_MAX_LOOKUPS=2;
_SEARCH_RESULT=''
_RN_ROOT_EXISTS=''
_CURRENT_LOOKUPS=1
_JSON_ROOT="'react-native'"
_JSON_FILE_NAME='firebase.json'
_JSON_OUTPUT_BASE64='e30=' # { }
_CURRENT_SEARCH_DIR=${PROJECT_DIR}
_PLIST_BUDDY=/usr/libexec/PlistBuddy
_TARGET_PLIST="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
_DSYM_PLIST="${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist"
# plist arrays
_PLIST_ENTRY_KEYS=()
_PLIST_ENTRY_TYPES=()
_PLIST_ENTRY_VALUES=()
function setPlistValue {
echo "info: setting plist entry '$1' of type '$2' in file '$4'"
${_PLIST_BUDDY} -c "Add :$1 $2 '$3'" $4 || echo "info: '$1' already exists"
}
function getFirebaseJsonKeyValue () {
if [[ ${_RN_ROOT_EXISTS} ]]; then
ruby -e "require 'rubygems';require 'json'; output=JSON.parse('$1'); puts output[$_JSON_ROOT]['$2']"
else
echo ""
fi;
}
function jsonBoolToYesNo () {
if [[ $1 == "false" ]]; then
echo "NO"
elif [[ $1 == "true" ]]; then
echo "YES"
else echo "NO"
fi
}
echo "info: -> RNFB build script started"
echo "info: 1. Locating ${_JSON_FILE_NAME} file:"
if [[ -z ${_CURRENT_SEARCH_DIR} ]]; then
_CURRENT_SEARCH_DIR=$(pwd)
fi;
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 | head -n 1)
if [[ ${_SEARCH_RESULT} ]]; then
echo "info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT"
break;
fi;
_CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))
done
if [[ ${_SEARCH_RESULT} ]]; then
_JSON_OUTPUT_RAW=$(cat "${_SEARCH_RESULT}")
_RN_ROOT_EXISTS=$(ruby -e "require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]" || echo '')
if [[ ${_RN_ROOT_EXISTS} ]]; then
_JSON_OUTPUT_BASE64=$(python -c 'import json,sys,base64;print(base64.b64encode(json.dumps(json.loads(open('"'${_SEARCH_RESULT}'"').read())['${_JSON_ROOT}'])))' || echo "e30=")
fi
_PLIST_ENTRY_KEYS+=("firebase_json_raw")
_PLIST_ENTRY_TYPES+=("string")
_PLIST_ENTRY_VALUES+=("$_JSON_OUTPUT_BASE64")
# config.analytics_auto_collection_enabled
_ANALYTICS_AUTO_COLLECTION=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "analytics_auto_collection_enabled")
if [[ $_ANALYTICS_AUTO_COLLECTION ]]; then
_PLIST_ENTRY_KEYS+=("FIREBASE_ANALYTICS_COLLECTION_ENABLED")
_PLIST_ENTRY_TYPES+=("bool")
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_ANALYTICS_AUTO_COLLECTION")")
fi
# config.perf_auto_collection_enabled
_PERF_AUTO_COLLECTION=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "perf_auto_collection_enabled")
if [[ $_PERF_AUTO_COLLECTION ]]; then
_PLIST_ENTRY_KEYS+=("firebase_performance_collection_enabled")
_PLIST_ENTRY_TYPES+=("bool")
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_PERF_AUTO_COLLECTION")")
fi
# config.messaging_auto_init_enabled
_MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "messaging_auto_init_enabled")
if [[ $_MESSAGING_AUTO_INIT ]]; then
_PLIST_ENTRY_KEYS+=("FirebaseMessagingAutoInitEnabled")
_PLIST_ENTRY_TYPES+=("bool")
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_MESSAGING_AUTO_INIT")")
fi
# config.crashlytics_disable_auto_disabler - undocumented for now - mainly for debugging, document if becomes useful
_CRASHLYTICS_AUTO_DISABLE_ENABLED=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "crashlytics_disable_auto_disabler")
if [[ $_CRASHLYTICS_AUTO_DISABLE_ENABLED == "true" ]]; then
echo "Disabled Crashlytics auto disabler." # do nothing
else
_PLIST_ENTRY_KEYS+=("FirebaseCrashlyticsCollectionEnabled")
_PLIST_ENTRY_TYPES+=("bool")
_PLIST_ENTRY_VALUES+=("NO")
fi
else
_PLIST_ENTRY_KEYS+=("firebase_json_raw")
_PLIST_ENTRY_TYPES+=("string")
_PLIST_ENTRY_VALUES+=("$_JSON_OUTPUT_BASE64")
echo "warning: A firebase.json file was not found, whilst this file is optional it is recommended to include it to configure firebase services in React Native Firebase."
fi;
echo "info: 2. Injecting Info.plist entries: "
# Log out the keys we're adding
for i in "${!_PLIST_ENTRY_KEYS[@]}"; do
echo " -> $i. ${_PLIST_ENTRY_KEYS[$i]}" "${_PLIST_ENTRY_TYPES[$i]}" "${_PLIST_ENTRY_VALUES[$i]}"
done
for plist in "${_TARGET_PLIST}" "${_DSYM_PLIST}" ; do
if [[ -f "${plist}" ]]; then
# paths with spaces break the call to setPlistValue. temporarily modify
# the shell internal field separator variable (IFS), which normally
# includes spaces, to consist only of line breaks
oldifs=$IFS
IFS="
"
for i in "${!_PLIST_ENTRY_KEYS[@]}"; do
setPlistValue "${_PLIST_ENTRY_KEYS[$i]}" "${_PLIST_ENTRY_TYPES[$i]}" "${_PLIST_ENTRY_VALUES[$i]}" "${plist}"
done
# restore the original internal field separator value
IFS=$oldifs
else
echo "warning: A Info.plist build output file was not found (${plist})"
fi
done
echo "info: <- RNFB build script finished"
),
execution_position: :before_compile,
input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb']
}
end
Project Files
Javascript
Click To Expand
package.json
:
{
"dependencies": {
"@crowdlinker/react-native-pager": "^0.2.3",
"@randstad-lean-mobile-factory/react-native-authentication-kit": "^4.1.6",
"@react-native-community/async-storage": "^1.12.1",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-firebase/analytics": "^12.0.0",
"@react-native-firebase/app": "^12.0.0",
"@react-native-firebase/crashlytics": "^12.0.0",
"@react-native-firebase/perf": "^12.0.0",
"@reduxjs/toolkit": "^1.5.1",
"axios": "^0.21.1",
"http-status-codes": "^2.1.4",
"jest-date-mock": "^1.0.8",
"lodash.flatmap": "^4.5.0",
"lodash.groupby": "^4.6.0",
"lodash.pick": "^4.4.0",
"lodash.zipobject": "^4.1.3",
"moment": "^2.29.1",
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-auth0": "^2.8.3",
"react-native-bootsplash": "^3.2.3",
"react-native-calendars": "git+https://github.com/the-noob-101/react-native-calendars",
"react-native-chart-kit": "^6.11.0",
"react-native-check-box": "^2.1.7",
"react-native-collapsible": "^1.6.0",
"react-native-config": "^1.4.2",
"react-native-date-picker": "^2.7.8",
"react-native-device-info": "^5.5.3",
"react-native-easy-content-loader": "^0.3.2",
"react-native-file-viewer": "^2.1.4",
"react-native-flash-message": "^0.1.23",
"react-native-fs": "^2.18.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-keyboard-aware-scroll-view": "^0.9.4",
"react-native-reanimated": "^1.7.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.3.0",
"react-native-segmented-control-tab": "^3.4.1",
"react-native-sensitive-info": "^5.5.8",
"react-native-snap-carousel": "^3.9.1",
"react-native-sqlite-storage": "^4.1.0",
"react-native-svg": "^12.1.1",
"react-native-version-number": "^0.3.6",
"react-navigation": "^4.4.4",
"react-navigation-drawer": "^2.7.1",
"react-navigation-stack": "^2.10.4",
"react-navigation-tabs": "^2.11.1",
"react-query": "^3.16.0",
"react-redux": "^7.2.4",
"redux": "^4.1.0",
"redux-persist": "^6.0.0",
"redux-persist-transform-filter": "^0.0.20",
"redux-saga": "^1.1.3",
"redux-saga-routines": "^3.2.3",
"reselect": "^4.0.0",
"typesafe-actions": "^5.1.0"
},
"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/runtime": "^7.14.0",
"@prettier/plugin-ruby": "^1.5.5",
"@prettier/plugin-xml": "^0.13.1",
"@react-native-community/eslint-config": "^2.0.0",
"@react-native-community/eslint-plugin": "^1.1.0",
"@testing-library/jest-native": "^4.0.1",
"@testing-library/react-native": "^7.2.0",
"@types/jest": "^26.0.23",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.flatmap": "^4.5.6",
"@types/lodash.groupby": "^4.6.6",
"@types/lodash.pick": "^4.4.6",
"@types/lodash.zipobject": "^4.1.6",
"@types/react": "16.9.0",
"@types/react-native": "^0.63.4",
"@types/react-native-calendars": "^1.505.3",
"@types/react-native-snap-carousel": "^3.8.2",
"@types/react-native-sqlite-storage": "^3.3.2",
"@types/react-redux": "^7.1.16",
"@types/react-test-renderer": "16.9.2",
"@types/redux-saga-routines": "^3.1.0",
"@types/remote-redux-devtools": "^0.5.4",
"babel-cli": "^7.0.0-0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-plugin-module-resolver": "^4.1.0",
"babel-plugin-transform-exponentiation-operator": "^6.24.1",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.1",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"fs-extra": "^9.0.0",
"jest": "^26.6.3",
"jest-extended": "^0.11.5",
"jest-snapshot": "^26.6.2",
"metro-react-native-babel-preset": "^0.59.0",
"ncp": "^2.0.0",
"prettier": "^2.3.0",
"promise": "^8.1.0",
"prompt-confirm": "^2.0.4",
"react-native-clean-project": "^3.6.4",
"react-native-version": "^4.0.0",
"react-test-renderer": "16.13.1",
"remote-redux-devtools": "^0.5.16",
"remotedev-server": "^0.3.1",
"snapshot-diff": "^0.8.1",
"standard-changelog": "^2.0.27",
"typescript": "^3.9.6"
},
"engines": {
"node": "=10"
},
"types": "./App/Redux/ .d.ts",
"resolutions": {
"hoist-non-react-statics": ">=3.3.0",
"react-native-safe-area-view": ">=0.10.0"
}
}
firebase.json
for react-native-firebase v6:
{
"$schema": "./node_modules/@react-native-firebase/app/firebase-schema.json",
"react-native": {
"crashlytics_debug_enabled": true,
"crashlytics_auto_collection_enabled": true,
"crashlytics_is_error_generation_on_js_crash_enabled": true,
"crashlytics_javascript_exception_handler_chaining_enabled": true,
"crashlytics_ndk_enabled": true
}
}
iOS
Click To Expand
ios/Podfile
:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
project 'scope',
'DEV Debug' => :debug,
'UAT Debug' => :debug,
'PROD Debug' => :debug,
'UAT Release' => :release,
'PROD Release' => :release
Debug = ['DEV Debug', 'UAT Debug', 'PROD Debug']
abstract_target 'defaults' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# https://rnfirebase.io/analytics/usage#disable-ad-id-usage-on-ios
$RNFirebaseAnalyticsWithoutAdIdSupport = true
# Pods for scope
config = use_native_modules!
use_react_native!(path: config['reactNativePath'])
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
if !ENV['CI']
use_flipper!({ 'Flipper' => '0.91.2' }, configurations: Debug)
post_install { |installer| flipper_post_install(installer) }
end
target 'scope' do
end
end
AppDelegate.m
:
// N/A
Environment
Click To Expand
react-native info
output:
info Fetching system and libraries information...
System:
OS: macOS 11.3.1
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Memory: 94.29 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 10.20.1 - ~/.asdf/installs/nodejs/10.20.1/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.asdf/installs/nodejs/10.20.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /Users/tlath/.asdf/shims/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 23, 25, 26, 28, 29
Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3, 29.0.2, 30.0.3
System Images: android-23 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.6953283
Xcode: 12.5/12E262 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_275 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
-
Platform that you're experiencing the issue on:
- [x] iOS
- [ ] Android
- [ ] iOS but have not tested behavior on Android
- [ ] Android but have not tested behavior on iOS
- [ ] Both
-
react-native-firebase
version you're using that has this issue:-
12.0.0
-
-
Firebase
module(s) you're using that has the issue:-
app
-
crashlytics
-
-
Are you using
TypeScript
?-
Y
&VERSION: 3.9.6
-
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Seems the issue is still there (react-native-firebase/app:18.5.0
), when running pod install
if the Podfile doesn't use an abstract target I get:
...
[Expo] Enabling modular headers for pod ReactCommon
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration
...
While if I use multiple targets with an abstract_target that custom script is not added:
...
[Expo] Enabling modular headers for pod ReactCommon
Auto-linking React Native modules for target `SharedTarget`: RNCAsyncStorage, RNCClipboard, RNDeviceInfo,
...
currently the only solution is to not use abstract target.
My podfile was something like that
Podfile
# react-native-permissions
def node_require(script)
# Resolve script with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
"require.resolve(
'#{script}',
{paths: [process.argv[1]]},
)", __dir__]).strip
end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
platform :ios, min_ios_version_supported
prepare_react_native_project!
# react-native-permissions
setup_permissions([
'PhotoLibrary',
'Camera',
'LocationWhenInUse'
])
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
# flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
flipper_config = FlipperConfiguration.disabled
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
abstract_target 'xCommonPods' do
target 'x' do
end
target 'xPreprod' do
end
target 'xStaging' do
end
target 'ourCompanyX' do
end
target 'ourCompanyXPreprod' do
end
target 'ourCompanyXStaging' do
end
config = use_native_modules!
use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
# @react-native-firebase/[email protected] is using FirebaseAnalytics version 11. GoogleTagManager should also use this
# if @react-native-firebase/analytics changes FirebaseAnalytics version. check version
pod 'GoogleTagManager', '7.4.3'
target 'xTests' do
inherit! :complete
# Pods for testing
end
post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
target 'x-tvOS' do
# Pods for x-tvOS
target 'x-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
I removed abstract target and created shared def
Podfile
# react-native-permissions
def node_require(script)
# Resolve script with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
"require.resolve(
'#{script}',
{paths: [process.argv[1]]},
)", __dir__]).strip
end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
platform :ios, min_ios_version_supported
prepare_react_native_project!
# react-native-permissions
setup_permissions([
'PhotoLibrary',
'Camera',
'LocationWhenInUse'
])
# this is necessary for multiple environments do not delete
def shared
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
# flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
flipper_config = FlipperConfiguration.disabled
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
$config = use_native_modules!
use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => $config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
# @react-native-firebase/[email protected] is using FirebaseAnalytics version 11. GoogleTagManager should also use this
# if @react-native-firebase/analytics changes FirebaseAnalytics version. check version
pod 'GoogleTagManager', '7.4.3'
end
target 'x' do
Pod::UI.puts 'building x'
shared
target 'xTests' do
Pod::UI.puts 'building xTests'
inherit! :complete
# Pods for testing
end
end
target 'xPreprod' do
Pod::UI.puts 'building xPreprod'
shared
end
target 'xStaging' do
Pod::UI.puts 'building xStaging'
shared
end
target 'ourCompanyX' do
Pod::UI.puts 'building ourCompanyX'
shared
end
target 'ourCompanyXPreprod' do
Pod::UI.puts 'building ourCompanyXPreprod'
shared
end
target 'ourCompanyXStaging' do
Pod::UI.puts 'building ourCompanyXStaging'
shared
end
post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
$config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
target 'x-tvOS' do
# Pods for x-tvOS
target 'x-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
With this change, scripts are added to all targets.
@AuroPick I took a really deep dive into this today to see if I could fix it, as my app also has an abstract target with the react-native config then a bunch of concrete targets to set Google-Services.plist file membership to different backends
In all my exploratory coding investigation with the react-native-firebase podspecs, the react-native CLI's native modules ruby, there does not seem to be a way to have concrete sub-targets get script phases added if the react-native config is in the abstract target. Cocoapods simply does not allow a way I can find to get a handle on the sub-target's instance to add the script phase
So your solution, where you create shared block to de-duplicate all the react-native config instead of an abstract target, then call that shared block from the concrete targets looks to be about as good as it gets
Thanks for posting that
I'm re-opening this as I would like to update docs to include a note on this. I've tested your solution and have it working in my commercial app
I'm re-opening this as I would like to update docs to include a note on this. I've tested your solution and have it working in my commercial app
An official documentation on multiple environment setup for react native firebase would be great
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Thank @AuroPick , only your solution work for me. :)
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.