我在我的swift项目中使用RealmSwift作为数据库。今天,在Xcode-beta版本11中打开我的项目后,我的应用因以下错误而崩溃:
由于未捕获的异常“ RLMException”而终止应用程序,原因:对象“ RealmSwiftPermissionRole”上不存在“主键属性”名称”
我的应用程序可以在以前版本的Xcode(10.2.1)上正常运行。 RealmSwiftPermissionRole是Realm中的一个类,我无权访问。也许在他们的功能更新中,他们修复了此错误,但就目前而言,我进行了很多搜索,但未找到任何解决方案。(我清理了项目,从模拟器中删除了该应用,然后再次运行了该项目,但没有任何改变。)有什么建议吗?
Gal*_*har 44
There's an issue with iOS 13 and Xcode 11 which may cause this problem. All String properties of Realm classes with a default String value set are disregarded somehow.
You can fix this by updating to the latest version (currently 3.20.0) and then on Xcode: Product -> Clean Build Folder.
If you're using cocoa-pods:
Open your project's Podfile, and replace RealmSwift line with:
pod 'RealmSwift', '~> 3.20.0'
Run Code Online (Sandbox Code Playgroud)
Then, open terminal on the project's folder and:
pod repo update
pod install
Run Code Online (Sandbox Code Playgroud)
Hope that helps.
小智 14
Realm的开发人员已开始研究Xcode 11兼容性。从该页面...
将Realm与Xcode Betas结合使用需要从源代码进行构建,并且通常需要使用dev分支而不是发行版。
迦太基
github "realm/realm-cocoa" "tg/xcode-11-b1"
DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer carthage bootstrap -no-use-binaries可可豆
pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true明确要求将Realm pod作为依赖项包括在内,否则它将尝试使用obj-c部分的最新版本。
注意最后一句话。您必须将Realm pod包含为依赖项,否则它将使用非beta版本,它将无法正常工作。
我在 RealmSwift 4.3.1 中遇到了同样的问题,问题是我忘记将该属性标记为@objc
@objc dynamic var id = ""
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6113 次 |
| 最近记录: |