- 通过npm安装最新的react-native-icons:npm install react-native-icons@latest --save
- 在XCode中,项目导航器中右键点击Libraries ➜ Add Files to [your project's name]
- 转到node_modules ➜ react-native-icons➜ ios并添加ReactNativeIcons.xcodeproj
- 将libReactNativeIcons.a(从ReactNativeIcons.xcodeproj下的“Products”中)添加到您的项目的Build Phases ➜ Link Binary With Libraries阶段
- 将要使用的字体文件添加到项目的Copy Bundle Resources构建阶段(单击“+”,然后单击“Add Other...”,然后从node_modules/react-native-icons/ios/Libraries/FontAwesomeKit中选择字体文件)。 运行您的项目(Cmd+R)
我的代码:
var React = require('react-native');
var Icon = require('FAKIconImage');
var { AppRegistry, StyleSheet, Text, View} = React;
class BringgersApp extends React.Component {
constructor(props) {
super(props);
}
render() {
return(
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to Bringgers!
</Text>
<Icon
name='ion|beer'
size={150}
color='#887700'
style={styles.beer} />
</View>
)
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
React.AppRegistry.registerComponent('BringgersApp', function() { return BringgersApp });
我构建之后,他说文件不存在...
Font file doesn't exist
我已经清理了DerivedData并尝试了多次构建,但仍然无法正常工作。