birkir / react-native-carplay

CarPlay with React Native
https://birkir.dev/react-native-carplay/
MIT License
655 stars 108 forks source link

Possible to get a RN 74 example? #188

Open blakecallens opened 4 months ago

blakecallens commented 4 months ago

Is your feature request related to a problem? Please describe. With the upgrade to Yoga 3.0 and the removal of Flipper, it would be helpful to have an example app showing how to configure iOS scenes in this version.

Describe the solution you'd like An example app for React Native >= 74

lovegaoshi commented 3 months ago

removing flipper related lines in the header file and podfile will just work for rn0.74, old arch.

mefjuu commented 3 months ago

@lovegaoshi Are you using AppDelegate ObjC or Swift version (like in example app in master branch)?

lovegaoshi commented 3 months ago

swift

On Tue, Jun 11, 2024, 5:20 AM Mateusz Janik @.***> wrote:

@lovegaoshi https://github.com/lovegaoshi Are you using AppDelegate ObjC or Swift version (like in example app in master branch https://github.com/birkir/react-native-carplay/tree/master/apps/example/ios )?

— Reply to this email directly, view it on GitHub https://github.com/birkir/react-native-carplay/issues/188#issuecomment-2160621542, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVWS4KWBGGPBB46SQFLZG3TSVAVCNFSM6AAAAABIWSGUB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQGYZDCNJUGI . You are receiving this because you were mentioned.Message ID: @.***>

mefjuu commented 3 months ago

@lovegaoshi Did you have any problems with migrating? I have some issues with "'RCTAppDelegate.h' file not found" in {TargetName}-Bridging-Header.h while compiling. I'm investigating what's the reason of the problem (maybe it's dependencies related problem? such as RN Firebase...)

lovegaoshi commented 3 months ago

if u use anything modifying appdelegate, u r on ur own. tho if u only use expo and rn app auth, lucky for u ive done it.

https://github.com/lovegaoshi/azusa-player-mobile/pull/474

On Tue, Jun 11, 2024, 8:42 AM Mateusz Janik @.***> wrote:

@lovegaoshi https://github.com/lovegaoshi Did you have any problems with migrating? I have some issues with "'RCTAppDelegate.h' file not found" in {TargetName}-Bridging-Header.h while compiling. I'm investigating what's the reason of the problem (maybe it's dependencies related problem? such as RN Firebase...)

— Reply to this email directly, view it on GitHub https://github.com/birkir/react-native-carplay/issues/188#issuecomment-2161081175, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZMOVVRRTXMQNV6D4LOM3ATZG4LH7AVCNFSM6AAAAABIWSGUB2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRRGA4DCMJXGU . You are receiving this because you were mentioned.Message ID: @.***>

blakecallens commented 3 months ago

I've been able to resolve the issue. A key difference in pure ReactNative v74 is that you need to add a bundleURL function to the AppDelegate, because it's not a class variable any longer.

override func bundleURL() -> URL? {
    return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index");
}
mefjuu commented 3 months ago

@lovegaoshi Glad to see real-world app using Car Play! Thanks for linking the repo. My problem with bridging header was setting it also for extra targets which I use in my app (for iOS Widgets). After leaving it only for main app target the error has gone.

lovegaoshi commented 3 months ago

appreciate mentioning of the bundleURL function! I did encounter that too and the snippet would fix it perfectly. I got it confused with sourceURL so I forced it in there.

DanielKuhn commented 1 month ago

I upgraded the example app to RN 75 in this PR.

It uses the same approach as @lovegaoshi 's - which poses a problem: In application:didFinishLaunchingWithOptions a second rootView is created, additionally to the one already created by the RCTRootViewFactory in RCTAppDelegate's application:didFinishLaunchingWithOptions here. This leads to duplicate rootViewControllers with rootViews causing side effects like react native hooks to be run twice... In other words: The app is "run twice":

Bildschirmfoto 2024-08-23 um 15 59 39

I outlined this problem in the README of my standalone-app-PR So far, the only way I found around it is to use the initAppFromScene-approach, recreating RCTAppDelegate's application:didFinishLaunchingWithOptions except for the rootViewController and window creation and leaving those to the PhoneSceneDelegate.

In RN 74 and 75, this seems to require patching the react native package itself and exposing createRCTRootViewFactory in RCTAppDelegate.h (see discussion here).

DanielKuhn commented 3 weeks ago

Related issue (RN 0.75) for Android: https://github.com/birkir/react-native-carplay/issues/210