How can I build an application using only a Swift playground? - ios

I have a basic understanding of how to make iOS apps with Swift in Xcode Projects (I can make apps like flappy birds and an adapted variation of pong). My main target for this year is to be able to at least apply for the Apple WWDC student scholarship. I have read online that the scholarship submission needs to be completed and uploaded in Swift playgrounds.
As I am self-taught, I have little to no experience with Swift playgrounds. So my main question is: how do I make an application in playgrounds? I am used to beginning with a main.storyboard, but I can't find that in Swift playgrounds.
How do you go about creating an interactive application in Swift playgrounds?

You cannot use storyboards directly in a playground, which is why Xcode doesn't support creating a storyboard inside of a playground. You can access a framework from a storyboard inside of a workspace (including cocoapods), so one solution is to make a framework to load your storyboards. This doesn't seem to fit with your criteria of making everything in playgrounds though. So you can either make all of your view programmatically or you can drag in compiled nib files to your Playground Resources folder and load the nibs from there (the playground cannot load xib, which is the XML representation of the nib).

Related

Create an iMessage Extension without storyboards?

I am wondering if it is possible (and if so, some elaboration and steps to achieve) building out a custom iMessage
Extension WITHOUT using storyboards? I have my core app, and then have the additional iMessage extension target. My main app is working fine without storyboards.
I followed the tutorial here, however it is not working and makes the original app look really funky upon deleting the Launch screen interface file base name info.plist entry from the main app. This tutorial is from 2016 and uses Objective C, so that might also have something to do with it.
I know that the launch screen for the main app now requires a storyboard, and everything is working fine there.
One way is to do it in SwiftUI.
Here's a link to another question that has a complete example of a bug, but to your question has a stub of a message extension that displays a very simple view. You could expand on that.
imessage extension app group conversation send fails on first run

Trouble adding an application xib/ nib file for swift in Xcode 7.0.1?

When I click new file and go to user interface tab, I don't see the application or window options. The application file description should say "An Interface Builder document suitable for creating an iOS application, including an application delegate and window." I tried searching in the search bar in Xcode but application did not show up for iOS.
Please see screen shots and difference for clarity.
app delegate screenshot 2
my screen
Apple introduced storyboards back in 2011. Before that, developers used a .xib file to specify their user interfaces, and the "main" .xib file, i.e. the first one that the app loaded, included a proxy for the app delegate so that it was easy to connect objects to outlets in the app delegate. As matt has indicated, though, things haven't really worked that way for a while. As he says, it sounds like you're working from an old book or online tutorial, and as a result your expectations don't match the reality of modern iOS development.
These days, apps generally use a storyboard to specify all or part of the user interface. A big problem with .xib files was that you had to load an entire file at once; if you instantiated a view controller with -initWithNibName:bundle:, the entire file was loaded. That meant that you could only specify a single view controller in a given .xib file, and managing the relationships between view controllers was harder than it should be. Storyboards address this problem -- a single storyboard typically contains several view controllers.
I agree with matt that you really shouldn't work from material so old that it expects you to use .xib files to build your application. That story again:
STOP USING THAT INFORMATION
There are plenty of great resources (notably matt's own iOS 9 Programming Fundamentals with Swift) that will teach you how to write modern iOS code. Apple's own documentation is a great place to start.

Where is Objects tab in Xcode 6?

I am following a hello world tutorial for xcode. I opened my LaunchScreen.xib file in Xcode6, here is how it looks like:
But according to the tutorial, there needs to be an Objects tab. Can anyone tell me where i can find it?
Thanks
Edit: Here is how it looks like in the tutorial:
I want to find my AppDelegate.h file but i cannot find it.
The Objects section of the document outline has been removed. Everything that was formerly under it is now a top-level item in the document outline. So everything that you now see in the outline that isn't under the “Placeholders” section would formerly have been under “Objects”.
Xcode's project templates have changed since your tutorial was written. When your tutorial was written, the template used a xib file that contained the app delegate and the window. Now, the template uses a storyboard. The system instantiates the app delegate and the window automatically and loads the initial view controller and its view from the storyboard.
The xib you are looking at (LaunchScreen.xib) is a new feature for iOS 8 that replaces the launch image PNGs you must use in older versions of iOS. It is not the xib you are looking for to work through your tutorial.
It would be possible to modify your project to match what the tutorial assumes you have, but doing so is probably not worth the effort. Look for a tutorial written for Xcode 5.1 or later that assumes you are starting with a storyboard.

Create a project with Storyboard, Cocos2D and ARC enabled

I'm using XCode 4.5.2 to create an iOS universal application.
I'd like to use its storyboard for my application. Normally, I create new project by choosing New > Project > Single view project > check Use storyboard.
Sometimes in my application, I need to use Cocos2D for complex animation (no need to interactive with it, only for presentation).
My animation was created using CocosBuilder which works with Cocos2D 2.0 and CCBReader library.
I tried to add Cocos2D to my existing project by:
Adding Cocos2D folder (include Support, Platforms, kazmath folders).
Try thing like edit -fno-obj-arc to those *.m files in Build Phases/Compile Sources.
But when I build project, the ARC errors are still there.
#Question:
How could I implement Cocos2D into existing XCode 4.3/4.5 project?
If I create a Cocos2D template project, could I activate ARC for rest of my project, those non-Cocos2D classes?
I successfully created an project with Cocos2D inside a UIView from a Cocos2D template as Ray's post but now I want things (may be) a little more complicated.
With many help from #Setrio, #LearnCocos2D and lot of Googling, I finally fixed it.
My project is combined from Cocos2D, Storyboard, ARC enabled and CocosBuilder.
First, create a project with SingleView selection (ARC enabled of course).
Then download the Cocos2D ARC enabled here https://github.com/LearnCocos2D/cocos2d-iphone-arc-templates thanks to Steffen!
Add its libs into your project as pointed out here http://www.learn-cocos2d.com/2012/04/enable-arc-cocos2d-project-video-tutorial/ (brilliant, works like charm)
Create storyboard with Cocos2D as this tutorial (sample included) http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/
All things work together now. Beautiful. I love Cocos2D :)
I don't know off the top of my head.
Yes, I have done this very thing with my latest Cocos2D-iOS project. I converted my project to ARC with the automatic refactoring tool, and I simply excluded all the Cocos2D library files from the process. for the most part the refactoring went smoothly and my project was up and running again in no time.
I found this link/tutorial useful for a project similar to this one.
http://www.tinytimgames.com/2012/02/07/cocos2d-and-storyboards/
Basically you add support for cocos2d inside the view controllers. You have to use cocos2d as a library and that solves most of the issues.

ios 5 - Code to Reflect on Storyboard

When you create an interface with Storyboard (OR normal IB) the code is generated at compile time for the app. In other words, it does not update the file of the ViewController it is linked to.
Is there a setting that allows for this?
For me I would see that as a great learning tool.
Like if I put a button on a certain place in a UIView, what would that look like in code?
Cheers Jeff
Unfortunately there is no such setting. XIB's and Storyboards are stored as XML files, and rendered into UI at runtime. On the other hand, when you create UI programmatically you write your code in Objective C using Cocoa Touch classes. There is no direct way to convert the XML into Objective C during development.

Resources