playgroundbooks / playgroundbook

Tool for Swift Playground books
https://ashfurrow.com/blog/swift-playground-books/
MIT License
259 stars 17 forks source link

No autocomplete in Playgrounds Book #51

Closed ryanoconnor7 closed 7 years ago

ryanoconnor7 commented 7 years ago

Hi all, Once I get the file & folder structure for a .playgroundbook, I import necessary classes and put them in the sources folder. Then, on the individual Contents.swift files for each page, I try to reference the class and initialize it, add it to the live view, etc. Not only am I unable to get any autocomplete whatsoever, it does not show any suggestions for regular UIKit and Foundation stuff, like trying to create a new variable for a view, string, etc. Even when writing in the Class file from my other project that I copied over, it compiles/shows autocomplete in the separate playground, and once put in the .playgroundbook Project, nothing.

I'm thinking that it doesn't compile anything in Xcode, and will only actually compile once you load it onto the iPad, however, it doesn't seem practical to write all my code in a separate project so that I can get completition when writing.

I will get a project uploaded shortly.

ashfurrow commented 7 years ago

@playgroundbooks/contributors anyone have any ideas here?

ntn-x2 commented 7 years ago

The same problem over here! I would like to get to know if there is a comfy way to fully develop a playground book from XCode. Thanks!

ashfurrow commented 7 years ago

There's a PR to change how we do things: https://github.com/playgroundbooks/playgroundbook/pull/34 You could pull down the code on that fork and try it out.

ryanoconnor7 commented 7 years ago

Interesting, it does make sense because once you create the file structure of a .playgroundbook, there's no actual .playground file left. So I guess what he did was for each chapter, enclose all of the stuff inside of Chapterq.playground. My only concern is that I'm pretty sure as per Apple's documentation you are required to name chapter's .playgroundchapter, so I wonder if it will recognize it. Rather than have a .playgroundchapter in book manifest, use Chapter1.playground.

ashfurrow commented 7 years ago

It should work. i've just merged that pull request and released version 1.0.0 of the tool, which uses the new playgrounds page format. I'd appreciate any feedback y'all have on documentation, and let me know what other shortcomings there are with the tool. Thanks!

ryanoconnor7 commented 7 years ago

So what's the procedure to get a playgrounds book started with your repo? I apologize, I haven't really looked at it much.

ashfurrow commented 7 years ago

That's a good question, I'm having some difficulty with it right now but I'm working on a fix and will get it to you asap, with instructions.

ryanoconnor7 commented 7 years ago

Thanks!

ashfurrow commented 7 years ago

Okay so it looks like Xcode's playgrounds format may have changed since #34 was opened /cc @dionlarson I'm working on a fix now.

ashfurrow commented 7 years ago

Okay, you're lucky you caught me when I had some spare time :wink: I've updated the tool to fix the bug I mentioned above, as well as improve the documentation. Basically, you need a directory that has a .yaml file and a bunch of playgrounds (these will become your chapters). You add pages to the playgrounds and that's it. Here's an example that's working for me locally with version 1.1.0 of the tool:

test.zip

It should generate a playground book that you can airdrop to your iPad. Autocomplete should work, too. More documentation has been added to the readme. Let me know if there are any questions, either here or in a new issue.

@ryanoconnor7 @Diiaablo95 Please try this out if you can and let me know if it works, hopefully we can get this issue closed and you can get back to working on your applications šŸ˜„

ntn-x2 commented 7 years ago

Thanks for your work!

Iā€™m gonna give it a try in a couple of hours more or less, hoping it will do its job in the best way possible! :)

On 15 Mar 2017, at 20:05, Ash Furrow notifications@github.com wrote:

Okay, you're lucky you caught me when I had some spare time šŸ˜‰ I've updated the tool to fix the bug I mentioned above, as well as improve the documentation. Basically, you need a directory that has a .yaml file and a bunch of playgrounds (these will become your chapters). You add pages to the playgrounds and that's it. Here's an example that's working for me locally with version 1.1.0 of the tool:

test.zip https://github.com/playgroundbooks/playgroundbook/files/845713/test.zip It should generate a playground book that you can airdrop to your iPad. Autocomplete should work, too. More documentation has been added to the readme. Let me know if there are any questions, either here or in a new issue.

