Realm-cocoa: Undefined symbols for architecture x86_64

Created on 18 Feb 2015  路  7Comments  路  Source: realm/realm-cocoa

I can't use Realm with Swift.

Podfile

target 'RealmSwiftTest' do

pod 'Realm'

end

Error

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RLMRealm", referenced from:
      __TMaCSo8RLMRealm in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Steps to reproduce

Version of Realm (latest from CocoaPods) , Xcode 6.3 (6D520o), Mac OS X 10.10.2 (14C109)

  1. Pod install
  2. Open project and use Simulator
  3. Create Bridging Header with #import <Realm/Realm.h>
  4. Test with code:
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        println(RLMRealm.defaultRealm())
    }

...

Any clue?

All 7 comments

I also tested with the latest version of Swift/RLMSupport.swift and it gives me the error:
No such module 'Realm'.

Are you adding #import <Realm/Realm.h> to your bridging header?

Yes, I added #import <Realm/Realm.h> and gives me the same error on import Realm (No such module 'Realm').

If I remove import Realm it gives me:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RLMArray", referenced from:
      __TMaCSo8RLMArray in RLMSupport.o
      _protocol_conformances in RLMSupport.o
  "_OBJC_CLASS_$_RLMObject", referenced from:
      __TFFE16CocoaPodKeysTestCSo8RLMArray8generateFS0_FT_GVSs11GeneratorOfCSo9RLMObject_U_FT_GSqS2__ in RLMSupport.o
      __TMaCSo9RLMObject in RLMSupport.o
      __TFFE16CocoaPodKeysTestCSo10RLMResults8generateFS0_FT_GVSs11GeneratorOfCSo9RLMObject_U_FT_GSqS2__ in RLMSupport.o
  "_OBJC_CLASS_$_RLMRealm", referenced from:
      __TMaCSo8RLMRealm in ViewController.o
  "_OBJC_CLASS_$_RLMResults", referenced from:
      __TMaCSo10RLMResults in RLMSupport.o
      _protocol_conformances in RLMSupport.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Yes, you'll need to remove the import Realm (since you aren't integrating it as a framework, and thus it isn't a module). As to the other issues, I'm not quite sure what's going on. Maybe @mrackwitz has some ideas?

Hi @ricardopereira, please follow these instructions to use Realm in a CocoaPods Swift project:

  1. Install CocoaPods 0.36.0.rc.1 or later ([sudo] gem install cocoapods --pre).
  2. In your Podfile, add use_frameworks! and pod 'Realm' to your app target, and pod 'Realm/Headers' to your test target.
  3. From the command line, run pod install.
  4. Use the .xcworkspace file generated by CocoaPods to work on your project!
  5. Download the latest release of Realm and extract the zip.
  6. Drag the file at Swift/RLMSupport.swift into the File Navigator of your
    Xcode project, checking the Copy items if needed checkbox.

We'll be updating our installation instructions on http://realm.io shortly.

@jpsim i got an issue when i run my project on iphone 6 and 6+. It works fine on other devices. Why do i get this error and how can I fix it? Thanks

@neon0619 please open a new GitHub issue along with steps that we can follow to reproduce the issue you're seeing. This happens when the linker can't find the symbols referred to by the headers/interface provided by the framework.

Was this page helpful?
0 / 5 - 0 ratings