我想在 Realm 中使用 Jitsi-Meet(视频通话库)。当我在 iOS 上运行应用程序时,Realm 不起作用。它显示以下错误:
2018-12-28 16:22:34.504 [error][tid:main][RCTModuleData.mm:179] Realm has no setter or ivar for its bridge, which is not permitted. You must either @synthesize the bridge property, or provide your own setter method.
如果我删除 Jisti-Meet 库,Realm 可以正常工作。Jitsi-Meet 在没有领域的情况下也能正常工作。
重现步骤
- 创建一个新的 react-native 应用程序:
react-native init AwesomeProject
- 安装领域-js:
npm install realm --save
和react-native link realm
- 安装 React Native Jisti Meet:
npm install react-native-jitsi-meet --save
- 在 Build setting 下将Dead Code Stripping设置为 No,将Enable Bitcode设置为 No 并将Always Embed Swift Standard Libraries设置为 Yes
- 添加
node_modules/react-native-jitsi-meet/ios/WebRTC.framework
和node_modules/react-native-jitsi-meet/ios/JitsiMeet.framework
嵌入二进制文件。 - 选择
Build Settings
,找到Search Paths
。编辑 BOTHFramework Search Paths
和Library Search Paths
. 并在两个部分上添加路径:$(SRCROOT)/../node_modules/react-native-jitsi-meet/ios
withrecursive
现在运行应用程序,应用程序将显示错误。
代码示例
文件名:App.js
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button} from 'react-native';
import Realm from 'realm';
const instructions = Platform.select({
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
android:
'Double tap R on your keyboard to reload,\n' +
'Shake or press menu button for dev menu',
});
type Props = {};
export default class App extends Component<Props> {
constructor(props) {
super(props);
this.state = { realm: null };
}
componentWillMount() {
Realm.open({
schema: [{name: 'Dog', properties: {name: 'string'}}]
}).then(realm => {
realm.write(() => {
realm.create('Dog', {name: 'Rex'});
});
this.setState({ realm });
});
}
render() {
const info = this.state.realm
? 'Number of dogs in this Realm: ' + this.state.realm.objects('Dog').length
: 'Loading...';
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Text style={styles.instructions}>To get started, edit App.js</Text>
<Text style={styles.instructions}>{instructions}</Text>
<Button title="Video"
// onPress = {() => initiateVideoCall()}
/>
<Text style={styles.welcome}>
{info}
</Text>
</View>
);
}
}
const 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,
},
});
领域和工具的版本
- Realm JS SDK 版本:2.21.1(低版本也有同样的问题)
- 节点或 React Native:RN 0.57.8
- 客户端操作系统和版本:iOS Real Device - 12.1.2
- MacOS:10.13.6 高山脉
- React Native 的调试器:无