@ryanoconnor7 https://github.com/ryanoconnor7 @Diiaablo95 https://github.com/Diiaablo95 Please try this out if you can and let me know if it works, hopefully we can get this issue closed and you can get back to working on your applications šŸ˜„

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/playgroundbooks/playgroundbook/issues/51#issuecomment-286847142, or mute the thread https://github.com/notifications/unsubscribe-auth/AGZNeJrFD9W8TaZciXMCEvvuuIIzGtyXks5rmDZ2gaJpZM4MbYdm.

ryanoconnor7 commented 7 years ago

Alright thanks I'll give it a try!

ryanoconnor7 commented 7 years ago

Works AMAZING! Great job! img_0622

orta commented 7 years ago

We should maybe make an example book repo - so people can look at that as a reference, rather than infer it from our README?

orta commented 7 years ago

@ryanoconnor7 - think you could turn your book into something applicable to anyone following along? I can make you a repo

ryanoconnor7 commented 7 years ago

So from start to finish? I'm pretty sure @ashfurrow 's test project does it pretty well, we just need to get the instructions down.

ryanoconnor7 commented 7 years ago

So maybe some instructions like this:

ryanoconnor7 commented 7 years ago

How to make a Playgrounds Book from start to finish

  1. Download this .playground template: test.zip

  2. Install framework that allows .playground to be converted to .playgroundbook

    • In terminal, use this command: sudo gem install playgroundbook
  3. Go back to the test project that you downloaded. finder Customize it by adding new .playground files for each chapter, and new Pages within the playground for each page.

    xcode
  4. Update test.yml file so that when converting, it knows what to include. These are all of the parameters available, but keep in mind the optionals. For a bare minimum, you should include name, identifier, imports, and chapters:

name: Testing book
identifier: com.ashfurrow.example
resources: assets # Optional
cover: cover.jpeg # Optional
deployment_target: ios10.0 # Optional
imports: # Optional, defaults to UIKit
 - UIKit
 - CoreGraphics
chapters:
  - name: Chapter 1
    edge_to_edge_live_view: false # defaults to true
    live_view_mode: "VisibleByDefault" # defaults to "HiddenByDefault"
  - name: Chapter 2
  - etc...
glossary:
  term: definition
  1. Once your content with your project, and updated .yaml, and ready to covert it to a .playgrounds book, navigate to the project folder in terminal, for example: cd Desktop/Xcode\ Projects/test
  2. Then, enter the following command: playgroundbook render test.yaml
  3. Your output should appear as name.playgroundbook: screen shot 2017-03-15 at 6 53 03 pm *For reference, in my project, I used the following yaml:
    name: Testing book
    identifier: com.ryanoconnor.example
    imports: # Optional, defaults to UIKit
    - UIKit
    - CoreGraphics
    - SceneKit
    chapters:
    - name: Ryan O'Connor
    live_view_mode: "VisibleByDefault" # defaults to "HiddenByDefault"

    Testing your completed Playgrounds Book You can use Airdrop or iCloud Drive to get it on an iPad to test. Another workaround: Since my iPad isn't on the same iCloud account as my Mac and my school disabled Airdrop, email the .playgroundbook file to yourself, then on iPad, do action "Add to iCloud Drive", selected Playgrounds folder. img_0623

ashfurrow commented 7 years ago

Those are great instructions @ryanoconnor7! I've invited you to join our GitHub organization, and I've created an empty repository that we could use to hold your instructions and sample code: https://github.com/playgroundbooks/example No pressure to accept! The example repo can look like whatever you want it to, whenever you have time. Let me know here or via email if I can help provide any guidance.

I'm going to close this issue as resolved, I've opened https://github.com/playgroundbooks/example/issues/1 to document things in the new repo.

ryanoconnor7 commented 7 years ago

Alright awesome @ashfurrow ! I know how to get the repository files up and stuff, but where should I put the instructions? In a separate file in the repo, maybe called instructions, or in the read me?

ashfurrow commented 7 years ago

Readme makes sense to me šŸ‘