For the SSDC submission, the app playground must run on Swift Playgrounds 4.5+ or Xcode 16+.
Key questions:
In Swift Playgrounds, is the app tested on iPadOS or macOS?
In Xcode 16+, is the playground tested using Mac Catalyst, an iPad simulator, or an iPhone simulator? The submission form only mentions a simulator but doesn’t specify which one.
Can I build an app primarily for iPhone (portrait mode), or is it better to focus on iPad (landscape mode) if that’s the expected testing environment in all cases?
Swift
RSS for tagSwift is a powerful and intuitive programming language for Apple platforms and beyond.
Posts under Swift tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I'm using the NEHotspotConfigurationManager class, with joinOnce = false, to connect to a Wi-Fi network that lacks internet access (IoT device).
After restarting my iPhone, the first connection to this network disconnects automatically in less than a minute. All subsequent connections remain stable without disconnecting. What could be causing this?
This crash report for one of my apps was downloaded by Xcode. Apparently the app crashed while releasing an object of type Scan.File, which is a Swift class held in an array in the Scan.Directory class. I'm not doing any manual reference counting or low-level stuff with that object.
What could cause such a crash?
crash.crash
I have this code:
var eventIn = kevent(ident: UInt(self.socket),
filter: Int16(EVFILT_WRITE),
flags: UInt16((EV_ADD | EV_ENABLE)),
fflags: 0,
data: 0,
udata: nil
)
I looked at it and thought why do I have those extra parentheses? So I changed it to
var eventIn = kevent(ident: UInt(self.socket),
filter: Int16(EVFILT_WRITE),
flags: UInt16(EV_ADD | EV_ENABLE), // changed line!
fflags: 0,
data: 0,
udata: nil
)
and then kevent gave me EBADF.
Does this make sense to anyone?
Hi the below array and code to output a list item works fine:
var quotes = [
[
"quote": "I live you the more ...",
"order": "1"
],
[
"quote": "There is nothing permanent ...",
"order": "2"
],
[
"quote": "You cannot shake hands ...",
"order": "3"
],
[
"quote": "Lord, make me an instrument...",
"order": "4"
]
]
cell.textLabel?.text = quotes[indexPath.row]["quote"]
However if I change the "order" values to be numbers rather than text like below then for the above line I get an error message in Xcode "No exact matches in call to subscript". Please could someone tell me how to make it work with the numbers stored as numbers? (I'm wondering if creating an any array type and using the .text function has caused a conflict but I can't find how to resolve)
[
"quote": "I live you the more ...",
"order": 1
],
[
"quote": "There is nothing permanent ...",
"order": 2
],
[
"quote": "You cannot shake hands ...",
"order": 3
],
[
"quote": "Lord, make me an instrument...",
"order": 4
]
]
Thank you for any pointers :-)
Whenever I run anything in xcode it opens an extra terminal that runs the program then exits immediately, but the app still runs through the normal xcode launch. It's not a huge issue but It's getting really annoying to realize I have like 7 windows of terminal open that are just doing nothing.
Has anyone had this issue before?
I have 2 versions of my app. This version I issued the "Clean Build Folder..." command. After doing so it will no longer compile/build. I've restored the directory to a copy prior to the Clean Build Folder with same result. The other version of this code will build and execute.
Command SwiftCompile failed with a nonzero exit code
/Users/martinwoscek/develop/iOS_switft_DEVELOP/FullScreenCamera-master-no_drivemonitor/AV Foundation/Base.lproj/LaunchScreen.storyboard: Encountered an error communicating with IBAgent-iOS.
Showing Recent Issues
.
.
.
Command SwiftCompile failed with a nonzero exit code
Command SwiftCompile failed with a nonzero exit code
Build failed 2/11/25, 8:15 AM 1.4 seconds
I used Swift Playground to develop application in Mac OS. Also using ZStack I used limited area in full page (using .frame(width: $, height: $)). However using command + R or clicking start button to see preview .app, while non resizing application my ZStack show as cutted. Please tell me how to set preview .app frame size as width, height... The buttom code is ContentView.swift code.
@main
struct ContentView: App {
init() {
MyFont.registerFonts()
}
// @StateObject private var audioPlayer = AudioPlayer()
var body: some Scene {
WindowGroup {
NavigationStack {
StartMenuView()
.frame(minWidth: 594, maxWidth: 594,
minHeight: 1142, maxHeight: 1142)
.preferredColorScheme(.dark) // Dark Mod
.statusBar(hidden: true) // Hidden Status Bar
.edgesIgnoringSafeArea(.all) // Ignoring Safe Area
}
}
.windowResizability(.contentSize)
}
}
Thank you for reading.


