Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Mixed Objective C and Swift Project

Is it recommended to use the Objective C or Swift MongoDB Realm SDK when working with a mixed Objective C/Swift code base? We migrated a mixed app to Realm last year and the Realm documentation stated that the Objective C SDK should be used. Is that still the case? I’ve noticed some methods in the SDK are marked with NS_REFINED_FOR_SWIFT which makes them unavailable in Swift. Also, there isn’t the RLMSupport.swift file that contains a lot of handy extensions.

@Nina_Friend RLMObject and RealmSwift.Object are different types that can’t be easily passed to functions expecting the other, so mixing the two gets really awkward

If RLMSupport.swift is missing wrappers for things marked as NS_REFINED_FOR_SWIFT then we should fix that - please open an issue here for what is missing that you need: https://github.com/realm/realm-cocoa

I’ll submit the issue.

Should I continue to have my data classes in Objective C and descending from RLMObject or should I rewrite the data classes in Swift and descend from Object even though other parts of my code are still in Objective C? In the future I would like to convert the whole project to Swift. If I start with Objective C/RLMObject and then want to switch to Swift/Object later is that going to be a problem?