React Native: Module AppRegistry is not a registered callable module (calling runApplication) - ios

I am trying to boot up a React Native 0.53.3 app with React 16.2.0 using simulator from Xcode 10.1 on High Sierra.
I previously had some issues that I have since resolved just to get the build to succeed:
npm-shrinkwrap.json: Could not install from "node_modules/react-navigation/react-native-tab-view#github:react-navigation/react-native-tab-view
React Native: ":CFBundleIdentifier", Does Not Exist
Now all build succeed even though I continue to get the cfbundleridentifier error:
Check dependencies
** BUILD SUCCEEDED **
Installing build/Build/Products/Debug-iphonesimulator/NFIBEngage.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/NFIBEngage.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Even in Metro Bundler it succeeds:
Metro Bundler ready.
Loading dependency graph, done.
BUNDLE [ios, dev] ./index.ios.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1667/1667), done.
BUNDLE [ios, dev] ./index.ios.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.
DELTA [ios, dev] ./index.ios.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1667/1667), done.
MAP [ios, dev] ./index.ios.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1667/1667), done.
So I was wondering why my app when launched in simulator would stay stuck in the splashscreen, that usually only happens when an index.ios.js has failed. So I looked at http://localhost:8081/debugger-ui/ and sure enough I saw the following errors:
Module AppRegistry is not a registered callable module (calling runApplication)
Unhandled JS Exception: Cannot read property 'invocationEventNone' of undefined
Unhandled JS Exception: Module AppRegistry is not a registered callable module (calling runApplication)
I don't know where its getting invocationEventNone from, its not anything written in the codebase, I checked.
As far as the `AppRegistry` module, it appears to look fine:
import {AppRegistry} from 'react-native';
import KeyboardManager from 'react-native-keyboard-manager';
import NFIBEngage from './App';
KeyboardManager.setToolbarPreviousNextButtonEnable(true);
AppRegistry.registerComponent('NFIBEngage', () => NFIBEngage);
Has anyone experienced something like this running versions similar to what I am running? What should I be investigating? How to resolve this?
I followed every solution in here:
Module AppRegistry is not registered callable module (calling runApplication)
There was nothing in here that could help:
React Native Module AppRegistry is not a registered callable module
This was not relevant:
React Native(iOS) Module AppRegistry is not a registered callable module (calling runApplication)
Not relevant:
React native AppRegistry is not a callable module
I then tried following the solution offered by iDevAmit here:
React-Native: Module AppRegistry is not a registered callable module
but it appears my iOS which is what I am interested in running right now, is already linked according to this output:
rnpm-install info Platform 'ios' module appcenter is already linked
rnpm-install info Linking appcenter android dependency
rnpm-install info Platform 'android' module appcenter has been successfully linked
iOS App Secret is '00000000-0000-0000-0000-000000000000' set in ios/NFIBEngage/AppCenter-Config.plist
Added code to initialize iOS AppCenter SDK in ios/NFIBEngage/AppDelegate.m
Could not install dependencies using CocoaPods.
Please refer to the documentation to install dependencies manually.
Error Reason - Could not find "pod" command. Is CocoaPods installed?
Configuring AppCenter Analytics
rnpm-install info Platform 'ios' module appcenter-analytics is already linked
? For the Android app, should user tracking be enabled automatical
ly? (Use arrow keys)
❯ Enable Automatically
Enable in JavaScript iOS App Secret is '00000000-0000-0000-0000-000000000000' set in ios/NFIBEngage/AppCenter-Config.plist
? For the iOS app, should user tracking be enabled automatically?
(Use arrow keys)
❯ Enable Automatically
Enable in JavaScript
I did a Ctrl + C to get out and I do not know if the CocoaPods message is related as I have never used it. One time I tried a pod install and zsh could not find pod as a command.
Omar's solution does not work as it gave me Duplicate declaration "appName"
None of the other recommendations were applicable and upgrading React Native is not an option for this project.
In my Xcode 10.1 I have the current configuration inside of Project Settings -> Advanced button:
In this post:
React Native IOS Build CFBundleIdentifier Does not Exist
I already have what SUMIT and priyanga recommended.