Hello folks,
I'd like to report a bug in Swift Playground to Apple official dev team, it's in "Learn to Code 2" - "Seeking Seven Gems".
The puzzle map can't be loaded, please check the following screenshot,
My system environment:
MacOS 15.3
Swift 6.0.3 (swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1))
Swift Playground 4.6.2
Xcode 16.2
Hardware: MacBook Pro/M2 Pro/32G
I tried to create a Text View using attributedString. I want to set the line height using paragraphStyle and return the Text, but paragraphStyle is not being applied. Why is that?
extension Text {
init?(_ content: String, font: StyleType, color: Color = .ppBlack) {
var attributedString = AttributedString(content)
attributedString.font = Font.custom(font.fontWeight, fixedSize: font.fontSize)
attributedString.foregroundColor = color
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = 16
paragraphStyle.maximumLineHeight = 16
paragraphStyle.lineSpacing = 0
attributedString.mergeAttributes(.init([.paragraphStyle: paragraphStyle]))
self = Text(attributedString)
}
}
Is there a way to create a Date constant from year, month and day? The only constructors that show up are .now and those based on some timeInterval. I'm trying to initialize some test data with known dates.
Hello!
I'm trying to set a UiRefreshControl.tintColor:
.onAppear {
UIRefreshControl.appearance().tintColor = UIColor.systemBlue
}
But instead of
I get
The color in the second picture is a high contrast version of the first one. I can't understand why it works this way.
I also tried the following.
UIRefreshControl.appearance().tintColor = UIColor(red: 0, green: 0.478, blue: 1, alpha: 1) // doesn't work
UIRefreshControl.appearance().tintColor = UIColor(named: "RefreshControlColor") // doesn't work, here set "High contrast" on and indicated Universal.systemBlueColor
Perhaps I missed something?
After the app is put in background for sometime and brought in to foreground and the app crashes each time with a different thread stack entries but all of them states same exception reason.
Hey,
I would love to access the users Contact (ie. the Me Card)
Apple recently released the Invites app and within this app you can find the users Contacts Photo. I tried to replicate this behaviour but I currently need to match based on a name or email or something else. I have no idea how to receive this data because when using the Invites app I only remember the app asking for Contacts permission and nothing else so far.
let store = CNContactStore()
let keysToFetch = [CNContactImageDataAvailableKey, CNContactImageDataKey, CNContactThumbnailImageDataKey] as [CNKeyDescriptor]
let email = "test@test.de"
let predicate = CNContact.predicateForContacts(matchingEmailAddress: email)
do {
let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch)
let imageDatas: [Data] = contacts.compactMap { $0.imageData }
self.images = imageDatas.map { UIImage(data: $0) ?? UIImage() }
} catch {
print("Error fetching contacts: \(error)")
}
This is how I am retrieving the Image. MAYBE someone can help me out.
Thank you so far
~ Flo
Hi guys, I’m making a simple note taking app and I want to support markdown functionality. I have tried to find libraries and many other GitHub repos but some of them are slow and some of them are very hard to implement and not very customizable.
In WWDC 22 apple also made a markdown to html document app and I also looked at that code and it was awesome. It was fast and reliable (Apple btw).
But the only problem I am facing is that the markdown text is on the left side and the output format is on the right in the form of html. I don’t want that I want both in the same line. In bear notes and things 3 you can write in markdown and you can see that it is converting in the same line. I have also attached example videos. So, I have markdown parser by apple but the only thing in the way is that it is converting it into a html document. Please help me with this. Also please look into the things 3 video they have also completely customized the text attributes selection menu. By default with UITextView we can only enable text attributes and it shows like this.
By clicking more we get the complete formatting menu but not the slider menu which is more convenient. Please also help me this. I don’t know if I can provide apple file but it is from wwdc 22 supporting desktop class interaction
we have three problem when using the push notification on Live Activity.
1. What is the specific callback strategy for the activityUpdates property in ActivityKit?
We found that in actual user scenarios, there is a probability that we may not receive callbacks. From the community experience, there are some resource optimization strategies that do not perform callbacks. From this perspective, the explanation is kind of vague. Is there any clear feedback to understand why callbacks are performed/not performed?
2.what is the specific description of the wake-up strategy, when background app receive Live Activity offline start Push?
From community experience, we can see that the system may wake up for a duration of 0-30s due to resource optimization strategies, or not wake up/not deal with it. Is there an official description of the wake-up strategy? or we also have to follow this description:
Wake up of apps using content-available pushes are heavily throttled. You can expect 1-2 wakeup per hour as a best case scenario in the hands of your users. so this cannot be assumed to be a reliable wake-up on demand mechanism for an app.
3 How can we determine user have selected (allow or always allow) of the Live Activity permission?
When we use real-time activity offline push, there are two system prompts in iOS:
the first prompt : allow and disallow real-time activity
the second prompt : always allow and disallow
Is there an interface that can directly determine which permission the user has chosen (allow/always allow)? (By the way, we can get disallow status).
At present, we haven't seen any interface in the official documentation/interface that can determine (allow/always allow). The difference here will affect the generation of Update Token. Without Update Token, we can not update our activity instance.
Hi everyone,
I believe this should be a simple and expected default behavior in a real-world app, but I’m unable to make it work:
1. I have a View (a screen/page in this case) that calls an endpoint using async/await.
2. If the endpoint hasn’t finished, but I navigate forward to a DetailView, I want the endpoint to continue fetching data (i.e., inside the @StateObject ViewModel that the View owns). This way, when I go back, the View will have refreshed with the fetched data once it completes.
3. If the endpoint hasn’t finished and I navigate back to the previous screen, I want it to be canceled, and the @StateObject ViewModel should be deinitialized.
I can achieve 1 and 3 using the .task modifier, since it automatically cancels the asynchronous task when the view disappears:
view
.task { await vm.getData() }
I can achieve 1 and 2 using a structured Task in the View (or in the ViewModel, its the same behavior), for example:
.onFirstAppearOnly {
Task { away vm.getData() }
}
onFirstAppearOnly is a custom modifier that I have for calling onAppear only once in view lifecycle. Just to clarify, dont think that part is important for the purpose of the example
But the question is: How can I achieve all three behaviors? Is this really such an unusual requirement?
My minimum deployment target is iOS 15, and I’m using NavigationView + NavigationLink. However, I have also tried using NavigationStack + NavigationPath and still couldn’t get it to work.
Any help would be much appreciated.
Thank you, folks!
Hello!
I have a destination navigation which is TabVIew where each tab item is ScrollView. And when scrolling content of any of tab items is underneath navigation bar its background is always hidden. But at the same time tab bar background is toggled depending on scrolling content position.
I expected it would work with TabView the same as with any other view.
Is it supposed to work like that?
Hello!!in the terms of swift challenge say that is required to be enroledl to the apple developer program paid or free version (to join to developer programs you need to be under 18 years old).How over 18 years old can join to swift challenge if he can't make apple developer account.
Fatal Error in Swift Playground
Description
I'm experiencing a catastrophic error when importing Package Dependency in any Swift Playgrounds that has icon or name that caused the whole Playground won't work anymore with error messages below.
I'm current running macOS Sequoia 15.3 (24D60) and Swift Playgrounds 4.6.1. They're all up-to-date.
Reproduction
Open Swift Playgrounds and and create a new project.
Import a package dependency
https://github.com/simibac/ConfettiSwiftUI.git
Rename the project and add an icon
Then you should able the reproduce the problem. I strongly believed that this is a serious bug.
You'll find that Assets in the left column are disappeared and appeared Assets.xcassets, you're unable to reveal the Dependency in the column like the reference picture above. The whole Playground is destroyed now and unable to work anymore.