Paul
Paul

Reputation: 36349

How do I use Realm in a Swift Playground?

So, I'm pretty new to XCode development, but I've read the documentation on how to import third party frameworks into a Playground in XCode 7.1.1, and the documentation on how to get started with Realm, using the Dynamic Framework method of installation.

At this point I have a workspace that contains an iOS project, the two .framework folders required by Realm, and a Playground project. I have built the workspace without errors.

I figured going through some of the Realm examples in the Playground would be a great way to get going, but doing a simple:

import RealmSwift

results in a "No such module 'RealmSwift' error. What am I missing?

Upvotes: 5

Views: 2076

Answers (3)

Sauvik Dolui
Sauvik Dolui

Reputation: 5660

I faced the same issue while playing with RealmSwift on a Playground. I create it under a single view iOS application. Fixed it after building my main target, as creates the dynamic framework to be linked into the Playground.

Working fine with Cocoapod installation, Swift 4.2, & Xcode 10.1 Try it yourself. https://github.com/sauvikdolui/RealmExploration

SwiftPlayGround with RealmSwift

Upvotes: 0

jpsim
jpsim

Reputation: 14409

Update: Realm Swift works with Swift Playgrounds now. You'll find an example in Realm's release zips (direct download).


Realm doesn't support Swift Playgrounds at the moment: https://github.com/realm/realm-cocoa/issues/938

Upvotes: 3

Sam Bellerose
Sam Bellerose

Reputation: 1812

You should install Realm with Cocoapods.

One good practice to adopt is using Cocoapods when using other librairies like this one when they support it. That way you always have control on the version you're using of this library.

Upvotes: 4

Related Questions