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

No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application bundle. unsanitizedScriptURLString = (null) #49245

Closed
TonyFTannous-Byd opened this issue Feb 7, 2025 · 14 comments

Comments

@TonyFTannous-Byd
Copy link

TonyFTannous-Byd commented Feb 7, 2025

Description

I upgrade my react native app from 0.76.6 to 0.77.0. The build has successfully but i have the following error in ios platform (android go well)

No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application bundle.

unsanitizedScriptURLString = (null)

Steps to reproduce

  1. install the repo
  2. npm install
  3. cd ios && pod install
  4. npm run start:clean
  5. npm run android:local (it work no problem)
  6. npm run ios:local it build successfully but during the launching app, the screen crash with the following error:
    No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application bundle.
    unsanitizedScriptURLString = (null)

React Native Version

0.77.0

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1
  Memory: 111.05 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.1
    path: ~/.nvm/versions/node/v20.18.1/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.2
    path: ~/Documents/AccuV-Team/IDP.Mobile/node_modules/.bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.2
      - 33.0.3
      - 34.0.0
      - 35.0.0
    System Images:
      - android-31 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Google APIs ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.0
    wanted: ^0.77.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application bundle.

unsanitizedScriptURLString = (null)

Reproducer

https://github.com/TonyFTannous-Byd/repo

Screenshots and Videos

Image

@cipolleschi
Copy link
Contributor

I just tried with these instructions:

npx @react-native-community/cli init TestMetroConnection --version latest --skip-install
cd TestMetroConnection
yarn install
cd ios
bundle install
bundle exec pod install
cd ..
yarn ios

This:

  • creates a new RN app on 0.77, using the most basic vanilla setup,
  • installs JS dependencies,
  • installs ruby gems
  • installs pods
  • build and run the ios app, while also starting metro.

This works. So the problem is not in React Native, but in one of the tools you are using in your app.

Image

What are you using for development?
I saw Reactatron and a bunch of environment files. They might change the setup. It could also be that one of those tools are not compatible with the Swift AppDelegate, but we do not maintain them, so I can't help you with that.

Can you try to open an issue in the Reactatron repo, instead?

@TonyFTannous-Byd
Copy link
Author

TonyFTannous-Byd commented Feb 7, 2025

@cipolleschi
ok, i opened an issue in Reactotron (infinitered/reactotron#1539)

i know it work if i create a project from scratch. but i have a big application created already in react native 0.76.6, i upgrade it to 0.77.0. i remove AppDelegate.mm, AppDelegate.h and main.m and i replaced it by AppDelegate.swift (ios platform) as mention upgrade helper (https://react-native-community.github.io/upgrade-helper/)
after the upgrade complete android work properly, but ios has this issue
if i remove AppDelegate.swift and restore the objective C files AppDelegate.mm (with integration of RCTAppDependencyProvider) and AppDelegate.h and main.m IOS work again properly

@gurbuzzomer
Copy link

I am having the same problem with "react-native": "0.76.6" I don't fully understand the reason for the error, it sometimes occurs. To solve this, connect to the physical device with a cable and run "npx expo run ios --device " build again and you are at the place where you are installing it on my device.

note: @TonyFTannous-Byd I don't think reactotron is the cause of this error because I can't use it from the app

@TonyFTannous-Byd
Copy link
Author

@gurbuzzomer
I believe my app includes libraries that contain modules written in C++, which prevents me from registering them in Swift as shown in the guide. My app works properly in React Native 0.76.6, but when I upgrade to 0.77—where switching AppDelegate from Objective-C to Swift is an option—I encounter issues. However, if I keep AppDelegate in Objective-C and implement RCTAppDependencyProvider, the app works properly.

@cipolleschi
Copy link
Contributor

Yes, that could be the case. As mentioned in the blogpost and in the documentation:

If your app has some local modules that are written in C++, you would not be able to use the AppDelegate in Swift that we shipped in React Native 0.77.

You need to keep the Objective-C++ App Delegate

@TonyFTannous-Byd
Copy link
Author

TonyFTannous-Byd commented Feb 18, 2025

@cipolleschi

yes, and if you want to use swift file
(resolve by @OTitaev )

the problem is in DEBUG flag in AppDelegate.swift

override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}

You should add
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";

Inside project.pbxproj in debug XCBuildConfiguration block

Should look like this

83CBBA201A601CBA00E9B192 /* Debug / = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos
]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
);
LIBRARY_SEARCH_PATHS = (
""$(SDKROOT)/usr/lib/swift"",
""$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)"",
""$(inherited)"",
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
};
name = Debug;
};

@cipolleschi
Copy link
Contributor

@TonyFTannous-Byd our Cocoapods scripts should inject that flag for you: https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L422

Make sure to call the react_native_post_install! function in your post_install hook as shown here: https://github.com/react-native-community/template/blob/main/template/ios/Podfile#L28-L33

@TonyFTannous-Byd
Copy link
Author

@cipolleschi
i already called react_native_post_install in my Podfile/post_install hook. but not resolve the issue
check my example: https://github.com/TonyFTannous-Byd/repo/blob/main/ios/Podfile

without adding SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; Inside project.pbxproj in debug XCBuildConfiguration block the issue will not resolved

@elStranger
Copy link

I have the same issue, anyone found how to fix this ?

@Osamasomy
Copy link

Exact same problem! any solution?

@wuduwawawei
Copy link

wuduwawawei commented Feb 27, 2025

When the error occurs, the node server is not started, so you can try the following two methods:

  1. Use the command
yarn react-native run-ios
  1. Start the node server first, then build it with Xcode.
# Start node server
yarn react-native start

I think this problem should be solved by injecting a script. I will add more details after I understand the specific method.

@anujkumar09062001
Copy link

Update your physical ios device software to latest version.

@TonyFTannous-Byd
Copy link
Author

@anujkumar09062001
My device is updated, same issue.

@TonyFTannous-Byd
Copy link
Author

TonyFTannous-Byd commented Mar 4, 2025

@cipolleschi

Hello,

@TonyFTannous-Byd our Cocoapods scripts should inject that flag for you: https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L422

Make sure to call the react_native_post_install! function in your post_install hook as shown here: https://github.com/react-native-community/template/blob/main/template/ios/Podfile#L28-L33

i already called eact_native_post_install as you mention, still same issue.
but i thing the problem is from the multi-configuration i am used (Local.Debug, Local.Release, Dev.Debug, Dev.Release, Production.Debug, Production.Release)

i resolve it by set programatly SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
Inside project.pbxproj in debug XCBuildConfiguration block

post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
      # :ccache_enabled => true
    )

    installer.aggregate_targets.each do |aggregate_target|
       project = aggregate_target.user_project

      project.build_configurations.each do |config|
          # Ensure this is only applied to Debug configurations
          if config.name.downcase.include?("debug")
            config.build_settings['SWIFT_ACTIVE_COMPILATION_CONDITIONS'] ||= '$(inherited) DEBUG'
         end
      end
      project.save
   end
  end

after that cd ios & pod install
and the issue resolved

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

No branches or pull requests

8 participants