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

Build input file cannot be found with Xcode 14 #683

Open
CuongNguyenV opened this issue Sep 19, 2022 · 24 comments
Open

Build input file cannot be found with Xcode 14 #683

CuongNguyenV opened this issue Sep 19, 2022 · 24 comments

Comments

@CuongNguyenV
Copy link

I was able to build different environments using Xcode 13, but after updating to Xcode 14, I got this error:
error build: Build input file cannot be found: '/Users/user/Library/Developer/Xcode/DerivedData/.../Build/Products/GeneratedInfoPlistDotEnv.h'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?

Any ideas? Thanks in advance!!

Xcode version: 14.0
react-native: 0.67.4
react-native-config: 1.4.6
@albat
Copy link

albat commented Sep 19, 2022

Same issue on my side, project is working fine on XCode 13 and get the same error with XCode 14.
Tried to upgrade to 1.4.7 but doesn't changed anything.
Also tried to build with legacy build settings, doesn't helped neither :/

@CuongNguyenV
Copy link
Author

Same issue on my side, project is working fine on XCode 13 and get the same error with XCode 14. Tried to upgrade to 1.4.7 but doesn't changed anything. Also tried to build with legacy build settings, doesn't helped neither :/

My workaround is back to Xcode 13, hope it helps your case @albat

@victor-gil
Copy link

Same problem here, any idea how to solve it?

@anhquan291
Copy link

Facing the same issue. Any solutions yet guys? Thanks

@SYoder1
Copy link

SYoder1 commented Sep 20, 2022

I am facing the same issues too. I really don’t want to revert back to XCode 13

@derrh
Copy link

derrh commented Sep 20, 2022

We were able to work around this issue. In our case, because the .podspec file doesn't list $BUILD_DIR/GeneratedInfoPlistDotEnv.h as an output_file in its [CP-User] Config codegen Run Script phase, Xcode was not building react-native-config early enough. This caused our app target to fail because the header file had not been generated yet. Adding an output_files entry to the .podspec fixes this issue.

Here is a patch if you're using patch-package:

$ cat patches/react-native-config+1.4.6.patch

diff --git a/node_modules/react-native-config/react-native-config.podspec b/node_modules/react-native-config/react-native-config.podspec
index 54985dd..854bfe7 100644
--- a/node_modules/react-native-config/react-native-config.podspec
+++ b/node_modules/react-native-config/react-native-config.podspec
@@ -25,7 +25,8 @@ HOST_PATH="$SRCROOT/../.."
 "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$HOST_PATH" "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig"
 ),
     execution_position: :before_compile,
-    input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb']
+    input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb'],
+    output_files: ['$BUILD_DIR/GeneratedInfoPlistDotEnv.h']
   }
 
   s.requires_arc = true

We also had updated from a previous version of react-native-config which was generating the header file in a different location. As a result, we also had to update our Info.plist Preprocessor Prefix File build setting to point to the new location $(BUILD_DIR)/GeneratedInfoPlistDotEnv.h
image

@hank619
Copy link

hank619 commented Sep 21, 2022

From my case, since we din't use the feature of Availability in Build settings and Info.plist, we just removed the INFOPLIST_PREFIX_HEADER and it works, just like this solution

@anhquan291
Copy link

anhquan291 commented Sep 21, 2022

@derrh
Update:
Thank you so much. It works. However, I cannot get the the variable from env in XCode any more :'(.

@sunweiyang
Copy link

sunweiyang commented Sep 21, 2022

I have applied the patch recommended by @derrh but it does not resolve this issue for me.

Xcode version: 14.0
react-native: 0.68.2
react-native-config: 1.4.6

@xgenem
Copy link

xgenem commented Sep 22, 2022

Experienced the issue today but didn't really do anything other than try to Archive again and it went away.

@ajaykumar97
Copy link

After spending hours of debugging, I ended up downgrading to the Xcode 13. It was the only solution for me as of now. When I compared the file changes since the last time the build was successfully archived, I observed that there were some code changes made by the Xcode 14(when I ran the build in it) in the file ios/<project_name>.xcodeproj/project.pbxproj something like:

/* ReactNativeConfig.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeConfig.xcodeproj; path = "../node_modules/react-native-config/ios/ReactNativeConfig.xcodeproj"; sourceTree = "<group>"; };

and

/* libReactNativeConfig.a in Frameworks */,

There were a couple more related to ReactNativeConfig.xcodeproj.

I reverted those, downgraded to Xcode 13, deleted Derived Data, tried archiving again and this time, it was successful.

1 more thing, I recently switched to the M2 Mac from Intel-Based Mac(last successful Archive was on Intel-Based Mac). I am not sure if that has anything to do with this issue.

I hope it will be helpful for someone.

