facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.96k stars 24.31k forks source link

0.73.1 iOS build failed on Apple Silicon Mac(M1 Pro), but I can do build on 0.72.4 version of React Native #42147

Closed harbolaez closed 9 months ago

harbolaez commented 9 months ago

Old Version

0.72.4

New Version

0.73.1

Description

I'm trying to upgrade to latest version and getting

Generating Pods project
Setting USE_HERMES build settings
Setting REACT_NATIVE build settings
[!] An error occurred while processing the post-install hook of the Podfile.

[!] The plist file at path `/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/kepit-development-Info.plist` doesn't exist.

/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/xcodeproj-1.22.0/lib/xcodeproj/plist.rb:17:in `read_from_path'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/node_modules/react-native/scripts/cocoapods/utils.rb:553:in `block in update_ats_in_plist'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/node_modules/react-native/scripts/cocoapods/utils.rb:551:in `each'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/node_modules/react-native/scripts/cocoapods/utils.rb:551:in `update_ats_in_plist'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/node_modules/react-native/scripts/cocoapods/utils.rb:575:in `apply_ats_config'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/node_modules/react-native/scripts/react_native_pods.rb:310:in `react_native_post_install'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/Podfile:99:in `block (3 levels) in from_ruby'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-core-1.12.1/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:1013:in `run_podfile_post_install_hook'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:149:in `message'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/user_interface.rb:64:in `section'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:315:in `create_and_save_projects'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:307:in `generate_pods_project'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:183:in `integrate'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/installer.rb:170:in `install!'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/command/install.rb:52:in `run'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:52:in `run'
/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/vendor/bundle/ruby/3.2.0/gems/cocoapods-1.12.1/bin/pod:55:in `<top (required)>'
/Users/harbolaez/.rvm/gems/ruby-3.2.1/bin/pod:25:in `load'
/Users/harbolaez/.rvm/gems/ruby-3.2.1/bin/pod:25:in `<main>'
/Users/harbolaez/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `eval'
/Users/harbolaez/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `<main>'

I'm not sure why is doing /Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/kepit-development-Info.plist

Steps to reproduce

I have deleted ndoe_modules, yarn.lock, Podfile.lock. and ran pod deintegrate; pod update; pod install

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 13.4.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 635.14 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: ~/.nvm/versions/node/v20.9.0/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nvm/versions/node/v20.9.0/bin/yarn
  npm:
    version: 10.1.0
    path: ~/.nvm/versions/node/v20.9.0/bin/npm
  Watchman:
    version: 2023.08.14.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/harbolaez/.rvm/gems/ruby-3.2.1/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.11090377
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 19.0.2
    path: /usr/bin/javac
  Ruby:
    version: 3.2.1
    path: /Users/harbolaez/.rvm/rubies/ruby-3.2.1/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

### Stacktrace or Logs

```text
NA

Reproducer

na

Screenshots and Videos

No response

github-actions[bot] commented 9 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
cortinico commented 9 months ago

[!] The plist file at path /Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/kepit-development-Info.plist doesn't exist.

The error message is clear, your build is trying to access a file that doens't exist. We can't help without a reproducer (or by looking at your code)

jayscottthomas commented 9 months ago

Hi, I had same problem. To solve this, I did some changes in one ruby file. In //node_modules/react-native/scripts/cocoapods/utils.rb line 553, change the line plist = Xcodeproj::Plist.read_from_path(fullPlistPath) with plist = Xcodeproj::Plist.read_from_path(plistPath.path)

and go to line 566, change the line Xcodeproj::Plist.write_to_path(plist, fullPlistPath) with Xcodeproj::Plist.write_to_path(plist, plistPath.path)

delphinebugner commented 9 months ago

I have the same error on CD, using Firebase.

After the pod install, getting the error :

Setting REACT_NATIVE build settings
[!] An error occurred while processing the post-install hook of the Podfile.

[!] The plist file at path `/Users/runner/work/mobile-news/mobile-news/ios/mobileNews/GoogleService-Info.plist` doesn't exist.

The error is located in the post_install function of the podfile, when executing the update_ats_in_plist: it looks for any file terminating by Info.plist to modify their NSAllowsArbitraryLoads, NSAppTransportSecurity... properly.

But I have 3 customs GoogleService-Info.plist for my 3 environnements :

image

The matching is made in the build phase - here an extract of my pbxproj:

        93E6EB9EE4D3433C96007083 /* Set environment GoogleService-Info.plist */ = {
            isa = PBXShellScriptBuildPhase;
            buildActionMask = 2147483647;
            files = (
            );
            inputFileListPaths = (
            );
            inputPaths = (
            );
            name = "Set environment GoogleService-Info.plist";
            outputFileListPaths = (
            );
            outputPaths = (
                "$(PROJECT_DIR)/$(PROJECT_NAME)/GoogleService-Info.plist",
            );
            runOnlyForDeploymentPostprocessing = 0;
            shellPath = /bin/sh;
            shellScript = "cp ${PROJECT_NAME}/GoogleService-Info.${ENV}.plist ${PROJECT_NAME}/GoogleService-Info.plist\n";
        };

So in the post_install function, the GoogleService-Info.plist does not yet exists and the Xcodeproj::Plist.read_from_path(fullPlistPath) fails.

@harbolaez I guess it's the same for you, as you have a kepit-development-Info.plist -> a plist for your development env, matched later to its real value.

@jayscottthomas changing for the initial path without the parent does not fix in our case.

Different ideas for the fix:

@philIip as you are the author of the initial PR https://github.com/facebook/react-native/pull/38086, do you have any insight on it?

delphinebugner commented 9 months ago

I don't think not modifying the GoogleService-Info.plist will be a problem on second thoughts ; it's literally what was happening when I deployed locally - post_install modified the gitignored GoogleService-Info.plist copied in a previous build, then on the build phase it was erased and replaced by the unmodified GoogleService-Info.production.plist.

So here's the patch - may open a PR with it: react-native+0.73.2.patch

focux commented 9 months ago

We are experiencing the same error as OP and @delphinebugner's patch worked flawlessly, thanks!

In my case, and as I see in the OP's post, it's computing the wrong path for one of my target's info plist. As you see in OPs, it's concatenating the ios folder path twice:

[!] The plist file at path `/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/Users/harbolaez/Desktop/code/personal/kepit-apps/kepit/ios/kepit-development-Info.plist

ngdlmk commented 9 months ago

Hi, I had same problem. To solve this, I did some changes in one ruby file. In //node_modules/react-native/scripts/cocoapods/utils.rb line 553, change the line plist = Xcodeproj::Plist.read_from_path(fullPlistPath) with plist = Xcodeproj::Plist.read_from_path(plistPath.path)

and go to line 566, change the line Xcodeproj::Plist.write_to_path(plist, fullPlistPath) with Xcodeproj::Plist.write_to_path(plist, plistPath.path)

this solution is working fine. When you create a new scheme and try to make the pod install this issue occurs for me

delphinebugner commented 7 months ago

Note: after bumping to react-native 0.73.6, patch is no longer need 🎉 issue fixed!