我一直在关注关于Realm的this教程,我遇到了一个问题。所以它说要生成一个领域模型,我们必须通过Alcaraz在Xcode中安装一个插件。闪亮的。
现在我面临的问题是,在Xcode 8+中,它不允许安装任何外部插件(就我所能理解的而言,只有那些可以编辑文本的插件)。
我的问题是,既然Xcode 8+不支持外部插件,我如何像本教程所说的那样生成领域模型。另外,如果现在不可能,那么我应该如何处理/解决这个数据模型映射。
我在Realms git页面或他们的网站上没有找到任何解决方案。任何帮助都是非常感谢的。
我使用的是Xcode 8.3.2,我使用的是Swift 3.1
编辑
我已经通过cocoapods安装了Realm。我在问,是否有像核心数据xcdatamodel这样的可视化生成器,用于领域数据模型,就像以前在Xcode插件中一样。
发布于 2017-05-26 18:47:41
You can use CocoaPods
add following to pods file and install -pod install
pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
then , Create model class as following
import Foundation
import UIKit
import RealmSwift
import Realm
class ClassName: Object{
required init(value: Any, schema: RLMSchema) {
super.init(value : value,schema:schema)
//fatalError("init(value:schema:) has not been implemented")
}
required init() {
super.init()
//fatalError("init() has not been implemented")
}
required init(realm: RLMRealm, schema: RLMObjectSchema) {
super.init(realm:realm , schema:schema)
//fatalError("init(realm:schema:) has not been implemented")
}
}发布于 2017-05-26 20:50:06
Realm没有可视化的模型生成器。即使在你链接的教程中,也没有提到这件事。XCode插件只生成一个框架Swift文件,可以用作您的领域模型,没有可视化生成器。
您在链接中看到的可视化工具是Realm Browser,但它的主要目的是检查您的数据库条目,您不能使用它创建模型。
发布于 2018-11-29 16:25:12
现在有一些Visual Realm编辑器:
使用Java对象编辑器,您将能够:为实体属性创建领域并定义每个属性的属性(主键、索引、忽略、默认值、一对一、一对多和多对多relationships.
RealmObjectEditor看起来很有前途。陀螺仪需要一个模型文件。试一试,让我知道它是否有帮助...
编辑:似乎RealmObjectEditor是在swift 2中编程的。需要更新到至少swift 3才能使用它……XCode 8太bad...Anybody了?(错误消息:目标“Realm Object Editor”包含使用Swift 2.x开发的源代码。此版本的Xcode不支持构建或迁移Swift 2.x目标。使用Xcode8.x将代码迁移到Swift 3。)
https://stackoverflow.com/questions/44198781
复制相似问题