Since Xcode 12 playgrounds can now import Swift packages I thought that it would open some possibilities for Realm. First use case I wanted to test is creating a database (to bundle with my other project) inside of Playground. Here is what I’ve done to see If I could even use Realm from Playground:
-
Created new Xcode storyboard project.
-
Added Playground at projects root level.
-
Added Realm with Swift Dependency Manager.
-
Added this code to the Playground:
import UIKit
import RealmSwiftprint(Realm.Configuration.defaultConfiguration.fileURL!)
-
Built project.
-
Tried to run Playground.
What I’m gettin is those errors:
Error 1:
error: MyPlayground.playground:4:7: error: cannot find 'Realm' in scope print(Realm.Configuration.defaultConfiguration.fileURL!)
Error 2 (I think it’s not critical?)
Swift package target 'Realm' is linked as a static library by 'RealmPlayground124' and 'RealmSwift'. This will result in duplication of library code.
The steps I tried are based on this article.
Did I do something wrong? Is that issue happening on my machine only or is it replicable? Is this an issue with Xcode or Realm? (I’ve tried exact same thing with SwiftyJSON and it worked in Playground)
(Tried this both on Xcode 12.4 and 12.5 beta with Realm 10.5.2)