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

[0.75.0-rc.2]: regression on linking iOS dependencies with script phase (e.g. RN Firebase): #341

Closed
imWildCat opened this issue Jun 27, 2024 · 21 comments

Comments

@imWildCat
Copy link

Old Version

0.74.x

New Version

0.75.0-rc2

Description

Not sure whether rc1 has this problem as well. I found this problem while upgrading from 0.74.x to 0.75.x

Error:

➜  ios git:(main) pod install
RNFBAnalytics: Using default Firebase/Analytics with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps.
RNFBAnalytics: You may set variable `$RNFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids.
Found 3 modules for target `AwesomeProject7`
link_native_modules! {:ios_packages=>[{:configurations=>[], :name=>"@react-native-firebase/analytics", :path=>"../node_modules/@react-native-firebase/analytics", :podspec_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec", :script_phases=>[]}, {:configurations=>[], :name=>"@react-native-firebase/app", :path=>"../node_modules/@react-native-firebase/app", :podspec_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/node_modules/@react-native-firebase/app/RNFBApp.podspec", :script_phases=>[{"name"=>"[RNFB] Core Configuration", "path"=>"./ios_config.sh", "execution_position"=>"after_compile", "input_files"=>["$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)"]}]}, {:configurations=>[], :name=>"react-native-svg", :path=>"../node_modules/react-native-svg", :podspec_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/node_modules/react-native-svg/RNSVG.podspec", :script_phases=>[]}], :ios_project_root_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/ios", :react_native_path=>"../node_modules/react-native"}
RNFBAnalytics: Using default Firebase/Analytics with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps.
RNFBAnalytics: You may set variable `$RNFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids.
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration

[!] Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Volumes/QuickMac/temp/202406/AwesomeProject7/ios/ios_config.sh.

 #  from /Volumes/QuickMac/temp/202406/AwesomeProject7/ios/Podfile:18
 #  -------------------------------------------
 #  target 'AwesomeProject7' do
 >    config = use_native_modules!
 #  

I thought it was something like pnpm workspace but it is not.

Steps to reproduce

  1. git clone https://github.com/imWildCat-archived/react-native-075-rc2-regression-ios-linking-script-phase
  2. cd react-native-075-rc2-regression-ios-linking-script-phase
  3. yarn install
  4. cd ios
  5. pod install

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info

➜  AwesomeProject7 git:(main) yarn react-native info                                              
info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (10) arm64 Apple M1 Max
  Memory: 218.66 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.14.0
    path: /private/var/folders/j8/0c4r57j93w1fgrwhr31z6z_c0000gn/T/xfs-94018d4a/node
  Yarn:
    version: 3.6.4
    path: /private/var/folders/j8/0c4r57j93w1fgrwhr31z6z_c0000gn/T/xfs-94018d4a/yarn
  npm:
    version: 10.7.0
    path: /opt/homebrew/opt/node@20/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/wildcat/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    Android NDK: 26.1.10909125
IDEs:
  Android Studio: 2024.1 AI-241.15989.150.2411.11948838
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 3.3.2
    path: /Users/wildcat/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.0.0-rc-fb9a90fa48-20240614
    wanted: 19.0.0-rc-fb9a90fa48-20240614
  react-native:
    installed: 0.75.0-rc.2
    wanted: 0.75.0-rc.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true


### Stacktrace or Logs

