Using UIKit & Storyboards

Hello,

For the past month, I've been learning to use UIKit on Xcode to prepare for the Swift Student Challenge. However, I can't find a way to use my newly acquired skills in App Playgrounds. Do they strictly require SwiftUI? Is there a way to use UIKit and Storyboards?

Accepted Reply

I just tested this by creating a new iOS Xcode project with Swift & UIKit, then copied the Swift files to a new App Playground (and deleted the old MyApp and ContentView SwiftUI files). It seems to work fine (I'm not entirely sure about storyboards though), which was expected in my opinion - as long as you have the necessary code and the @main attribute somewhere in your code, the app should compile and run. What I'm not entirely sure of is how / if storyboards are supported in Playgrounds.

However, I'd definitely recommend you to learn SwiftUI as well. It should be easy to learn using the available resources and you can also use UIKit with SwiftUI code.

Good luck!

Replies

App playgrounds require you to use SwiftUI.

You have to create an Xcode app project to use UIKit and storyboards.

Add a Comment

I just tested this by creating a new iOS Xcode project with Swift & UIKit, then copied the Swift files to a new App Playground (and deleted the old MyApp and ContentView SwiftUI files). It seems to work fine (I'm not entirely sure about storyboards though), which was expected in my opinion - as long as you have the necessary code and the @main attribute somewhere in your code, the app should compile and run. What I'm not entirely sure of is how / if storyboards are supported in Playgrounds.

However, I'd definitely recommend you to learn SwiftUI as well. It should be easy to learn using the available resources and you can also use UIKit with SwiftUI code.

Good luck!