React Native 0.60.0 和 react-native-carplay 如何配置?
我正在使用 https://www.npmjs.com/package/react-native-carplay 中的示例但我在 Xcode 上收到错误。我认为这是新版本更改的错误。
我想使用当前版本。有人可以帮助我吗?
添加#import #import <RNCarPlay.h>
在 AppDelegate.m 上
错误 => 找不到“RNCarPlay.h”文件
在@end之前添加方法
(void)application:(UIApplication *)application didConnectCarInterfaceController:(CPInterfaceController *)interfaceController toWindow:(CPWindow *)window { [RNCarPlay connectWithInterfaceController:interfaceController window:window]; }
(void)application:(nonnull UIApplication *)application didDisconnectCarInterfaceController:(nonnull CPInterfaceController *)interfaceController fromWindow:(nonnull CPWindow *)window { [RNCarPlay disconnect]; }
错误 => 使用未声明的标识符“RNCarPlay”
import { CarPlay, GridTemplate } from 'react-native-carplay';
const template = new GridTemplate({ /* .. */ });
CarPlay.setRootTemplate(template, false);
最佳答案
所以我发现了一些东西...... 一些步骤没有在文档中描述。
在 XCode 的项目导航器中,右键单击 Libraries ➜ Add Files to [your project's name]
转到 node_modules ➜ react-native-carply 并添加 SplashScreen.xcodeproj
在 XCode 的项目导航器中,选择您的项目。将 libSplashScreen.a 添加到项目的构建阶段 ➜ 将二进制文件与库链接
要修复“RNSplashScreen.h”文件未找到,您必须选择您的项目 → build设置 → 搜索路径 → 要添加的标题搜索路径:
$(SRCROOT)/../node_modules/react-native-carplay/ios
此更改后错误得到解决。
关于ios - React Native 0.60.0 和 react-native-carplay 之间如何配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56996495/