lugg / react-native-config

Bring some 12 factor love to your mobile apps!
MIT License
4.8k stars 658 forks source link

Build input file cannot be found with Xcode 14 #683

Open CuongNguyenV opened 2 years ago

CuongNguyenV commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

Same problem here, any idea how to solve it?

anhquan291 commented 1 year ago

Facing the same issue. Any solutions yet guys? Thanks

SYoder1 commented 1 year ago

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

derrh commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

sunweiyang commented 1 year ago

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 commented 1 year ago

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

ajaykumar97 commented 1 year ago

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 commented 1 year ago

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

EXCLUDED_ARCHS = arm64 ; which I removed, then started working

luancurti commented 1 year ago

Working in 1.4.11 version

Drckk commented 1 year ago

Switching the scheme works for me

whalemare commented 1 year ago

Switching the scheme works for me

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

kulor commented 1 year ago

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 commented 1 year ago

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

Thanks is advance.

tudor-alexa99 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 9 months ago

I found solution for this.

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

benevolentsocialplanner commented 6 months ago

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 commented 3 months ago

pod install