mongodb-university / realm-template-apps Goto Github PK
View Code? Open in Web Editor NEWThe MongoDB Realm template apps source
The MongoDB Realm template apps source
I'm trying to follow the tutorial here, but every time I run the sample app it crashes immediately.
https://www.mongodb.com/docs/atlas/app-services/tutorial/react-native/
Here's what I'm running:
realm-cli pull --remote [name of my app in atlas] --template react-native.todo.flex
cd TutorialApp/frontend/react-native.todo.flex
npm install
This will get stuck on reifying realm. So I blow away node_modules and packages-lock.json and run yarn instead.
rm -rf node_modules package-lock.json
yarn
npx pod-install
npx react-native run-ios
It takes a long time, but eventually tries to run the app. When it does, the app simply crashes with a BAD_ACCESS error. This is really weird because I'm able to build and run other React Native apps.
What gives? Am I doing something wrong here?
More details:
Mac OS X Ventura 13.4
XCode 14.3.1
2020 Intel MacBook Pro
Atlas url is used in project but is missing in config
class Config extends ChangeNotifier {
late String appId;
late String? atlasUrl;
late Uri baseUrl;
Config._create(dynamic realmConfig) {
appId = realmConfig['appId'];
atlasUrl = realmConfig['dataExplorerLink'];
baseUrl = Uri.parse(realmConfig['baseUrl']);
}
static Future<Config> getConfig(String jsonConfigPath) async {
dynamic realmConfig =
json.decode(await rootBundle.loadString(jsonConfigPath));
var config = Config._create(realmConfig);
return config;
}
}
Hello team. Not sure if this is the right channel. But I was working on a presentation and using the template tiered from our docs, I realise there was something wrong.
So, inspecting further, I've seen that the call to function joinTeam is doing
const adminFuncArgs = [admin.id, "greenTeam", true /* make admin */];
const adminFuncResult = await admin.callFunction("joinTeam", adminFuncArgs);
The arguments are passed in an Array
. The App Services function is defined as exports = async function (userId, teamName, isAdmin = false)
and the problem is that all the arguments are stored in userId
instead of being spread.
Therefore userId = [admin.id, "greenTeam", true]
and teamName = undefined
. So the $set
is not working as expected as the filter will never work
The fix is pretty simple, just by editing two lines as follows:
const adminFuncResult = await admin.callFunction("joinTeam", admin.id, "greenTeam", true);
const funcResult = await member.callFunction("joinTeam", member.id, "greenTeam", false);
When running the code through the android simulator, it errors out when initializing the RealmProvider. I get the following errors:
BUNDLE ./index.js
LOG View your data in MongoDB Atlas: https://cloud.mongodb.com/links/<...>/explorer/Cluster0/database/collection/find.
ERROR Error: Exception in HostObject::get for prop 'Realm': java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealm.so caused by: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/~~UrHcuOA1X7s9x-M8jCfU4g==/com.synctutorial-q5oSJsHgqnnBeIlJ_Vt4TQ==/lib/x86_64/librealm.so"... result: 0, js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. 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., js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. 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., js engine: hermes
Howdy.
It would be lovely since I used the logics in this SwiftUI ToDo example in my project you help me to figure out how can I fix my issue on realm/realm-swift#8079
Regards,
The app is correctly built, but when it is initiated, appears the next error on the simulator:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: Unable to resolve module ./index from /Users/user1/apps/learning-fm/MyRealmApp/.: <br><br>None of these files exist:<br> * index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)<br> * index/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)<br> at ModuleResolver.resolveDependency (/Users/user1/apps/learning-fm/MyRealmApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)<br> at DependencyGraph.resolveDependency (/Users/user1/apps/learning-fm/MyRealmApp/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)<br> at /Users/user1/apps/learning-fm/MyRealmApp/node_modules/metro/src/lib/transformHelpers.js:129:24<br> at Server._resolveRelativePath (/Users/user1/apps/learning-fm/MyRealmApp/node_modules/metro/src/Server.js:1137:12)<br> at async Server.requestProcessor [as _processBundleRequest] (/Users/user1/apps/learning-fm/MyRealmApp/node_modules/metro/src/Server.js:464:37)<br> at async Server._processRequest (/Users/user1/apps/learning-fm/MyRealmApp/node_modules/metro/src/Server.js:420:9)</pre>
</body>
</html>
RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_drain
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_sim
0x0
I execute the npx react-native init command from the app main folder, the one which contains app.json, realm.json, ios and android folders, etc...
What am I supposed to do different?
Thank a lot in advance!
I have followed the Android With Kotlin Tutorial but when I download the zip containing the front end code it is empty. As a result I used the CLI (appservices pull
) but I cannot get the app to function correctly and I am not sure if this is an issue with the template or configuration that I have missed while following the tutorial.
On the Android device I can login successfully and get the following in the logcat
LoginEvent com.mongodb.app I User logged in successfully.
but then I am presented with a black screen and the logcat repeatedly outputs
REALM com.mongodb.app W [Core] Reading failed: End of input
What am I missing?
Error appears on this line of the app bar component:
flutter run
full output:
Launching lib/main.dart on macOS in debug mode...
2023-06-13 18:47:42.616 xcodebuild[6282:571776] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-0014518C3E91801E }
{ platform:macOS, arch:x86_64, id:00006000-0014518C3E91801E }
lib/components/app_bar.dart:8:47: Error: The class 'PreferredSizeWidget' can't be used as a mixin because it isn't a mixin class nor a mixin.
class TodoAppBar extends StatelessWidget with PreferredSizeWidget {
^
Target kernel_snapshot failed: Exception
Command PhaseScriptExecution failed with a nonzero exit code
warning: Run script build phase '[CP-User] Download Realm Flutter iOS Binaries' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'realm' from project 'Pods')
warning: Run script build phase '[CP-User] Report Metrics' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'realm' from project 'Pods')
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **
Building macOS application...
Exception: Build process failed
the dart linter is also reporting the same error on the same line.
Upgrading to latest package version causes sync connection errors within the application.
the layout ressource is not in the project for android kotline
Do you recommend using the Toolkit QueryProperty
or ApplyQueryAttributes
The SwiftUI template todo app is unable to maintain a connection with MongoDB. The app itself works just fine, but it is unable to sync. The steps I'm taking are:
I can see the created user in App Services, but no todos are ever synced. Opening the app on a different simulator confirms that there is no syncing happening. The following is output when the app launches and attempts to connect to flexible sync (I've removed some identifying info from these logs):
Sync: Realm sync client ([realm-core-13.10.1])
Sync: Connection[1]: Session[1]: Binding '[obfuscatedpath]/flx_sync_default.realm' to ''
Sync: Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, client reset = false
Sync: Connected to endpoint 'x.xx.xxx.xx:xxx' (from 'xxx.xxx.x.xx:xxxxx')
Sync: Connection[1]: Closing the websocket with status='SystemError: invalid certificate chain', was_clean='false'
Sync: Connection[1]: Connection closed due to error
I am trying to figure out how the flexible sync works, and when I am looking at this code:
Realm initRealm(User currentUser) {
Configuration config = Configuration.flexibleSync(currentUser, [Item.schema]);
Realm realm = Realm(
config,
);
final userItemSub = realm.subscriptions.findByName('getUserItems');
if (userItemSub == null) {
realm.subscriptions.update((mutableSubscriptions) {
// server-side rules ensure user only downloads own items
mutableSubscriptions.add(realm.all<Item>(), name: 'getUserItems');
});
}
return realm;
}
I am wondering, where is the getUserItems
is defined? I can't find in the codebase: the https://github.com/mongodb/template-app-dart-flutter-todo.git
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.