Using Pages in iPad Playgrounds - ipad

The documentation mentions:
add pages to your playground to help organize your code.
But I’m unable to access a class from a different Page. I tried setting everything public, and even creating the class in the Sources folder by starting the playground in Xcode but it crashes on launch with Problem Running Playground
I would really appreciate some help. I’m trying to use Playgrounds more, but don’t want to have all my classes & extensions in one Page.

Related

How Do You Debug Swift PlaygroundBook?

While I'm exploring Playground Book sample code, like this one, I find it to be very tedious to get the code to run because of Playground Book's limitations in where the code can run: only on iPad's Swift Playground.
There is no way to debug the "Sources" / Auxiliary code in iOS's Swift Playground, since all the source files are shown in un-editable plain text. You have to open the source files in Xcode to edit them, but then you can't compile or run them!
This is especially tedious for the sample code above, which uses PlaygroundValue, a persistence API that requires Playground Book format, so I still couldn't get the code to run by separating all source code into a separate Playground file to run on the Mac.
Since the sample code above is outdated, I find it to be near impossible to debug it right and get the code to run. You'd have to:
Deploy the code on iPad. Run the Book.
See many error messages on iPad.
Go back to Xcode on Mac and debug them one by one, manually.
Deploy the code on iPad again to run. Repeat the process.
Even after all the errors are resolved, you can still be faced with cryptic "Problem Running Playground" without any further concrete explanation.
What's your workflow to productively debug and deploy code with Playground Book? Current workflow seems impractical to me I think there must be a better way, but I'm not familiar enough with Playground Book and my online research doesn't yield any reasonable workarounds.
From a bug report / suggestion I sent to Apple, I got the following reply:
We’ve actually built tools to help debug the auxilliary sources and we did a presentation at WWDC 2018 that demonstrates it. Please view the presentation and get access to the tools here: https://developer.apple.com/videos/play/wwdc2018/413/
Upon further research, I found that they have recently released a Playgrounds Author Template:
The Swift Playgrounds Author Template is a starter Xcode project that will help you create, debug, and produce a Playground book. Using the template you can step through the code for your live view as if it were an app so that you can identify bugs more easily and develop an efficient workflow for developing your Playground books.
This template, requiring Swift 4.1 to run, includes three different targets:
PlaygroundBook
Book_Sources
LiveViewTestApp
You can use the LiveViewTestApp to fully debug your Playground Book right on your Mac with Xcode.
I am not aware of any possibility that does not require you to test the Playground on an actual iPad.
Anyway, you can make developing Swift Playgrounds less tedious by
Using iCloud to synchronize your mac version with the iPad.
Embedding your Playground in an Xcode project as described in one of my previous answers. That way, you can at least achieve autocompletion during development.
Linking your source files to another target, so that compile errors can be caught before running the Playground.
Anyway, you will still encounter mysterious "Problem Running Playground" errors from time to time

How can I transform my iOS/Swift project to a state where I will be able to use live views?

I have been working on my first iOS/Swift application for the past month or so, and have created all of my class declaration files (i.e. my .Swift files) in my main project folder. I would really like to use live views in my app, because as of right now I cannot build/run the app at all due to errors I don't know how to fix (I'll be posting about those later today in hope of finding someone who can help me fix them).
What would be the best way to go about converting all of my views into embedded frameworks so that I could use the Live Views feature of Xcode ? I am running Xcode 7 and wrote my app in Swift 2.0
Thanks
You apparently don't need to use frameworks for that anymore. At least it works just fine in Xcode 7 for me - for classes that are part of the main project. Just mark your class as #IBDesignable.
But in order to show the preview, your code needs to be able compile, so you will need to resolve your issues first.

Not required to import MapKit.framework?

I'm making an app for my exam that uses theMapKitView andCoreLocation for getting different locations and adding pins to the map.
But I realized that I hadn't imported the MapKit.framework in the build settings, which I always was told to do. What I don't understand is that everything still works without it. I'm simply using "import MapKit" when I have to use it.
So my question is: Is it really necessary to import the framework in the build settings too? Some of the other students said that theirs dodn't work without it.
Thanks!
When you enabled the "Maps" availability. Xcode automatically linked MapKit for you.

AS3 Multiple Application Domain using local null.swf file

I have the following issue, I cannot find a solution on the web, please let me know if you can help me or point me to a proper info about this issue.
To understand the background, Im porting a game from flashDevelop to Flash Builder (please dont give me tips about this comment if doesn't help to my particular problem). Everything works fine right now, the game use a file null.swf as a container of local files (I don't undertand that part completely, but the game has a lot of embed swc files, and the game use the null.swf to access those files, through LoaderMax).
The problem is that everything works fine with a fast build, but it's not working with a standard build, I have the error on Loader class that says "Multiple application domains are not supported on this operating system".
Useful information:
Im using AIR 3.9, compilation flash swf-version=20 (I had 18 when I started with this issue)
null.swf is properly included on the IPA, the code recognize the file, and as I said before it works with a fast build.
For embed swc files, I had to include the files with a compiler argument: "-include-libraries ../../filename.swc ../../filename2.swc etc.."
Thanks for any help.
Regards
It's fixed, using a context:
context = new LoaderContext(false, ApplicationDomain.currentDomain, null);
If I use the third parameter, like ..., SecurityDomain.currentDomain); it doesn't work.

OpenGL ES Programming Guide Particles example

I am trying to make the particle system example given in the book OpenGL ES programming guide to compile in iOS 6 but I don't seem to be able to make it work. For reference here is the web site of the book:
http://www.opengles-book.com/
The code can be downloaded from Google Code, see instructions below:
http://code.google.com/p/opengles-book-samples/wiki/Instructions
The code is in chapter 13.
Has anyone came across this and were able to make it work in iOS 6? I had made some modifications but still no joy.
Follow these steps:
Open "Common.xcodeproj" located in "/opengles-book-samples/iPhone/Common/"
Select to build for device or simulator and build.
After Build Succeeded close the Common.xcodeproj.
Open Finder and from the menu Go>Go to Folder... type without quotes "~/Library/Developer/Xcode/DerivedData/" and find the folder called "Common-bkoronpjvpvwbxgdgxbwiukcqwaz" inside folder go to : /Build/Products/ and copy "libCommon.a" to ParticleSystem project.
Build&Run particle example.
That's it. :)
Good luck.

Resources