【发布时间】:2021-08-24 09:58:08
【问题描述】:
我正在使用 VS 代码在 ios 中构建一个 react-native 应用程序。
我知道如何使用 Xcode 将密钥添加到 info.plist 文件中,现在我可以在 VS 文件系统的 info.plist 文件中看到该密钥显示在我的屏幕?
例如 SERVICE_KEY = "Hello World"
如何使用 VS 代码而不是 Xcode 让“Hello World”显示在屏幕上。
我正在考虑类似下面的内容,但显然它不正确
SERVICE_KEY 是我要显示的关键数据
```import React from 'react';
import {StyleSheet, Text, View, SafeAreaView} from 'react-native';
// import 'info.plist';
// import 'strings.xml';
import {SERVICE_KEY} from 'rnFinal/ios/rnFinal/info.plist';
const Key = () => {
return (
<SafeAreaView>
<View>
{/* <Text>{SERVICE_KEY}</Text> */}
<Text>I am going to be a key</Text>
</View>
</SafeAreaView>
);
};
export default Key;
const styles = StyleSheet.create({});```
下面是 info.plist
``` <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
//lots of key values...
<key>Service_Key</key>
<string>$(SERVICE_KEY)</string>
</dict>
</plist>```
附带问题是否有人推荐任何好的资源来在 VS 代码中构建 react native 而不是使用 X'每次升级都会中断'代码?
感谢您的帮助!
【问题讨论】:
标签: ios xcode react-native visual-studio-code