realm / realm-swift

Realm is a mobile database: a replacement for Core Data & SQLite
https://realm.io
Apache License 2.0
16.28k stars 2.14k forks source link

Cannot import RealmSwift in Playground #7117

Open mmacu opened 3 years ago

mmacu commented 3 years ago

Goals

Importing and opening Realm in Xcode Playground.

Expected Results

Since Xcode 12 it's possible to import Swift packages into Playground. As such it should be possible to import Realm as well.

Actual Results

Getting No such module 'RealmSwift' error.

Steps for others to Reproduce

  1. Create new Xcode (Storyboard) project.
  2. Add Playground at root level.
  3. Add Realm with Swift Dependency Manager.
  4. Build project.
  5. Try to import and do anything with Realm from the Storyboard (added simple script below).

Code Sample

import UIKit
import RealmSwift

print(Realm.Configuration.defaultConfiguration.fileURL!)

Version of Realm and Tooling

Realm version: 10.5.2 Realm database version: 10.4.0 Xcode version: 12.4 (tested with 12.5 beta as well) iOS/OSX version: N/A Dependency manager + version: Swift Package Manager

dianaafanador3 commented 3 years ago

@mmacu I've been able to reproduce this. We're investigating if importing Realm using SPM into Playground is possible.

dianaafanador3 commented 3 years ago

@tgoyne Have you tried this before?

leemaguire commented 2 years ago

I tested https://github.com/realm/realm-swift/issues/7266 with a playground in an Xcode project in Xcode 13.2 and it works. So when this gets merged we will have better support for Playgrounds inside Xcode projects.