react-native-web-monorepo icon indicating copy to clipboard operation
react-native-web-monorepo copied to clipboard

Failed to run debug from XCode

Open fortezhuo opened this issue 3 years ago • 3 comments

I have found some issue while running debug from XCode

Step to reproduce

  1. Clone this repo
  2. Yarn install and pod install
  3. Open XCode and run with Simulator Iphone 11

And here the error

To reload the app press "r"
To open developer menu press "d"

Error: Unable to resolve module `./index` from ``: 

None of these files exist:
  * index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  * index/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
    at ModuleResolver.resolveDependency (/Users/forte/Workspace/monorepo/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/Users/forte/Workspace/monorepo/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/forte/Workspace/monorepo/node_modules/metro/src/node-haste/DependencyGraph.js:287:16)
    at /Users/forte/Workspace/monorepo/node_modules/metro/src/lib/transformHelpers.js:267:42
    at Server.<anonymous> (/Users/forte/Workspace/monorepo/node_modules/metro/src/Server.js:841:41)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/forte/Workspace/monorepo/node_modules/metro/src/Server.js:99:24)
    at _next (/Users/forte/Workspace/monorepo/node_modules/metro/src/Server.js:119:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Environment :

System:
    OS: macOS 11.2.2
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 119.64 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.0 - /var/folders/lh/qcjd3k_d0279sz5vgvf59tmc0000gn/T/yarn--1615371724201-0.584219214210274/node
    Yarn: 1.22.10 - /var/folders/lh/qcjd3k_d0279sz5vgvf59tmc0000gn/T/yarn--1615371724201-0.584219214210274/yarn
    npm: 6.14.11 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      Android NDK: 17.1.4828580
  IDEs:
    Android Studio: Not Found
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
✨  Done in 16.55s.
✨  Done in 18.38s.

fortezhuo avatar Mar 10 '21 10:03 fortezhuo

Are you able to get it work ? I think path in your AppDelegate.m file is not correct for "index" file.

devfsmalik avatar Apr 19 '21 10:04 devfsmalik

I can make it work by using packages/mobile/index instead. But reanimated v2 babel plugin can't be load properly

#ifdef FB_SONARKIT_ENABLED
  return
      [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/mobile/index"
                                                     fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main"
                                 withExtension:@"jsbundle"];
#endif

fortezhuo avatar Apr 19 '21 11:04 fortezhuo

I could get a build doing 2 changes:

  1. in Build phases changed Bundle React Native code and images script to:
set -e

export NODE_BINARY=node
export PROJECT_ROOT=$PWD/.. 
../../../node_modules/react-native/scripts/react-native-xcode.sh
  1. Changed file format: {root_project}/packages/mobile/index.tsx for {root_project}/packages/mobile/index.js

joae avatar May 15 '21 00:05 joae