Group Group Group Group Group Group Group Group Group

Chapter 5 Playground_Sources error

#1

Getting this after I’ve bootstrapped:

Playground execution failed:

error: /var/folders/45/sn7sv1w11sgg1r4fcvbvptn80000gn/T/playground1-1c6ecd..swift:3:8: error: no such module 'Playground_Sources'
import Playground_Sources

Have been trying to solve getting around the errors so far, but can’t get past this.

#2

(Looks like this happens in Chapter 6 too)

#3

(Also, switching the Platform under Platform Settings does not resolve the issues)

#4

@reez have you looked at the other threads in this forum? a bunch of people have found different solutions to their problems: Playground misbehaving (Chapter 3) (100+ posts) and Realm - Building Modern Swift Apps : Script Error (100+ posts)

Regardless, since plenty of people used to have difficulties we’re releasing a different version of the code that doesn’t use CocoaPods for playgrounds - we’re preparing a book update right now

#5

“have you looked at the other threads in this forum”

Yes.

#6

In that case if none of the solutions in those threads worked for you I’d suggest wait just a bit and get the new book version, since all our testers have confirmed the new setup without CocoaPods works for them. We’re working on it and I (personally) hope to get it out some time next week.

#7

Hey @reez - I believe v1.1 with the updated Playgrounds has been released. Could you try it and let us know if that helps you ?

Thanks
Shai

#8

Will try v1.1 out for this :+1:t4:

#9

I’m trying out Chapter 7, and I’m still getting this error. Any ideas?

Did the normal set up:

“ open the macOS Terminal app (or a similar app of your choice), navigate to the current chapter’s starter folder, and run the bootstrap script, like so:
./bootstrap.sh”

#10

Getting the import RealmSwift error also since it’s not finding Realm either-

#11

Hey @reez - Are you having issues specifically on chapter 7? Do other playground-chapters work for you on 1.1 ?

#12

It’s only happening on Chapter 5 still. I have found ways the last day or two around fixing all of the other chapters now, but I can’t fix Chapter 5. (I’ve used fresh repos, cleaned Xcode, simulator, bootstrap clean, derived data, etc etc)

It’s the Playground Sources error still, and it doesn’t find RealmSwift because of that, but I’m not sure how to get this fixed.

Any ideas?

Playground execution failed:

error: /var/folders/45/sn/T/playground7-a67f58..swift:3:8: error: no such module 'Playground_Sources'
import Playground_Sources
#13

Hey Reez, I really cannot reproduce this issue in Chapter 5 or any other for that matter. (Using Xcode 9.3, 9.4 etc.)

If the other playgrounds work for you, perhaps it would be easier to just copy-paste the chapter’s code into the functioning playground?

#14

I’m having the same issue in Chapter 6. I’m using High Sierra 10.13.5; XCode 9.4.1. I’ve run ./bootstrap.sh and am getting the following error when I click on the little red “something broke” icon after it says “Build Succeeded”

No such module "RealmSwift" Person.swift

and

Playground execution failed:
error: /var/folders/xs/ggpqyccx0m354yl8hfc0y9tm0000gn/T/playground1-ef0f13…swift:3:8: error: no such module ‘Playground_Sources’
import Playground_Sources

I’ve had problems with the playgrounds throughout the book (and it has really convinced me Playgrounds are utter crap and not worth using) - but usually closing down XCode and completely restarting it had worked if I got errors or it went into lala land. This one won’t work at all.

Under the Realm target, it has many red files (meaning it can’t find them). Including a Realm.framework (but there’s one that isn’t red??) and RealmSwift.framework under the Products folder.

I’ve tried cleaning the derived files using

rm -rf ~/Library/Developer/Xcode/DerivedData/RealmPlayground-*

but it seems to have had no impact. I’m using version 1.1 of the book (I just downloaded it a few days ago). Any suggestions?
Thanks!

#15

@pknitter I’m having exactly the same issue and tried many things and still having the issue.

Thanks

#16

@pknitter Finally it works!

in the ‘Observing an Object’ page I changed Platform from iOS to macOS and changed it back to iOS in the Playground Settings’ and it works now!

I tried this many times as suggests in the book with no success but it works now!

Thanks

#17

@bidadh Tried that - still didn’t work for me :frowning_face:

Did you do a clean within Xcode? Can you tell me what your Realm/Products/ folder looks like? That whole folder in my project is all red - meaning it doesn’t find the files.

In digging around i’ve also found that there appears to be a typo in the Realm/Configuration/RealmSwift/RealmSwift.xcconfig file:

PRODUCT_BUNDLE_IDENTIFIER = io.realm.RealmSwit;

(note it says io.realm.RealmSwit instead of io.realm.RealmSwift)

Fixing that doesn’t seem to have much of an impact even if I clean and rebuild.

#18

I now can’t get older chapters to work either. The only thing I can think that I changed is I was prepping my real project to start using Realm so I ran the instructions on that site , and part of that was to update pod. “pod repo update”. I don’t know what version of cocoapods I was on before but pod --version now shows me at 1.5.3

One of the other threads suggested to go back to cocoapods 1.4; but I haven’t found instructions to do that yet (or know if it would cause problems with my real projects…)

Editing to update - I think the version of cocoapods is a herring. I checked my history and I was already at 1.5.3; so that doesn’t seem to be it. It looks I’m able to run the sample apps (e.g. BackLinks from chapter 4).

Still searching for an answer…

#19

@pknitter, to be honest, I can’t remember the exact steps :frowning:

I use pod version 1.5.3 so it shouldn’t be a problem.
I’ve modified bootstrap.sh to use RealSwift version 3.7.2 ( latest version)
my xcode version is 9.4.1

I think you better extract a clean copy of the sources from the original files and try these steps:

update bootstrap.sh to point to 3.7.2 (Optional I guess)
run bootstrap.sh
open Playground
you more likely will see the red flag still
select ‘Observing an object’ from the list
on the right-hand side of your xcode, you see ‘File Inspector’ pane
from the ‘Playground settings’ change the platform to macOS and change it back to iOS

this might resolve the issue.

if not, clean the project by pressing CMD+K and try the last step once again. hopefully, it works!

Thanks

1 Like
#20

Replying to thread one more time to say it seems to be working now. I ran the app example from Chapter 4 (BackLinks) and then closed that project. I then tried again for Chapter 6 to change Platform from iOS to macOS and then back to iOS in the Playground Settings’ and suddenly it seems to work. I assume that’s a temporary state and will try to take advantage of it while it’s working. I’ve lost several hours of precious time mucking about with this now :frowning:

So far I’ve loved all the books I’ve bought from raywenderlich.com (iOS Apprentice, Core Data, the countless free tutorials), but the use of Playgrounds is causing me no end of headaches. I hope you never ever ever use Playgrounds as a way to run sample code again. I’d rather run an empty app 50 times in a row than use Playgrounds at this point…