```text
➜  ios git:(main) pod install
RNFBAnalytics: Using default Firebase/Analytics with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps.
RNFBAnalytics: You may set variable `$RNFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids.
Found 3 modules for target `AwesomeProject7`
link_native_modules! {:ios_packages=>[{:configurations=>[], :name=>"@react-native-firebase/analytics", :path=>"../node_modules/@react-native-firebase/analytics", :podspec_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec", :script_phases=>[]}, {:configurations=>[], :name=>"@react-native-firebase/app", :path=>"../node_modules/@react-native-firebase/app", :podspec_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/node_modules/@react-native-firebase/app/RNFBApp.podspec", :script_phases=>[{"name"=>"[RNFB] Core Configuration", "path"=>"./ios_config.sh", "execution_position"=>"after_compile", "input_files"=>["$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)"]}]}, {:configurations=>[], :name=>"react-native-svg", :path=>"../node_modules/react-native-svg", :podspec_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/node_modules/react-native-svg/RNSVG.podspec", :script_phases=>[]}], :ios_project_root_path=>"/Volumes/QuickMac/temp/202406/AwesomeProject7/ios", :react_native_path=>"../node_modules/react-native"}
RNFBAnalytics: Using default Firebase/Analytics with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps.
RNFBAnalytics: You may set variable `$RNFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids.
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration

[!] Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Volumes/QuickMac/temp/202406/AwesomeProject7/ios/ios_config.sh.

 #  from /Volumes/QuickMac/temp/202406/AwesomeProject7/ios/Podfile:18
 #  -------------------------------------------
 #  target 'AwesomeProject7' do
 >    config = use_native_modules!
 #  
 #  -------------------------------------------


### Reproducer

https://github.com/imWildCat-archived/react-native-075-rc2-regression-ios-linking-script-phase

### Screenshots and Videos

_No response_
@imWildCat
Copy link
Author

imWildCat commented Jun 27, 2024

might be related to #336

and the fix seems to be waiting for cherry-pick facebook/react-native#45165

thank you! please feel free to close this one once confirmed.

@cortinico
Copy link
Collaborator

Thanks for the repro @imWildCat 👍 That's something for @cipolleschi to investigate

@imWildCat
Copy link
Author

Thanks for the quick reply, @cortinico ! ❤️

@cipolleschi
Copy link
Collaborator

@imWildCat have you tried applying the fixes suggested by facebook/react-native#45165 in your repro?
Does it fixes it?

@imWildCat
Copy link
Author

No I haven’t

is there any quick way to apply that diff?

@imWildCat
Copy link
Author

imWildCat commented Jun 27, 2024

I applied facebook/react-native@d3e0430 locally and it does not work:

image

it might happen before codegen I believe

@imWildCat
Copy link
Author

@cipolleschi I checked the git history of the autolinking.rb file but haven't found any bad commit.

Created this PR facebook/react-native#45208

There might be better way

@imWildCat
Copy link
Author

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Jun 27, 2024
Summary:
Since 0.75-rc.x, I cannot run pod install because of an linking issue of react native firebase.

reactwg/react-native-releases#341 (comment)

## Changelog:

[IOS][FIXED] Auto linking script of script phase

Pull Request resolved: #45208

Test Plan: Full demo of this fix: <https://github.com/imWildCat-archived/react-native-075-rc2-regression-ios-linking-script-phase>

Reviewed By: christophpurrer

Differential Revision: D59125585

Pulled By: blakef

fbshipit-source-id: be96d3b207eff67c5e0d777203e7fc0d10103fc0
@cipolleschi
Copy link
Collaborator

cipolleschi commented Jun 28, 2024

closed by facebook/react-native@e320ab4

@mikehardy
Copy link

Oh you beat me to it!! Didn't see this, logged #345
Will close mine. Awesome @imWildCat thank you!

@cortinico
Copy link
Collaborator

Pick request for the fix is here (for reference):

cortinico pushed a commit to facebook/react-native that referenced this issue Jul 1, 2024
Summary:
Since 0.75-rc.x, I cannot run pod install because of an linking issue of react native firebase.

reactwg/react-native-releases#341 (comment)

## Changelog:

[IOS][FIXED] Auto linking script of script phase

Pull Request resolved: #45208

Test Plan: Full demo of this fix: <https://github.com/imWildCat-archived/react-native-075-rc2-regression-ios-linking-script-phase>

Reviewed By: christophpurrer

Differential Revision: D59125585

Pulled By: blakef

fbshipit-source-id: be96d3b207eff67c5e0d777203e7fc0d10103fc0
@matinzd
Copy link

matinzd commented Aug 20, 2024

I guess one of these fixes has caused pod install to fail even in 0.75.2 with monorepos. Is anyone else having this issue?

Output:

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

[!] Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Users/MY_HOME_DIR/work/node_modules/@react-native-firebase/app/ios_config.sh.

 #  from /Users/MY_HOME_DIR/work/kreddy-bare/apps/kreddy-mobile/ios/Podfile:36
 #  -------------------------------------------
 #    use_expo_modules!
 >    config = use_native_modules!
 #    
 #  -------------------------------------------
Warning: command "pod update --project-directory=ios" exited with non-zero status code

Script phase is failing because it's trying to read from the non-existant node_modules folder outside of the monorepo.

I am gonna dig into this to see what has caused this issue.

@matinzd
Copy link

matinzd commented Aug 20, 2024

UPDATE

If I run pod commands with --project-directory=ios outside of ios folder the pod install will fail. This was not happening before 0.75.

My project sturucture:

USE_FRAMEWORKS=static RCT_NEW_ARCH_ENABLED=1 bundle exec pod update --project-directory=ios

- monorepo-root
-- apps
---- kreddy-mobile (running the command here)
------- ios
------- android

@cipolleschi

@cipolleschi
Copy link
Collaborator

@matinzd I just tried spinning up a new project with 0.75.2 and everything works for me.

That's the script I run

npx react-native@latest init TestPodInstall --version next --skip-install
cd TestPodInstall
yarn install
cd ios
bundle install
cd ..
USE_FRAMEWORKS=static RCT_NEW_ARCH_ENABLED=1 bundle exec pod update --project-directory=ios

If you are in a monorepo, there might be something in your specific monorepo setup.

If the problem is:

[!] Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Users/cipolleschi/Tests/node_modules/@react-native-firebase/app/ios_config.sh.

the problem is in Firebase, that is hardcoding the path to @react-native-firebase/app/ios_config.sh here. They should probably do a resolve to look for the right file path.

@matinzd
Copy link

matinzd commented Aug 22, 2024

But it's weird that this was working before 75. That needs to be fixed but I am wondering if there has been some breaking changes with introducing the path.

@cipolleschi
Copy link
Collaborator

uhm, good point. I think it might related to the changes we made with autolinking, then.

@blakef can you chime in here?

@matinzd
Copy link

matinzd commented Aug 22, 2024

Now that there have been changes in auto linking do you think this can be related as well?

software-mansion/react-native-screens#2306

@blakef
Copy link
Collaborator

blakef commented Aug 23, 2024

So this is because before 0.75 we used to use an absolute path instead of a relative path (introduced in #45208). So you get paths looking like this:

CleanShot 2024-08-23 at 16 17 49@2x

You can see how that quickly falls apart when using --project-directory. I'll put up a fix passing the root with the package and using that instead of path.

@blakef
Copy link
Collaborator

blakef commented Aug 23, 2024

Now that there have been changes in auto linking do you think this can be related as well?

software-mansion/react-native-screens#2306

I don't think it's related. This path just affects package scripts AFAIK. For what it's work I added react-native-screens to a basic project on 0.75.2 and it seemed to build fine on iOS.

blakef added a commit to blakef/react-native that referenced this issue Aug 23, 2024
Summary:

A previous attempt at fixing this issue used a relative path (facebook#45208),
this doesn't work if the user runs bundle install outside of the ios/
folder, using the --project-directory=ios argument.

Changelog:
[iOS][Fix] support bundle install from outside the ios folder using --project-directory

Test Plan:
Ran the command in a project with @react-native-firebase/app using the
--project-directory, confirmed that it's fixed when using the absolute
path.

closes: reactwg/react-native-releases#341
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Aug 23, 2024
Summary:
A previous attempt at fixing this issue used a relative path (#45208), this doesn't work if the user runs bundle install outside of the `ios/`
folder, using the `--project-directory=ios` argument.

## Changelog:
[iOS][Fixed] support bundle install from outside the ios folder using --project-directory

Pull Request resolved: #46186

Test Plan:
Ran the command in a project with `react-native-firebase/app` using the
`--project-directory`, confirmed that it's fixed when using the absolute
path.

closes: reactwg/react-native-releases#341

Reviewed By: cipolleschi

Differential Revision: D61719821

Pulled By: blakef

fbshipit-source-id: d83429dd29c9e8cc066ab9843ad95fdfc0af8dea
@matinzd
Copy link

matinzd commented Aug 24, 2024

Thanks for fixing it the auto-linking issue! 🌸

Have you tried rnscreens with new arch turned on?

@xxsnakerxx
Copy link

- phase["script"] = File.read(File.expand_path(phase["path"], package[:path]))
+ phase["script"] = File.read(File.expand_path(File.join(package[:path], phase["path"]), ios_project_root))

cipolleschi pushed a commit to facebook/react-native that referenced this issue Sep 11, 2024
Summary:
A previous attempt at fixing this issue used a relative path (#45208), this doesn't work if the user runs bundle install outside of the `ios/`
folder, using the `--project-directory=ios` argument.

## Changelog:
[iOS][Fixed] support bundle install from outside the ios folder using --project-directory

Pull Request resolved: #46186

Test Plan:
Ran the command in a project with `react-native-firebase/app` using the
`--project-directory`, confirmed that it's fixed when using the absolute
path.

closes: reactwg/react-native-releases#341

Reviewed By: cipolleschi

Differential Revision: D61719821

Pulled By: blakef

fbshipit-source-id: d83429dd29c9e8cc066ab9843ad95fdfc0af8dea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done / Picked
Development

Successfully merging a pull request may close this issue.

7 participants