Search code examples
ioscocoapodsrealm

Realm.io build errors when using cocoapods `use_frameworks!`


Goal: Be able to use swift pods in an ObjC project

Steps Taken:

  • Altered Podfile by appending use_frameworks!
  • Ran pod install (Cocoapods version 1.0.0)
  • Built workspace again

Result (Errors):

  • I get the following Realm.io errors (pod installed from pod 'Realm' since I'm coding in ObjC):
    • RLMRealm.h:51:1: Duplicate interface definition for class 'RLMRealm'
    • RLMRealm.h:95:62: Property has a previous declaration
    • RLMRealm.h:105:38: Property has a previous declaration
    • RLMRealm.h:110:56: Property has a previous declaration
    • RLMRealm.h:115:38: Property has a previous declaration
    • RLMRealm.h:297:28: Property has a previous declaration
    • RLMRealm.h:493:1: Duplicate interface definition for class 'RLMNotificationToken'

Problem-Solving Steps Taken:

  • (Previous ones in edit history that led to this simplified question)
  • Deleted all pods and reinstalled (no effect)
  • Unlinked Pods framework in Build Phases and relinked (no effect)
  • Cleaned and built / Cleaned build folder and built (no effect)
  • Tried importing with "", <>, and @import (currently all imports in my code are done with #import <Realm/Realm.h>) (searched with #import <Realm and #import "Realm) (no effect)
  • Created new project, copied files over, and pod installed (no effect)
  • Searched project folder for "@interface RLMNotificationToken" and only found one instance of the RLMRealm.h file, so I don't have duplicates
  • Deleting all of my files except for AppDelegate.h/m builds successfully
  • Searched for #import "R, #import <R, @import R and found a rogue #import <RLMRealm.h>

Questions:

I'm frankly really confused and not sure what to do at this point.

So how do I fix these build errors? Why is this happening? Or what other problem-solving steps should I try? (Answers to any of these questions would be appreciated)


Solution

  • Evidently one of my files had a #import <RLMRealm.h> in it (not sure how that got in there). I changed that to @import Realm; and it all works now. I missed that when searching before and only found it while combing my code. Interesting that it works with the library but not with the framework. Well, figured it out and it's all good now.