NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

Where / How do you store your sample code?

Forums > SwiftUI


How do you store your code for future use? So far I have been referring to complete projects and copied and pasted the formulas or code as needed. But I find it hard to remember what I used in each project.. How do you organize yourselves?


@Bnerd asks for hints:

How do you store your code for future use?

Dear Future Me:

In my team, we joke about writing notes to our future selves. I don't know how many times past me has provided clear, detailed explanations to confused, dumbfounded current me. You might see in some of my code, I tend to write a lot of comments. If I can 'splain it so future me can understand it, then maybe someone else can benefit.

I keep my notes in Playgrounds.

When I first started using Playgrounds, I created a NEW playground for each concept. What a waste! You can create multiple playground pages in a single playground project. Give each playground page a nice title, such as "Buttons with Gradients", "Making a Button with SF Symbols" or "Buttons with Bindings".

Soon enough, you'll have a great collection of coding tips and hints.

See -> Learner's Recipe Book


Select the code, then go to the Editor menu. At the bottom of the menu hit Create Code Snippet. You can name and edit your snippet. To use it in the future bring the snippet window up and double click the name of the code you want and it will paste it into your editor. The code snippet window also shows the Views Library and Modifiers Library. Lot of good information there.




I had already a good Playground file when started to learn SWIFT, I will continue this one, thanks for the Pages tip.

I tried also other third party apps, but, Playground just makes sense!


Hacking with Swift is sponsored by Play

SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!

Click to learn more about Play!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.