1

如何在 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);
4

1 回答 1

0

所以我发现了一些东西......文档中没有描述一些步骤。

在 XCode 中,在项目导航器中,右键单击 Libraries ➜ Add Files to [your project's name]

转到 node_modules ➜ react-native-carply 并添加 SplashScreen.xcodeproj

在 XCode 的项目导航器中,选择您的项目。将 libSplashScreen.a 添加到项目的构建阶段 ➜ 将二进制文件与库链接

要修复 'RNSplashScreen.h' 文件未找到,您必须选择您的项目 → 构建设置 → 搜索路径 → 标题搜索路径以添加:

$(SRCROOT)/../node_modules/react-native-carplay/ios

在此更改后,错误得到解决。

于 2019-07-17T17:15:09.120 回答