-
Notifications
You must be signed in to change notification settings - Fork 109
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
Standalone in iOS not loading up JS template code. #199
Comments
Here is an update. It seems like this is a step forward in the right direction as this patch seems to allow my app to compile except I have not tested it working in runtime. kudos to @janwiebe-jump and @casperolesen UPDATE: 08.02.2024 Got basic Apple CarPlay working fully with much tweaking and help from above thread. |
@EliG-TA could you please share your code? I am running into issues with Expo SDK 51, I keep getting build errors and a black screen. |
@janwiebe-jump Hey, my team is using Expo 50. Nearly all of the code I posted above was loosely adapted from this commit. Since it is company code, I am advised against sharing code. If you have any specific questions, I can try to answer to the best of my ability. You can also share your code and I can give you suggestions. |
@janwiebe-jump You mentioned in #101 (comment) that you got it working. If so, that is amazing! I only got the CarPlay app to work when the phone app is open. Would you be able to point me in the right direction on how to get CarPlay to work standalone as mentioned in facebook/react-native#46211? My code is currently relying on |
I have just updated my plugin to Expo SDK 51 and React Native 0.75. This allows to run the CarPlay app without running on the phone, except when the expo-dev-client is installed (only in development builds) |
@janwiebe-jump Thank you for providing your solution. I tried implementing it along with upgrading my RN version to 75 from 73 and my Expo version to 51 from 50. On my end, it still does not fix the issue where the CarPlay app does not open if the phone app is not running. Also, I am trying to get it to work on the simulator with the expo-dev-client. Do you have any insights for these issues? |
Speaking of which, maybe this expo/expo#30612 can shed some light. |
Hey @EliG-TA did you try a release build? During development the dev-client seems to stall the boot of the carplay app. As soon as the phone app is booted, the carplay app continues. |
Thanks @janwiebe-jump. I tried release build and it didn't change anything. What is the exact version of RN 75 and Expo 51 are you using? Also, do you think setting bridgeless mode or the new architecture to true would make a difference? UPDATE 9.24.2024: With dev-client it is actually working for me albeit laggy. I used it to glance at the simulator logs to see why the CarPlay app either shows a blank screen or crashes when entering without the phone app running (depending on whether the dev-client is in use or not). Anyways, I found that the CarPlay scene tries to initiate the code and just exits immediately following. Here I have attached relevant logs and code snippets. AppDelegate.mm
CarSceneDelegate.mm
LOGSdefault 11:41:59.009689-0400 Project Entering CarScene VERDICTI bet if the phone app were to be launched programmatically when entering the CarScene, then that would fix the issue because my two scenes communicate with each other. Another thing to keep in mind, is how to switch scenes on a device that does not support multiple scenes. How can one accomplish this? UPDATE 9.26.2024: After much consideration, I don't believe it is so feasible to launch a JS bundled phone app from a CarPlay app. It seems like the phone scene and car scene should be loosely coupled. Therefore, unless anyone has any better ideas, the only solution would be to call all the CarPlay template methods and also retrieve all the necessary data in Objective-C. This seems to be related to #158 (comment) Just to cover all bases, would this comment help solve the issue @DanielKuhn? |
In my opinion The CarPlay app and phone app should not be coupled at all. It is the very purpose of CarPlay that you do not need to fiddle around with your phone while driving, therefore all features of a CarPlay app need to be working standalone. This is also misleading in the example app of this project, where the phone app navigates to screens based on selections made in CarPlay and vice versa. For this purpose I wrote the standalone-example which outlines launching a react native app headlessly (i.e. not launching on phone, not appearing in app switcher, etc.) and only interacting with the Car Scene. The comment you referred to only concerns how to correctly wire linking in a scenes-based setup and has nothing to do with CarPlay. |
@DanielKuhn Thank you for the insightful response. I have been trying to follow the standalone-example to the point. It's just that in my case, no JS code seems to be accessible/running when the app on the phone is terminated. I cloned https://github.com/janwiebe-jump/expo-carplay-plugin so that's my Obj-C code. Then, since I only got a blank car app screen when in standalone, I tried using your patch for exposing the createRCTRootViewFactory function and I get the error: "AppController.sharedInstace was called before the module was initialized". Therefore, I tried using EXAppDelegateWrapper's createRCTRootViewFactory instead and the app compiles and runs great, although the screen remains blank in standalone mode. There is some hint in this implementation from the MacOS Console application that might be of use: When going through exclusively CarSceneDelegate, ExpoUpdatesReactDelegateHandler throws fatal error: "Cannot find the current window." This comes from its function:
I personally find this challenging to comprehend as @janwiebe-jump told me his code works flawlessly at least when using a development build which is precisely what I am using. The CarPlay screen shows blank when using expo-dev-client as well. In order to be completely clear, here is a rough layout of my JS side. index.js (JS app entry point)
CarCode.js pseudocode
Please, any help would really be appreciated. 🙏 Hopefully this thread can help others as well who may experiencing similar issues. |
Just an idea.. What if somehow I stored the last known React Native context, functionality, and data for CarPlay on the native side and then retrieved it? I tried doing everything including opening the app programmatically from its deep link, using background task to call react native code for CarPlay, and even the above proposed idea. Any help would be greatly appreciated as I have been waiting on a solution for quite sometime now. @KestasVenslauskas, you seem to be knowledgeable regarding this library. Perhaps you can shed some light? |
Sorry, but I added everything I have to offer - the standalone-example works flawlessly for me and since I'm not using expo I don't have any other ideas on how to fix your problem. |
I don't know what to add either. My approach works for me, on Expo SDK 51. Not on dev builds, because there is something in a dev build that prevents the CarPlay app from showing the view when the phone app is not running. As soon as that one starts and loads the dev server, the CarPlay app starts. However, I tested it in preview and production builds, and that way my CarPlay app boots, when the phone app is not running. |
@janwiebe-jump Thank you for your help. Following your approach exactly, I discovered an issue: when the app is fully closed (not just backgrounded), the cp.bridge check returns false in RNCarPlay.m, which prevents the "didConnect" event from firing.
Any help @casperolesen? |
Hey! I cannot understand why I am having so much difficulty getting this library setup for IOS. I got it working with minimal effort on my part for Android. This issue is happening after I followed meticulously what the documentations say on setting up for IOS, but to no avail. What could I possibly be doing wrong. FYI, I'm trying very hard to use this library with my Expo project even though this is a bare bones React Native library and it was not built for this use case. However, I feel like I am getting very close. I am fully aware that this library has been transitioning from Objective-C in favor of Swift for much of the code base, however I since I am trying to keep my App stable being that it uses a lot of Expo, I would like to keep it in Objective-C if possible.
Here is the error output:
⚠️ ld: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my relevant project folder layout and code:
.
└── ./ios/
├── ./ios/build/
├── ./ios/Pods/
├── ./ios/MyProject/
│ ├── ./ios/MyProject/Images.xcassets/
│ ├── ./ios/MyProject/Supporting/
│ ├── ./ios/MyProject/AppDelegate.h
│ ├── ./ios/MyProject/AppDelegate.mm
│ ├── ./ios/MyProject/CarSceneDelegate.h
│ ├── ./ios/MyProject/CarSceneDelegate.m
│ ├── ./ios/MyProject/Info.plist
│ ├── ./ios/MyProject/main.m
│ ├── ./ios/MyProject/noop-file.swift
│ ├── ./ios/MyProject/PhoneSceneDelegate.h
│ ├── ./ios/MyProject/PhoneSceneDelegate.m
│ ├── ./ios/MyProject/SplashScreen.storyboard
│ ├── ./ios/MyProject/MyProject-Bridging-Header.h
│ └── ./ios/MyProject/MyProject.entitlements
├── ./ios/MyProject.xcodeproj/
├── ./ios/MyProject.xcworkspace/
└── ./ios/Other Files
AppDelegate.h
AppDelegate.mm
CarSceneDelegate.h
CarSceneDelegate
main.m
PhoneSceneDelegate.h
PhoneSceneDelegate.m
To Reproduce
Try building the project with my configuration for IOS.
Expected behavior
To build successfully for IOS.
Screenshots/Videos
If applicable, add screenshots to help explain your problem.
CarPlay (please complete the following information):
Additional context
I have the following Apple entitlements:
"com.apple.developer.carplay-audio": true,
"com.apple.developer.playable-content": true
The text was updated successfully, but these errors were encountered: