Swift Playgrounds

RSS for tag

Learn and explore coding in Swift through interactive learning experiences on the Swift Playgrounds app for iPadOS and macOS.

Posts under Swift Playgrounds tag

82 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

(Swift Playgrounds for Mac) How do I build for iPhone?
I am trying to challenge myself by building an iPhone app in Swift Playgrounds. I just got a Mac Mini M4, so I am trying Swift Playgrounds for Mac. I can submit a build to TestFlight, but it's for Mac and won't let me even test on my iPhone. How can I build my app for iPhone? The least "hacky" answer is appreciated, but I'll entertain anything. Examples in order of hackiness might be: I missed an option in Playgrounds for Mac. Open my playground in Xcode, change something, open back in Playgrounds for Mac. Same as above, but maybe I have to add/copy a file (e.g., manifest.plist). Open my playground in Playgrounds for iPad (I have an iPad 9), do something, copy back to Playgrounds for Mac. Submit via Playgrounds for iPad. Submit via Xcode. BTW, I'm challenging myself not just for its own sake, but because I'm curious how far a student/newbie/etc can take Swift Playgrounds. I was hoping to set a good example for others looking for a lighter-resource, more user-friendly experience than Xcode (which is why I assume Playgrounds for Mac even exists). But right now it feels like Playgrounds for Mac is a … third-class citizen? Maybe the iPad version is second-class? I haven't really tried it. P.S. Why does this text editor seem so lame? Making a numbered list and adding to it is a nightmare. Should be: start a numbered list, hit return, new number appears below. I'm on Safari. This should be the best dev experience on the planet, not the worst!
1
0
141
1w
Missing EnvironmentObject from TableColumn on macOS
I encountered a strange behavior that reminded me of when .sheet() modifiers didn't inherit environment objects. Unless I'm missing something very obvious, it seems to me that TableColumn may expose the same issue. At least on macOS, because the very same code does not crash on iOS. I'm posting this here before reporting a SwiftUI bug. Below is a gist for a playground: https://gist.github.com/keeshux/4a963cdebb1b577b87b08660ce9d3364 I also observe inconsistent behavior when building with Xcode 16.1 or 15.4, specifically: https://github.com/passepartoutvpn/passepartout/issues/872#issuecomment-2477687967 The workaround I resorted to is re-propagating the environment from the parent: https://github.com/passepartoutvpn/passepartout/pull/873/files#diff-c662c4607f2adfd0d4e2c2a225e0351ba9c21dbdd5fc68f23bc1ce28a20bce4dR45
1
0
203
3w
Completely new to programming, looking for resources.
Hello Everyone, I am completely new to programming, I have played with the Playgrounds app and I understand how some of the basic concepts work, however when going through "A Swift Tour" on developer.apple.com I struggle to understand a lot of the concepts presented. Are there any resources that someone can recommend so I can continue to learn? I tried just watching the video and searching the things I didn't understand, but I don't think I am learning much this way.
2
0
414
Nov ’24
Empty canvas in Swift Playgrounds Mac 15.1
Hi, First post and I am a total newbie when it comes to Ipads & Macs... And also this forum, so sorry if I post in wrong section. My son use Ipad at school and they use Swift Playground there. To be able to do some programming at home, I have set up Vmware with Sequoia 15.1. I installed the app Swift Playground and try to run the playground Get Started with Code and some other education playgrounds. If I understand correctly, it should be some landscape and a figure on the canvas... For me it is only a blue area. I installed XCode, but could not figure out how to run the learning examples there. Tips? Is it possible to run the education playgrounds there? I removed Swift Playgrounds and installed it again, same issue. I also installed IOS 18.1 (?) but I am not sure it is needed. Any suggestion of how I can get contents to show on the canvas? Except of bying an Ipad. ;)
1
0
238
Nov ’24
Xcode (Cloud) vs. Playground App
Hej hej tl;dr. I have problems building a Playground App using Xcode Cloud and I created a reference repository to reproduce this. Did anyone try this before and succeeded? Maybe you have a hint about what's going wrong here. Initial Failure I followed the documentation for Building Swift packages and Swift Playgrounds app projects with Xcode Cloud and I have always run into the following error message: ❌ Code Signing Exporting for App Store Distribution failed. Please download the logs artifact for more information Check Logs “Fair game!” I thought, checked out the logs and see this error appearing twice in each of the following steps: Export archive for ad-hoc distribution Export archive for development distribution Export archive for app-store distribution 5.3 Sec. Run command: 'xcodebuild -exportArchive -archivePath /Volumes/workspace/tmp/3546d064-74fa-42d0-8b36-3623e18941be.xcarchive -exportPath /Volumes/workspace/adhocexport -exportOptionsPlist /Volumes/workspace/ci/ad-hoc-exportoptions.plist '-DVTPortalRequest.Endpoint=http://172.16.35.199:8089' -DVTProvisioningIsManaged=YES -IDEDistributionLogDirectory=/Volumes/workspace/tmp/ad-hoc-export-archive-logs -DVTSkipCertificateValidityCheck=YES -DVTServicesLogLevel=3' Error Command exited with non-zero exit-code: 70 Moving forward, I downloaded the logs artifact as suggested earlier. This is IDEDistribution.standard.log: 2024-10-27 11:15:04 +0000 [MT] Starting export with options: {"embedOnDemandResourcesAssetPacksInBundle":true,"teamID":"38R2LLP8AF","stripSwiftSymbols":true,"thinning":"<none>","iCloudContainerEnvironment":"Development","destination":"export","reformatterBundleIdentifier":"hamburg.plus.encore","uploadSymbols":true,"raiseProfileSupportOptionalToRequired":false,"buildNumber":"4","testFlightInternalTestingOnly":false,"manageAppVersionAndBuildNumber":false,"method":"ad-hoc","generateAppStoreInformation":false} This is IDEDistribution.critical.log (actually it's three times this single error, but I'll spare you the repetition): 2024-10-27 11:15:04 +0000 [MT] -[IDEDistributionMethodManager orderedDistributionMethodsForTask:archive:logAspect:]: Error = Error Domain=IDEDistributionMethodManagerErrorDomain Code=2 "Unknown Distribution Error" UserInfo={NSLocalizedDescription=Unknown Distribution Error} And this is an excerpt (of hopefully relevant details) of IDEDistribution.verbose.log (again, this happens three times, only giving the relevant data points here): … 2024-10-27 11:15:04 +0000 [MT] Rejected distribution method <IDEDistributionMethodiOSAdHoc: 0x600001590100> because it doesn't support distributing archive … 2024-10-27 11:15:04 +0000 [MT] Rejected distribution method <IDEDistributionMethodiOSAppStoreValidation: 0x6000015900f0> because it doesn't support distributing archive … 2024-10-27 11:15:04 +0000 [MT] Rejected distribution method <IDEDistributionMethodiOSAppStoreDistribution: 0x600001590120> because it doesn't support distributing archive … 2024-10-27 11:15:04 +0000 [MT] Rejected distribution method <IDEDistributionMethodiOSAdHoc: 0x600001590100> because it doesn't support distributing archive … 2024-10-27 11:15:04 +0000 [MT] Available distribution methods: {( <IDEDistributionMethodSaveBuiltProducts: 0x6000015f8060>, <IDEDistributionMethodExportArchive: 0x6000015f8070> )} Investigate Xcode Archive (*.xcarchive) At this point, I downloaded the Xcode archive from AppStoreConnect and realized that it only contained debug symbols for the app, but not the app itself. > ls -la /Users/herzi/Downloads/….xcarchive/Products total 0 drwxrwxr-x@ 2 herzi staff 64 27 Okt 12:21 . drwxrwxr-x@ 5 herzi staff 160 27 Okt 12:22 .. Notice the absence of the Applications folder that would contain the Application.app bundle. Current Status So I created a clean, sample repository for my integration. Did anyone try this before and succeeded? Maybe you have a hint about what's going wrong here.
1
0
282
Nov ’24
Swift Student Challenge requires Swift Playground (.swiftpm), minimum OS setting not available.
When making a new Swift Playground via Xcode > New > Project > iOS > App Playground, as a .swiftpm package, the settings are very limited, including setting the minimum OS version. This is incredibly irritating because I can't keep make @available blocks because that would double the size of my code, and I can't use SwiftData (for example) because my app needs to also support iOS 16. Is there a way to set the minimum OS or some other upload type accepted for Apple so that I can change this simple setting? Thank you
2
0
378
Oct ’24
Seriously? I can't deploy my demo to iPad cus swift 6?
Okay everyone who click into or just pass by this post ,to cut a farrrirly long story short ,here is the thing... I was devloping my app in the playground on my Mac , which was building for the iPad, In the early time of real machine commissioning(through the Xcode ),everything is okay everything is okay.. "well,mabe it's time to deploy my app to the playground in ipad"! Then,to top it all off🤣,then playground tell me (In case that you can't understand chinese and creat ambiguity ) emm that's too tight...,so I can only got back to the Xcode changing my language version to swift 5 then..... Noting change .... and I think err.. in order to properly deploy app to iPad ,I had to rework my code with swift 5! So, I almost fell on my knees ,can somebody who in charge of the playground ,can somebody who in charge of the playground ,just ,just! shove swift 6 in the playground (as long as it make my code run anyway), otherwise there's no way to debug it! please please plase!
1
2
383
Oct ’24
iOS 18 features not working in Xcode iOS playground
When I create a new iOS playground in Xcode 16.0 with an iOS 18.0 SDK installed, I cannot use some of the new features such as the new way for programming tab layouts. When I just use an Xcode project, these features work as expected. In a playground, I get errors saying "x is only available in iOS 18.0 and later". I have noticed this for more than just this feature. Is there some way I can force the playground to run with iOS 18 as I have the appropriate SDKs installed?
0
1
313
Oct ’24
Help by Swift Playground App
I would like to program an app in Swift Playground that displays WhatsApp Web in a webview, so to speak. But I keep seeing an error like in the screenshot. My Code: import SwiftUI import WebKit import PlaygroundSupport struct WebView: UIViewRepresentable { let url: URL func makeUIView(context: Context) -&gt; WKWebView { let webView = WKWebView() let request = URLRequest(url: url) webView.load(request) return webView } func updateUIView(_ webView: WKWebView, context: Context) { } } struct ContentView: View { var body: some View { WebView(url: URL(string: "https://web.whatsapp.com")!) .edgesIgnoringSafeArea(.all) } } PlaygroundPage.current.setLiveView(ContentView())
0
0
246
Oct ’24
Playgrounds issue: Has to reload the puzzle every time we test code
Hi! I have a remote student who's learning to code in Swift using Playgrounds - Learn to Code 2. It's frustrating to try to test his code when we think he as part of a solution to a puzzle because he can't run his code twice in the same puzzle without resetting the puzzle - when he tries, the page gives an error, and he has to reload the whole puzzle, which erases his code. As a workaround, he's been copying his code and reloading the puzzle whenever he wants to test out a partial solution. Is there an easier way to do this?
0
0
288
Sep ’24