What resolved this error was by removing the Instabug library and code from App.js file:
export default class appName extends PureComponent {
constructor() {
super();
this._startSentry();
// if (Platform.OS === "ios") {
// const key = base === "prod" ? env.instabug.prod : env.instabug.beta;
// Instabug.startWithToken(key, Instabug.invocationEvent.twoFingersSwipe);
// }
// Instabug.setIntroMessageEnabled(false);
// appcenter.trackAppOpened();
}
as I was also getting invocationEvent undefined along with that AppRegistry error.

Related

React Native IOS/ Expo build failing for multiple reasons

A expo build is failing on my computer though it is working on the other developers' laptop. The discrepancies are that he is running another version of IOS on his simulator, we don't see this being the issue though.
Problem:
After an expo start -c & running on IOS the build fails with the following errors:
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/#react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:237:40 in guardedLoadModule
at http://192.168.0.62:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false:null in global code
Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/#react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:95:17 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:141:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:39 in handleError
at node_modules/#react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError```
Has anyone seen this or does anyone have ideas on how to get around this issue?
I have tried npm install, clearing caches, resetting file paths, and rebuilding expo builds.

ionic cordova run ios error - Error code 1 for command

I am a newbie of iOS app development. I installed macOs on VMware and use ionic3 framework to development an existed project. It works fine with Android system.
When I run
ionic cordova run ios
get below error:
[17:58:08] tslint: src/pages/welcome/welcome.ts, line: 28
Property 'events' is declared but its value is never read.
L27: private nav: Nav,
L28: private events: Events,
L29: private auth: AuthService,
[17:58:09] lint finished in 4.08 s
FIXME: Implement XCBuild support for macros in overriding parameters with condition sets:
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer
CordovaError: Promise rejected with non-error: 'Error code 1 for command: xcodebuild with args: -xcconfig,/Users/ang/Sense/mobile-app-full/platforms/ios/cordova/build-debug.xcconfig,-workspace,adar.xcworkspace,-scheme,adar,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 12 Pro Max,build,CONFIGURATION_BUILD_DIR=/Users/ang/Sense/mobile-app-full/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/ang/Sense/mobile-app-full/platforms/ios/build/sharedpch'
at /usr/local/lib/node_modules/cordova/bin/cordova:30:15
at processTicksAndRejections (internal/process/task_queues.js:93:5)
[ERROR] An error occurred while running cordova run ios (exit code 1).
Could not find the description and solution of Error code 1 on website.
Thanks for checking my issue.

Invariant Violation: Native module cannot be null.Invariant Violation: "main" has not been registered

When running expo run:ios, i am getting the following error:
Invariant Violation: Native module cannot be null.
Invariant Violation: "main" has not been registered. This can
happen if:
Metro (the local dev server) is run from the wrong folder. Check if Metro is
running, stop it and restart it in the current project.
A module failed to load due to an error and AppRegistry.registerComponent
wasn't called.
My index.js file
import 'react-native-gesture-handler';
import { registerRootComponent } from 'expo';
import App from './App';
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
In appDelegate.m file the module name is "main"
succesful app loading on emulator without any error.

React-native monorepo iOS release build crash

I have a monorepo with this architecture :
├── node_modules
├── packages
├── app # React native project
├── android
└── ios
├── common # TS package
└── web # Next JS project
In common package I have some shared services such as API calls for web front and mobile app.
During development phases, build and run process were working fine for both app and web.
Now I would like to publish my app to the app store but I'm not able to compile a working release ios app.
I have this crash logs when launching the app :
022-06-02 15:33:14.173898+0200 XXXX[33899:2579321] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.', reason: 'Unhandled JS Exception: Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the applica..., stack:
<unknown>#13:289
value#760:3143
<unknown>#760:747
value#760:2538
value#760:719
value#(null):(null)
'
*** First throw call stack:
(0x185361288 0x19e05b744 0x1003c0538 0x10043fd8c 0x10044066c 0x1852e9b24 0x185307610 0x18533e5fc 0x1003d7bd4 0x1003f5e98 0x1003f5ac8 0x184fc6e6c 0x184fc8a30 0x184fd0124 0x184fd0c80 0x184fdb500 0x1f6c240bc 0x1f6c23e5c)
libc++abi: terminating with uncaught exception of type NSException
I follow this article to build monorepo : https://medium.com/#ratebseirawan/react-native-0-63-monorepo-walkthrough-36ea27d95e26.
I have in my xcode project, Build Phases > Bundle React Native code and images :
set -e
export NODE_BINARY=node
export EXTRA_PACKAGER_ARGS="--entry-file packages/app/index.js --reset-cache"
../../../node_modules/react-native/scripts/react-native-xcode.sh "packages/app/index.js"
and in Start packager :
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../../../node_modules/react-native/scripts/.packager.env"
if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then
if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then
if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then
echo "Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly"
exit 2
fi
else
open "$SRCROOT/../../../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start packager automatically"
fi
fi
In my AppDelegate.m
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"packages/app/index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];
#endif
}
metro.config.js :
const {getDefaultConfig} = require("metro-config");
const path = require('path');
module.exports = (async () => {
const {
resolver: {sourceExts, assetExts}
} = await getDefaultConfig();
return {
projectRoot: path.resolve(__dirname, '../../'),
transformer: {
babelTransformerPath: require.resolve("react-native-svg-transformer"),
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== "svg"),
sourceExts: [...sourceExts, "svg"]
}
};
})();
Env :
react-native 0.67.4
output of npx react-native info :
System:
OS: macOS 12.3.1
CPU: (8) arm64 Apple M1
Memory: 555.95 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.5.0 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8092744
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
Languages:
Java: 17.0.2 - /usr/bin/javac
npmPackages:
#react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
I think that the main.js bundle generated is at the wrong place but I don't find the solution, have you any idea ?
Thanks !
in your packages/app/metro.config.js file did you do the changes that are shown in the article?
also and could you share that file.
(The article that you mentioned was specifically supposed to work with ReactNative 0.63, at that time there was little to no tooling to work with React Native on a Monorepo but now we have great tooling and support for it that will solve these annoying issues out of the box, I personally have been using https://nx.dev/guides/react-native)
for your issue tho I can try to help but there might be many things that could cause the error, one might be behind the M1 chip (doesn't have to be tho)
another info that might help, I read the patch notes of RN version 0.65 or 0.66 that they fixed an issue with monorepos where metro doesn't work nicely with symlinks so that might help.
but if I where you, I would clone the NX monorepo template and see their setup and compare with what you have (Files I would look at are metro.config. info.plist. babel.config)
Atm, I found a temporarily workaround :
I added in packages/app/package.json :
"build-prod:ios": "react-native bundle --platform ios --dev false --entry-file ./packages/app/index.js --bundle-output ios/MyAppName/main.jsbundle --assets-dest ios",
in Xcode > Build Phases > Copy Bundle Ressources :
add main.jsbundle
Comment all lines in "Bundle React Native code and images" and "Start packager"
For each new release, I now need to run yarn build-prod:ios before use xcode to build.

vsCode doesn't run flutter app on physical iPhone

I just installed the latest version of flutter and xcode and I'm getting an error when I try running the flutter app on an actual iPhone. Works on ios simulator. The weird thing is that it works when I run it from xcode, but when I run it from vsCode, I get the following error:
It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
open ios/Runner.xcworkspace
What I tried doing:
Change the bundle identifier to myEmailAddress#gmail.com.appTitle
Clean and build the ios app
clean then ran flutter build bundle
What am I doing wrong and how can I get vsCode to run the app on an iPhone?
Here's the full error:
Launching lib/main.dart on Jessica’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: ITYTO5RCWD
Xcode build done. 25.4s
Failed to build iOS app
Error output from Xcode build:
↳
2020-04-19 13:53:51.828 xcodebuild[2046:21215] [MT] iPhoneConnect: 📱<DVTiOSDevice ...> == Underlying device preparation errors ==
2020-04-19 13:53:51.828 xcodebuild[2046:21215] [MT] iPhoneConnect: Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.
Domain: com.apple.platform.iphoneos
Code: 5
Failure Reason: allowsSecureServices: 1. isConnected: 0. Platform: <"...platform info...">. DTDKDeviceIdentifierIsIDID: 0
User Info: {
DVTDeviceDescription = "...device info..."
}
--
2020-04-19 13:53:51.829 xcodebuild[2046:21215] [MT] iPhoneConnect: 📱<"...platform info..."> == END: Underlying device preparation errors ==
** BUILD FAILED **
Xcode's output:
↳
/Users/Jessica/Development/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.m:88:37: warning: incompatible pointer types sending 'FlutterEngine *' to parameter of type 'NSObject<FlutterBinaryMessenger> * _Nonnull' [-Wincompatible-pointer-types]
binaryMessenger:_headlessEngine];
^~~~~~~~~~~~~~~
In module 'Flutter' imported from /Users/Jessica/Development/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.h:2:
/Users/Jessica/Desktop/flutter_game2/ios/Flutter/Flutter.framework/Headers/FlutterChannels.h:178:74: note: passing argument to parameter 'messenger' here
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
^
1 warning generated.
/Users/Jessica/Desktop/flutter_game2/build/ios/Debug-iphoneos/Runner.app: resource fork, Finder information, or similar detritus not allowed
Command CodeSign failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the precompiled application for the device.
It appears that your application still contains the default signing identifier.
Try replacing 'com.example' with your signing id in Xcode:
open ios/Runner.xcworkspace
Error launching application on Jessica’s iPhone.
Exited (sigterm)
Alright, so i solved this problem by pressing on the search icon on the top left of vscode, then searching for com.example
then i saw three search results that were in the ios folder click on it and replace all three com.example with the identifier you created in xcode.
you can change your signing identifier in Xcode
To do that, just open your workspace with app in Xcode, then go to signing and capabilities to change default com.example to anything else...
Better to use as follows to give app company / organization name
flutter create --org com.yourdomain your_app_name
Swift, Kotlin, and androidx dependencies are the default options
After just open the created project in Android Studio or in VSCode
Parameter
--org com.yourcompany
will form applicationId for Android:
com.yourcompany.yourappname
and iOS PRODUCT_BUNDLE_IDENTIFIER:
com.yourcompany.yourAppName
To explore all possible parameters type
flutter create --help

Resources