We have a teleprompter scrolling app that has worked fine up through OS Ventura. Now in Sonoma the text starts to slow down after 20-30 seconds, then if left alone ends up coming to a complete stop after 2-3 minutes and is frozen until we restart the scrolling.
An odd work around, not a fix, is that when we switch the display from dark mode to light mode it will restart the scrolling as if we manually stopped and restarted.
It was built in Swift Storyboard/Xcode 15 and we have been testing on MacBooks with Intel, Silicon, M1, M2 .
OS Sonoma is the only common denominator in which we experience the issue. We submitted a case to Apple yesterday but has anyone else experienced similar issues and heard of a fix?
Swift Student Challenge
RSS for tagAsk questions and connect with other challenge applicants.
Posts under Swift Student Challenge tag
52 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hello! I have requested permission to participate in this years swift student challenge, but in the response is the link for the form for last years challenge.
Hello,
For the Swift Student Challenge, do I need to worry about submitting a clean source code with comments? Or does Apple judge submissions solely based on their user experience with the app?
Thanks!
Im making an app that uses drag&drop but, it doesn't work.
This is made with Swift Playground.
If you can find a solution, please let me know.
Here is the code.
//MARK: Drop Area
@ViewBuilder
func DropAera()->some View{
VStack(spacing: 12){
ForEach($rows,id:\.self){$row in
HStack(spacing: 10){
ForEach($row){$item in
Text(item.value)
.font(.system(size: item.fontSize))
.padding(.vertical,5)
.padding(.horizontal,item.padding)
.opacity(item.isShowing ? 1 : 0)
.background{
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(item.isShowing ? .clear : .gray.opacity(0.25))
}
.background{
// If Item is Dropped into Correct Plase
RoundedRectangle(cornerRadius: 6, style: .continuous)
.stroke(.gray)
.opacity(item.isShowing ? 1 : 0)
}
// MARK: Adding Drop Operation
// MARK: Adding Drag Drop Operation
.onDrop(of: [.url], isTargeted: .constant(false)) {
providers in
if let first = providers.first{
let _ = first.loadObject(ofClass: URL.self) {
value,error in
guard let url = value else{return}
if item.id == "\(url)"{
droppedCount += 1
let progress = (droppedCount / CGFloat(characters.count))
withAnimation{
item.isShowing = true
updateShuffledArray(character: item)
self.progress = progress
}
}
else{
//Animating When Wrong text
animateView()
}
}
}
return false
}
}
}
if rows.last != row{
Divider()
}
}
}
}
@ViewBuilder
func DragArea()->some View{
VStack(spacing: 12){
ForEach(shuffledRows,id: \.self){row in
HStack(spacing: 10){
ForEach(row){item in
Text(item.value)
.font(.system(size: item.fontSize))
.padding(.vertical,5)
.padding(.horizontal,item.padding)
.background{
RoundedRectangle(cornerRadius: 6, style: .continuous)
.stroke(.gray)
}
// MARK: Adding Drag Drop Operation
.onDrag{
// Returning ID to find whitch Item is Moving
return .init(contentsOf: URL(string: item.id))!
}
.opacity(item.isShowing ? 0 : 1)
.background{
RoundedRectangle(cornerRadius: 6, style: .continuous)
.fill(item.isShowing ? .gray.opacity(0.25) : .clear)
}
}
}
if shuffledRows.last != row{
Divider()
}
}
}
}
I am currently working on a project for the Swift Student Challenge. One part of the app is for visualizing goals with a chart created using Swift Charts. In the app, you log your progress for the goal and then it should show up in the chart. My issue is that the data is not showing after it has been logged. Here are some code snippets:
Code For Chart View
Chart {
let currentDate = Date.now
BarMark (
x: .value("Day", "Today"),
y: .value("Score", goalItem.getLogItemByDate(date: currentDate).score)
)
}
.frame(maxHeight: 225)
.padding()
GoalItem Data Object
public class GoalItem: Identifiable {
public var id: String
var name: String
var description: String
var logItems: [String: GoalLogItem]
init(name: String, description: String) {
self.id = UUID().uuidString
self.name = name
self.description = description
self.logItems = [:]
}
func log(date: Date, score: Double, notes: String) {
self.logItems[dateToDateString(date: date)] = GoalLogItem(date: date, score: score, notes: notes)
}
func getLogItemByDate(date: Date) -> GoalLogItem {
let logItem = self.logItems[dateToDateString(date: date)]
if logItem != nil {
return logItem!
} else {
return GoalLogItem(isPlaceholder: true)
}
}
}
After logging something using the GoalItem.log method, why does it not show up in the chart? Are the variables not updated? If so, how would I get the variables to update?
Thanks
Hello,
Does anyone know how to restrict my app playground to run on iPhones only (not even iPads) and to always be presented in portrait mode? I'm using Xcode.
Thanks for any help!
Hello,
The appearance of one of my buttons is not updating after being tapped. I have had no trouble doing the exact same thing in my other views, but here it simply doesn't work. The "heart" button will keep its original appearance (in this case an unfilled heart) no matter what, despite my print statements indicating that the value has changed. The other actions performed when tapping the heart work perfectly. I've been at it for hours.
Any help would be appreciated. Thanks!
import SwiftUI
struct SearchView: View {
@State private var searchText = ""
@StateObject var save = SaveWords()
@State var heart: String?
@State var disappear = false
@State var done = true
var body: some View {
NavigationView {
VStack {
if !disappear {
SearchBarView(text: $searchText)
Spacer()
}
if searchText != "" {
List(.constant(Array(FetchWord.getWordFromStart(start: searchText)).prefix(10).map {Word(word: $0.1)})) { suggestion in
NavigationLink(destination: suggestion.IPA.wrappedValue == "error" ? AnyView(EmptyView()) : AnyView(PracticeView(wordSheet: suggestion)
.onAppear {
disappear = true
if done {
SaveWords.file = "Favorites"
DispatchQueue.main.async {
Task {
try? await save.load()
heart = save.words.contains(suggestion.wrappedValue) ? ".fill" : ""
}
}
}
}
.onDisappear {
disappear = false
Task {
SaveWords.file = "History"
try? await save.load()
if save.words.first != suggestion.wrappedValue {
save.words.insert(suggestion.wrappedValue, at: 0)
try? await save.save()
}
}
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
SaveWords.file = "Favorites"
done = false
if heart == "" {
heart = ".fill"
DispatchQueue.main.async {
Task {
try? await save.load()
if !save.words.contains(suggestion.wrappedValue) {
save.words.insert(suggestion.wrappedValue, at: 0)
try? await save.save()
}
}
}
} else {
heart = ""
DispatchQueue.main.async {
Task {
try? await save.load()
try? await save.delete(wordToDelete: suggestion.wrappedValue)
try? await save.save()
}
}
}
done = true
}, label: {
Image(systemName: "heart" + (heart ?? ""))
})
}
})
) {
if suggestion.IPA.wrappedValue != "error" {
CardView(wordSheet: suggestion)
}
}
}
}
}
Spacer()
}
}
}
#Preview {
SearchView()
}
Your app playground must be built with and run on Swift Playgrounds 4.4 or later (requires iPadOS 16 or macOS 13.5, or later) or Xcode 15 on macOS 13.5, or later. You may incorporate the use of Apple Pencil.
If I want to develop a playground for the iPad and Apple Pencil, am I limited to using Playgrounds on iPadOS to make it? Or could I also use Playgrounds on macOS and Xcode?
If I use Xcode to make my iPad playground, should I select "Xcode" for "Which software should we use to run your app playground?" I assume so, as I used Xcode to make my app — but then it will be run in a simulator by the judges, which means they cannot use the Apple Pencil.
I'm a little lost here. Any guidance is appreciated.
I am making a code that uses pencilKit and you can draw on the canvas. However, I want to be able to detect if the resulted drawing is in contact with a Rectangle().
Is there any way to do this?
I dont want to use variables for X and Y positions because I have more than 400 rectangles in a grid.
Hi! While working on my Swift Student Challenge submission it seems that I found a race condition (TOCTOU) bug in SwiftUI when using sheets, and I'm not sure if this is expected behaviour or not.
Here's an example code:
import SwiftUI
struct ContentView: View {
@State var myVar: Int?
@State private var presentSheet: Bool = false
var body: some View {
VStack {
// Uncommenting the following Text() view will "fix" the bug (kind of, see a better workaround below).
// Text("The value is \(myVar == nil ? "nil" : "not nil")")
Button {
myVar = nil
} label: {
Text("Set value to nil.")
}
Button {
myVar = 1
presentSheet.toggle()
} label: {
Text("Set value to 1 and open sheet.")
}
}
.sheet(isPresented: $presentSheet, content: {
if myVar == nil {
Text("The value is nil")
.onAppear {
print(myVar) // prints Optional(1)
}
} else {
Text("The value is not nil")
}
})
}
}
When opening the app and pressing the open sheet button, the sheet shows "The value is nil", even though the button sets myVar to 1 before the presentSheet Bool is toggled.
Thankfully, as a workaround to this bug, I found out you can change the sheet's view to this:
.sheet(isPresented: $presentSheet, content: {
if myVar == nil {
Text("The value is nil")
.onAppear {
if myVar != nil {
print("Resetting View (TOCTOU found)")
let mySwap = myVar
myVar = nil
myVar = mySwap
}
}
} else {
Text("The value is not nil")
}
})
This triggers a view refresh by setting the variable to nil and then to its non-nil value again if the TOCTOU is found.
Do you think this is expected behaivor? Should I report a bug for this? This bug also affects .fullScreenCover() and .popover().
I noticed updating a @Transient attribute's value does not refresh SwiftUI views when using a SwiftData model with @Query or @Bindable.
Here is a sample code (clicking the button changes the Transient attribute):
import SwiftUI
import SwiftData
// SwiftUI App struct declaration
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(for: MyModel.self)
}
}
// My SwiftData test model
@Model
class MyModel {
var myFirstArray: [Int]
@Transient var mySecondElement: Bool = false
init(myFirstArray: [Int] = [Int](), mySecondElement: Bool = false) {
self.myFirstArray = myFirstArray
self.mySecondElement = mySecondElement
}
}
// The SwiftUI View
struct ContentView: View {
@Query var myModels: [MyModel]
@Environment(\.modelContext) var modelContext
var body: some View {
VStack {
if myModels.count != 0 {
Text("Model:")
// I expected this to update when the button is clicked
Text("mySecondElement's value: \(myModels[0].mySecondElement ? "True" : "False" )")
Button {
// button that changes the transient attribute
myModels[0].mySecondElement.toggle()
print(myModels[0].mySecondElement) // this prints the actual value
} label: {
Text("Add mySecondElement data")
}
}
}
.onAppear {
try? modelContext.delete(model: MyModel.self)
if myModels.count == 0 {
let model = MyModel(myFirstArray: [0, 1, 3])
modelContext.insert(model)
}
}
}
}
I expected ContentView() to be refreshed when I clicked on the button. However, this seems to not be the case - it seems that attributes marked with @Transient don't publish updates to Views.
Is this expected behaviour? Should I file a bug / feedback for this?
Is it possible to create SwiftData Document-based apps in App Playgrounds (or Swift Packages, since App Playgrounds are a special type of packages)?
As explained in wwdc2023-10154, to create a document-based app you are required to provide an UTType that conforms to com.apple.package. This requires your file type to be declared and exported in the Info.plist file of an Xcode project, but App Playgrounds don't have them.
Providing .package as a UTType seems to partially work:
import SwiftUI
import SwiftData
@main
struct SwiftDataFlashCardSample: App {
var body: some Scene {
#if os(iOS) || os(macOS)
DocumentGroup(editing: Card.self, contentType: .package) {
ContentView()
}
#else
WindowGroup {
ContentView()
}
.modelContainer(for: Card.self)
#endif
}
}
This way I am able to run the app, create and edit new document, and save it on disk. However, opening it again does not work (you cannot select it since it is a folder without a defined package type).
Is there any workaround to this?
I guess I could drop support for multiple documents entirely if this is not possible (I don't think this would affect my submission), but I would just like to check if there is any way to do this first.
Hello,
Very recently, the following code has automatically appeared at the bottom of three of my SwiftUI View files:
@available(iOS 17.0, macOS 14.0, tvOS 17.0, visionOS 1.0, watchOS 10.0, *)
struct $s10Accent_Ace33_0BADA584A03144EFDAB57154E6FD3FBALl7PreviewfMf_15PreviewRegistryfMu_: DeveloperToolsSupport.PreviewRegistry {
static let fileID: String = "Accent_Ace/HistoryView.swift"
static let line: Int = 47
static let column: Int = 1
static func makePreview() throws -> DeveloperToolsSupport.Preview {
DeveloperToolsSupport.Preview {
let randomWord1 = FetchWord.getRandomWord()
let randomWord2 = FetchWord.getRandomWord()
@State var randomWords = [Word(word: randomWord1.0, IPA: randomWord1.1, lineNumber: randomWord1.2), Word(word: randomWord2.0, IPA: randomWord2.1, lineNumber: randomWord2.2)]
HistoryView(words: $randomWords)
}
}
}
This is from one of my files but it's very similar in the other two. It seems to have something to do with my previews.
The problem is that this code generates an error: Ambiguous use of 'init(_:traits:body:)'. My previews worked just fine before the auto-generated code appeared, so I tried deleting it. However, it automatically comes back no matter how many times I get rid of it. It's preventing me from building my App Playground, so I can't run the app or even see the previews. Does anyone know how to get rid of it or fix the error?
Thanks for the help!
Hi, I am participating in the swift student challenge, and I need some help.
When I make a color by Color(red: , green: , blue: ), I calculate it by getting the rgb of the color that I want and dividing each of the colors by 255. For example, if red was 5, I would divide it by 255 to get 0.01960784313, which I put in the code for the red parameter. However, when I run the code, the color that appears is a bit different than the one I was expecting to see. Can someone please explain this?
Hi Developers,
I want to create a Vision app on Swift Playgrounds on iPad. However, Vision does not properly function on Swift Playgrounds on iPad or Xcode Playgrounds. The Vision code only works on a normal Xcode Project.
SO can I submit my Swift Student Challenge 2024 Application as a normal Xcode Project rather than Xcode Playgrounds or Swift Playgrounds File.
Thanks :)
Hello,
My App Playground uses a text file to work properly. I've had no issues running the app on Simulator, but it fails to find the file when being run on my physical iPhone. Has anyone had the same issue? Any idea what the problem is?
Thanks for the help!
Hello, is the new Journaling Suggestions API available in App Playgrounds (made using Xcode)?
I know I can add capabilities in Xcode, but it seems that the Journaling Suggestions capability isn't available. I assume this API is currently unsupported in App Playgrounds?
I am developing my app for the Swift Student Challenge 2024. I have made significant progress on it and have been building it on a M1 Mac, where it works perfectly. However, when testing it on some iPads (specifically, the iPad Pro 2018 and iPad Air 5 M1), it did not perform well on these devices.
I am wondering if I can specify whether the app should be reviewed on a Mac (M1 or later) or if it will be reviewed on an iPad.
Hi! I'm preparing to apply for the Swift Student Challenge and had a question, how can I find info.plist in Xcode 15.2 playground I will do a game AR game and I need info.plist to access to camera so how can I find info.plist ?
Hi! I'm preparing to apply for the Swift Student Challenge and had a question.
In the terms and conditions, it says
"Your app playground must be built with and run on Swift Playgrounds 4.4 or later (requires iPadOS 16 or macOS 13.5) or Xcode 15 on macOS 13.5 or later. You may incorporate the use of Apple Pencil."
Does this mean that my app must run on iPadOS 16 or macOS 13.5, or can it run on iPadOS 17 or macOS 14 or later as long as it runs on Playgrounds 4.4?
In other words, what should I set my Deployment Target to?
Thanks for your help in advance 😜