@naheed-shamim
Copy link

naheed-shamim commented Sep 29, 2022

For me, in ios/.xcodeproj/project.pbxproj,

EXCLUDED_ARCHS = arm64 ;
which I removed, then started working

@luancurti
Copy link
Collaborator

Working in 1.4.11 version

@Drckk
Copy link

Drckk commented Dec 16, 2022

Switching the scheme works for me

@whalemare
Copy link

whalemare commented Apr 19, 2023

Switching the scheme works for me

Thank you, sir! When I explicitly set --scheme NAME flag, build is succeed

@kulor
Copy link

kulor commented Jun 15, 2023

I found my own solution (using an old version of React Native):

Added this to the "Bundle React Native Code And Images" phase (which contains the script node_modules/react-native/scripts/react-native-xcode.sh:

outputPaths = (
"${BUILD_DIR}/GeneratedInfoPlistDotEnv.h"
);

@sajibsaha4647
Copy link

Same problem what should i do for it . please help..

Thanks is advance.

@tudor-alexa99
Copy link

tudor-alexa99 commented Jul 5, 2023

Intel based Mac here, XCode 14 MacOS Ventura.
The issue happened to me when switching branches. Apparently there is an issue if you create new files / groups (aka folders) or you move a file from one group to another, and then you change branches to another one where the folder has not been created.

I fixed it by deleting the Derived Data folder, and cleaning the build folder.

  1. Open Finder -> On the top press Go -> Library -> Developer -> XCode and delete the DerivedData Folder
  2. Command - Shift - K on XCode to clean build folder

Hope that helps fix the issue or at least determine why it happens to you 🙏

@inkcrazy666
Copy link

inkcrazy666 commented Jul 10, 2023

i have same issue.

Build input file cannot be found: '/Users/inkcrazy/Library/Developer/Xcode/DerivedData/Daling-arvboeyqyunjixcoavidvtbyfrru/Build/Intermediates.noindex/ArchiveIntermediates/Daling/InstallationBuildProductsLocation/Applications/Daling.app/Daling'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?

i change

-"EXCLUDED_ARCHS[sdk=*]" = arm64;
+"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;

66f8f100b472cd5f48301b02b747056f

@jorgeovejero913
Copy link

I found my own solution (using an old version of React Native):

Added this to the "Bundle React Native Code And Images" phase (which contains the script node_modules/react-native/scripts/react-native-xcode.sh:

outputPaths = (
"${BUILD_DIR}/GeneratedInfoPlistDotEnv.h"
);

Worked for me!!!!

@sinau123
Copy link

sinau123 commented Jul 24, 2023

I found my own solution (using an old version of React Native):

Added this to the "Bundle React Native Code And Images" phase (which contains the script node_modules/react-native/scripts/react-native-xcode.sh:

outputPaths = (
"${BUILD_DIR}/GeneratedInfoPlistDotEnv.h"
);

work for me too,

@shaileshpendams
Copy link

I found solution for this.

https://youtu.be/cteLpAN6d7U?si=vskcHfd3uUEDNgLW

@benevolentsocialplanner

We were able to work around this issue. In our case, because the .podspec file doesn't list $BUILD_DIR/GeneratedInfoPlistDotEnv.h as an output_file in its [CP-User] Config codegen Run Script phase, Xcode was not building react-native-config early enough. This caused our app target to fail because the header file had not been generated yet. Adding an output_files entry to the .podspec fixes this issue.

Here is a patch if you're using patch-package:

$ cat patches/react-native-config+1.4.6.patch

diff --git a/node_modules/react-native-config/react-native-config.podspec b/node_modules/react-native-config/react-native-config.podspec
index 54985dd..854bfe7 100644
--- a/node_modules/react-native-config/react-native-config.podspec
+++ b/node_modules/react-native-config/react-native-config.podspec
@@ -25,7 +25,8 @@ HOST_PATH="$SRCROOT/../.."
 "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig/BuildDotenvConfig.rb" "$HOST_PATH" "${PODS_TARGET_SRCROOT}/ios/ReactNativeConfig"
 ),
     execution_position: :before_compile,
-    input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb']
+    input_files: ['$PODS_TARGET_SRCROOT/ios/ReactNativeConfig/BuildDotenvConfig.rb'],
+    output_files: ['$BUILD_DIR/GeneratedInfoPlistDotEnv.h']
   }
 
   s.requires_arc = true

We also had updated from a previous version of react-native-config which was generating the header file in a different location. As a result, we also had to update our Info.plist Preprocessor Prefix File build setting to point to the new location $(BUILD_DIR)/GeneratedInfoPlistDotEnv.h image

can't understand what should i do... i still get the same err

@jaswant-iotric
Copy link

pod install

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

No branches or pull requests