You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:iOS Release构建报错Module AppRegistry未注册为可调用模块,Debug正常

Fixing "Module AppRegistry is not a registered callable module" in iOS Release Builds

Hey there, I’ve dealt with this exact head-scratcher before—when your React Native iOS app works flawlessly in Debug but throws that AppRegistry error only in Release mode, it’s usually tied to bundling or build configuration quirks. Here are the steps that fixed it for me and other devs:

  • Validate your Release bundling setup
    A common issue is that the Release build isn’t properly generating or using the JS bundle. Try manually creating the bundle first:

    npx react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle --assets-dest ios/assets
    

    Then check your Xcode project:

    • Go to your target’s Build Phases and confirm the Bundle React Native code and images script is present and runs without errors.
    • In Build Settings, ensure JS_BUNDLE_PATH is set to $(BUILT_PRODUCTS_DIR)/$(PRODUCT_NAME).app/main.jsbundle.
  • Double-check AppRegistry registration
    It sounds obvious, but typos or missing registration in your entry file (like index.js) can only show up in Release mode. Verify your code looks like this:

    import { AppRegistry } from 'react-native';
    import App from './App';
    import { name as appName } from './app.json';
    
    AppRegistry.registerComponent(appName, () => App);
    

    Make sure the appName matches exactly what’s in your app.json—even a small typo can break Release bundling.

  • Test with Hermes disabled (if using it)
    Hermes engine can sometimes have Debug/Release inconsistencies. Try disabling it in your ios/Podfile:

    use_react_native!(
      :path => config[:reactNativePath],
      :hermes_enabled => false # Set to false temporarily
    )
    

    Run pod install and rebuild your Release build. If it works, consider updating Hermes or checking compatibility with your React Native version.

  • Wipe build caches and artifacts
    Stale caches are a frequent culprit for Release-only bugs. Run these commands to start fresh:

    # Clean Xcode Release build
    xcodebuild clean -workspace YourApp.xcworkspace -scheme YourApp -configuration Release
    # Reset React Native metro cache
    npx react-native start --reset-cache
    # Reinstall iOS pods
    cd ios && pod deintegrate && pod install && cd ..
    

    Then rebuild your Release build from scratch in Xcode.

  • Check for tree-shaking removing AppRegistry
    Release mode uses aggressive tree-shaking, which might incorrectly flag AppRegistry as unused. If all else fails, try adding a dummy reference to AppRegistry somewhere in your code to prevent it from being stripped (this is a last resort, but can help confirm if tree-shaking is the issue).

One of these steps should resolve the error—start with the bundling check since that’s the most common fix for this specific issue!

内容的提问来源于stack exchange,提问作者beretis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:20:35