Using Unresolved Identifier 'Realm'

I am new to Realm and iOS development and I am stuck due to this error. I downloaded the latest version of Realm ie 0.98.0 and followed the steps in the Getting Started section.

  • Download the latest version of Realm and extract the zip.
  • Go to the Xcode General settings. Drag RealmSwift.framework and Realm.framework from the ios / swift-2.1.1 /, watchos /, tvos / or osx / swift-2.1.1 / directory into the "Embedded Binary Files" section. Make sure that “Copy” is selected, if necessary, and click “Finish”.
  • For your unit test "Build Settings" purposes, add the parent path to RealmSwift.framework under the "Search Paths in Framework" section.
  • If you use Realm in an iOS, watchOS or tvOS project, create a new “Run Script Phase” in your target Build Phases applications and paste the following snippet into the Script text box:

    bash "$ {BUILT_PRODUCTS_DIR} / $ {FRAMEWORKS_FOLDER_PATH} /Realm.framework/strip-frameworks.sh"

As mentioned in the answer to the following question, I added $ (PROJECT_DIR) in the Framework search path

How to add a parent path to RealmSwift.framework in the "Search Paths in Framework" section?

After that, I created the Dog class and added the following code to AppDelegate.swift

let myDog = Dog()
myDog.name = "Rex"
myDog.age = 1
print("name of dog: \(myDog.name)")

// Get the default Realm
let realm = try! Realm()

// Persist your data easily
try! realm.write {
  realm.add(myDog)
}

When I try to build a project, I get the error "Using an unresolved identifier" Kingdom "in the following line:

let realm = try! Realm()

, . 2 " ", " ", " ".

XCode 7.2.1, OS 10.11.13 Swift 2.1.1. Cocoapods

- - ? .

+4
1

. .

import RealmSwift

Java Eclipse, .

+5

Source: https://habr.com/ru/post/1627920/


All Articles