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

iOS build failed in release mode #866

Closed
ra1nj opened this issue Jan 13, 2025 · 5 comments
Closed

iOS build failed in release mode #866

ra1nj opened this issue Jan 13, 2025 · 5 comments
Assignees
Labels
status:confirmed The issue has been reviewed and all necessary information is provided. type:bug A bug report.

Comments

@ra1nj
Copy link
Contributor

ra1nj commented Jan 13, 2025

Describe the bug

After upgraded to repack5.0, the debug mode is fine, but once i run the app with release mode, the build is failing:

UnableToResolveError: Unable to resolve module app1/App from /Users/xxx/Repack/RepackHost/App.tsx: app1/App could not be found within the project or in these directories:

System Info

.

Re.Pack Version

5.0.rc.2

Reproduction

https://github.com/ra1nj/RepackHost/tree/repack_5.0

Steps to reproduce

Clone reproduce repo and install deps then run in release mode

@ra1nj ra1nj added status:new New issue, not reviewed by the team yet. type:bug A bug report. labels Jan 13, 2025
@jbroma jbroma added status:investigating The issue needs more research and information. and removed status:new New issue, not reviewed by the team yet. labels Jan 13, 2025
@jbroma jbroma self-assigned this Jan 13, 2025
@jbroma jbroma added status:confirmed The issue has been reviewed and all necessary information is provided. and removed status:investigating The issue needs more research and information. labels Jan 13, 2025
@jbroma
Copy link
Member

jbroma commented Jan 14, 2025

I've managed to confirm this and this needs to be fixed in 2 places:

  • platform setup (since RN 76 changed some CLI commands used when bundling for releasing)
  • RepackTargetPlugin needs some reworking to always include ScriptManager no matter what

@jbroma
Copy link
Member

jbroma commented Jan 20, 2025

hi @ra1nj, the 5.0.0-rc.7 is out which should fix the issue you were having, let me know if this fixes the problem for you so we can close this issue 👍

@ra1nj
Copy link
Contributor Author

ra1nj commented Jan 21, 2025

I have upgraded the repack version to 5.0.0-rc.7 and pod install, but still facing the same issue:

/Users/vn564c0/.nvm/versions/node/v20.5.1/bin/node /Users/vn564c0/Repack/RepackHost/node_modules/react-native/scripts/bundle.js webpack-bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/vn564c0/Library/Developer/Xcode/DerivedData/RepackHost-curtkupfvqvvmyaqkkdcwvttwpmj/Build/Products/Release-iphonesimulator/main.jsbundle --assets-dest /Users/vn564c0/Library/Developer/Xcode/DerivedData/RepackHost-curtkupfvqvvmyaqkkdcwvttwpmj/Build/Products/Release-iphonesimulator/RepackHost.app --minify false --config-cmd '/Users/vn564c0/.nvm/versions/node/v20.5.1/bin/node  /Users/vn564c0/Repack/RepackHost/node_modules/react-native/cli.js config'
 WARN  the transform cache was reset.
                Welcome to Metro v0.81.0
              Fast - Scalable - Integrated


/Users/vn564c0/Repack/RepackHost/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:148
        throw new UnableToResolveError(
              ^

UnableToResolveError: Unable to resolve module app1/App from /Users/vn564c0/Repack/RepackHost/App.tsx: 

It seems that it still using metro as bundler ?

@jbroma
Copy link
Member

jbroma commented Jan 21, 2025

I have upgraded the repack version to 5.0.0-rc.7 and pod install, but still facing the same issue:

/Users/vn564c0/.nvm/versions/node/v20.5.1/bin/node /Users/vn564c0/Repack/RepackHost/node_modules/react-native/scripts/bundle.js webpack-bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/vn564c0/Library/Developer/Xcode/DerivedData/RepackHost-curtkupfvqvvmyaqkkdcwvttwpmj/Build/Products/Release-iphonesimulator/main.jsbundle --assets-dest /Users/vn564c0/Library/Developer/Xcode/DerivedData/RepackHost-curtkupfvqvvmyaqkkdcwvttwpmj/Build/Products/Release-iphonesimulator/RepackHost.app --minify false --config-cmd '/Users/vn564c0/.nvm/versions/node/v20.5.1/bin/node  /Users/vn564c0/Repack/RepackHost/node_modules/react-native/cli.js config'
 WARN  the transform cache was reset.
                Welcome to Metro v0.81.0
              Fast - Scalable - Integrated


/Users/vn564c0/Repack/RepackHost/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:148
        throw new UnableToResolveError(
              ^

UnableToResolveError: Unable to resolve module app1/App from /Users/vn564c0/Repack/RepackHost/App.tsx: 

It seems that it still using metro as bundler ?

sorry for an oversight, one thing you have to change in the project is the script for Bundle React Native code and images build phase in Xcode, replace it with the following:

set -e

if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then
  source "$PODS_ROOT/../.xcode.env"
fi

if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
  source "$PODS_ROOT/../.xcode.env.local"
fi

export CLI_PATH="$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@react-native-community/cli/package.json')) + '/build/bin.js'")"

WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"

This basically points to RNC CLI explicitly instead of relying on the logic in core - which was broken in RN 76 and doesn't allow for overriding the commands out of the box

@ra1nj
Copy link
Contributor Author

ra1nj commented Jan 21, 2025

I have upgraded the repack version to 5.0.0-rc.7 and pod install, but still facing the same issue:

/Users/vn564c0/.nvm/versions/node/v20.5.1/bin/node /Users/vn564c0/Repack/RepackHost/node_modules/react-native/scripts/bundle.js webpack-bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/vn564c0/Library/Developer/Xcode/DerivedData/RepackHost-curtkupfvqvvmyaqkkdcwvttwpmj/Build/Products/Release-iphonesimulator/main.jsbundle --assets-dest /Users/vn564c0/Library/Developer/Xcode/DerivedData/RepackHost-curtkupfvqvvmyaqkkdcwvttwpmj/Build/Products/Release-iphonesimulator/RepackHost.app --minify false --config-cmd '/Users/vn564c0/.nvm/versions/node/v20.5.1/bin/node  /Users/vn564c0/Repack/RepackHost/node_modules/react-native/cli.js config'
 WARN  the transform cache was reset.
                Welcome to Metro v0.81.0
              Fast - Scalable - Integrated


/Users/vn564c0/Repack/RepackHost/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:148
        throw new UnableToResolveError(
              ^

UnableToResolveError: Unable to resolve module app1/App from /Users/vn564c0/Repack/RepackHost/App.tsx: 

It seems that it still using metro as bundler ?

sorry for an oversight, one thing you have to change in the project is the script for Bundle React Native code and images build phase in Xcode, replace it with the following:

set -e

if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then
source "$PODS_ROOT/../.xcode.env"
fi

if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
source "$PODS_ROOT/../.xcode.env.local"
fi

export CLI_PATH="$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@react-native-community/cli/package.json')) + '/build/bin.js'")"

WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
This basically points to RNC CLI explicitly instead of relying on the logic in core - which was broken in RN 76 and doesn't allow for overriding the commands out of the box

After this change, now is working👍

@ra1nj ra1nj closed this as completed Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:confirmed The issue has been reviewed and all necessary information is provided. type:bug A bug report.
Projects
None yet
Development

No branches or pull requests

2 participants