react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

Cannot install on iOS when using abstract targets in pod file

Open gabrielbull opened this issue 7 years ago • 12 comments

Issue

Cannot install on iOS when using abstract targets in pod file. I get this error:

pod install
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration

[!] Invalid `Podfile` file: [!] Script phases cannot be added to abstract targets..

 #  from /Users/gabriel/Code/seal/seal-jobs-frontend/apps/employee-native/ios/Podfile:53
 #  -------------------------------------------
 #
 >    use_native_modules!
 #  end
 #  -------------------------------------------

Project Files

Podfile content:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

abstract_target 'MyProject' do
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'MyProject' do
  end

  target 'MyProjectTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'MyProjectDemo' do
  end

  target 'MyProjectInAppPurchases' do
  end

  use_native_modules!
end

Environment

System:
    OS: macOS 10.15
    CPU: (16) x64 Intel(R) Xeon(R) W-2140B CPU @ 3.20GHz
    Memory: 1.45 GB / 64.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.12.0 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.12.1 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmGlobalPackages:
    react-native-cli: 2.0.1
  • 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:
    • 6.0.3
  • Firebase module(s) you're using that has the issue:
  • Are you using TypeScript?
    • Irrelevant

gabrielbull avatar Oct 30 '19 20:10 gabrielbull

Interesting. I also have an abstract target and it works for me but on v5 I have not tried v6. But I looked and I wonder if it's because you have the same target name twice? My abstract target name is unique

Or it could be a v5 / v6 different - I'm waiting for notifications so haven't ported yet

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

abstract_target 'KScoreApp' do

  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Required by react-native-permissions
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
  pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
  pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec"

  # Required by RNFirebase
  pod 'GoogleIDFASupport', '~> 3.14.0'
  pod 'Firebase/Auth', '~> 6.11.0'
  pod 'Firebase/DynamicLinks', '~> 6.11.0'
  pod 'Firebase/Analytics', '~> 6.11.0'
  pod 'Firebase/Functions', '~> 6.11.0'
  pod 'Firebase/Firestore', '~> 6.11.0'
  pod 'Firebase/Messaging', '~> 6.11.0'
  pod 'Firebase/RemoteConfig', '~> 6.11.0'
  pod 'Firebase/Storage', '~> 6.11.0'
  pod 'Firebase/Performance', '~> 6.11.0'
  pod 'Fabric', '~> 1.10.2'
  pod 'Crashlytics', '~> 3.14.0'

  target 'KScoreAppTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'KScoreAppDev' do
  end

  target 'KScoreAppTest' do
  end

  target 'KScoreAppStaging' do
  end

  target 'KScoreAppProd' do
  end

  use_native_modules!
end

target 'KScoreApp-tvOS' do
  target 'KScoreApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

mikehardy avatar Oct 30 '19 21:10 mikehardy

Yes, this is something only happening on v6, wasn't happening on v5.

Update: Now have to delete a few lines from node_modules/@react-native-firebase/app/react-native.config.js:

diff --git a/node_modules/@react-native-firebase/app/react-native.config.js b/node_modules/@react-native-firebase/app/react-native.config.js
index 769591f..372a85b 100644
--- a/node_modules/@react-native-firebase/app/react-native.config.js
+++ b/node_modules/@react-native-firebase/app/react-native.config.js
@@ -4,15 +4,6 @@ module.exports = {
       android: {
         packageImportPath: 'import io.invertase.firebase.app.ReactNativeFirebaseAppPackage;',
       },
-      ios: {
-        scriptPhases: [
-          {
-            name: '[RNFB] Core Configuration',
-            path: './ios_config.sh',
-            execution_position: 'after_compile',
-          },
-        ],
-      },
     },
   },
 };

And then, I added the build phase manually on each target:

[RNFB] Core Configuration

../node_modules/@react-native-firebase/app/ios_config.sh
Capture d’écran, le 2019-10-30 à 20 54 04

Use patch-package to patch automatically on yarn install.

gabrielbull avatar Oct 31 '19 00:10 gabrielbull

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.

stale[bot] avatar Nov 28 '19 05:11 stale[bot]

It's still an active issue

gabrielbull avatar Nov 28 '19 20:11 gabrielbull

@gabrielbull when you say you deleted ios_config.sh, did you mean the script itself or just the scriptPhaseexport in react-native.config?

phurtad2 avatar Dec 15 '19 20:12 phurtad2

Delete the file ios_config.sh, use patch-package to create a patch file that will delete it on every yarn install.

gabrielbull avatar Dec 15 '19 20:12 gabrielbull

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.

stale[bot] avatar Jan 12 '20 21:01 stale[bot]

Still seeing this issue on version 6.2.0. And @gabrielbull when I try your fix and run pod install after deleting ios_config.sh, it gives me back this error:

Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Users/johntzan/dev/project-name-app/node_modules/@react-native-firebase/app/ios_config.sh.

Also adding that I did not have this issue on v5 as I am just now upgrading to v6 but this is holding the process back.

johntzan avatar Jan 15 '20 22:01 johntzan

@Salakar this will bite me too - any idea why abstract targets aren't working?

I'd suppose the auto-magic in here needs to skip targets that are abstract? https://github.com/invertase/react-native-firebase/blob/master/packages/app/pod_config.rb

mikehardy avatar Jan 15 '20 22:01 mikehardy

React Native CLI auto linking on iOS is adding this script based on the module config: https://github.com/invertase/react-native-firebase/blob/master/packages/app/react-native.config.js#L8-L14

So ideally I think we should raise this issue on the CLI repo and maybe tag in Alloy or Orta.

Salakar avatar Jan 15 '20 22:01 Salakar

Same fix as above for Crashlytics module when getting this error:

Adding a custom script phase for Pod RNFBCrashlytics: [RNFB] Crashlytics Configuration

[!] Invalid `Podfile` file: [!] Script phases cannot be added to abstract targets..

 #  from /Users/gabriel/Code/seal/seal-jobs-frontend/apps/employee-native/ios/Podfile:51
 #  -------------------------------------------
 #
 >    use_native_modules!
 #  end
 #  -------------------------------------------
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Edit node_modules/@react-native-firebase/crashlytics/react-native.config.js

diff --git a/node_modules/@react-native-firebase/crashlytics/react-native.config.js b/node_modules/@react-native-firebase/crashlytics/react-native.config.js
index 213e7e9..b2c6fd3 100644
--- a/node_modules/@react-native-firebase/crashlytics/react-native.config.js
+++ b/node_modules/@react-native-firebase/crashlytics/react-native.config.js
@@ -17,15 +17,6 @@
 module.exports = {
   dependency: {
     platforms: {
-      ios: {
-        scriptPhases: [
-          {
-            name: '[RNFB] Crashlytics Configuration',
-            path: './ios_config.sh',
-            execution_position: 'after_compile',
-          },
-        ],
-      },
     },
   },
 };

Add script phases manually to each targets:

[RNFB] Crashlytics Configuration

../node_modules/@react-native-firebase/crashlytics/ios_config.sh

gabrielbull avatar Feb 12 '20 16:02 gabrielbull

I've sent up a PR for the CLI that fixes this: https://github.com/react-native-community/cli/pull/982 which has now been merged.

Would appreciate if anyone can try it out, in the meantime I'm going to go ahead and close this issue. Thanks for the report

Salakar avatar Feb 16 '20 19:02 Salakar