我的应用程序在我声明 RealmSwift class 后崩溃

My app crashes after I declare RealmSwift class

我声明class

import RealmSwift
class Person: Object {
 dynamic var tmpID = 0
  var name: String { // computed properties are automatically ignored
    return "\(firstName) \(lastName)"
  }
  dynamic var firstName = ""
  dynamic var lastName = ""

  override static func ignoredProperties() -> [String] {
     return ["tmpID"]
  }
}

当我 运行 我的应用程序时,控制台日志:

dyld: Library not loaded: @rpath/RealmSwift.framework/RealmSwift Referenced from: /Users/macbook/Library/Developer/CoreSimulator/Devices/EA7EDDF8-C23C-494A-B702-2AC0F0484F54/data/Containers/Bundle/Application/1E43EC69-375D-4F14-A90D-86AF9728E260/SearchFilm.app/SearchFilm Reason: image not found (lldb)

Realm 曾经包含一个 strip-frameworks.sh,需要将其作为构建脚本添加到您的项目中。

Build Phases

下的项目属性编辑器中将其添加为 build script
bash ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework/strip-frameworks.sh

注意: 我正在使用 Swift-2.0 库,但不包含此文件。当我解决 Swift2.0

的问题时,我会更新我的答案

编辑

我最终让它在 Swift 2.0

中工作

我遵循了所有 the instructions here,然后将两个框架添加为 Embedded Binaries,如下所示: