Post

Replies

Boosts

Views

Activity

Reply to SwiftData erors in Swift Playground
Hi! SwiftData is a framework available in iOS 17 or newer. By default, it seems that App Playgrounds default to iOS 16 support in Xcode. The App you will submit to the Swift Student Challenge will need to run on iOS 16 or newer as explained on this thread, but if you want to add iOS 17-specific behaviour, you could use the if #available version check or the @available(iOS 17.0, *) attribute as explained in this other thread. Do not change the minimum deployment version in the Package.swift mentioned in the latter thread! As I previously said, the minimum version should be iOS 16 for 2024 Swift Student Challenge submissions.
Feb ’24
Reply to Can I enhance and resubmit my rejected Swift Student Challenge project with added features?
I'm not a judge if that's who you're looking for. In fact I am also an applicant (who also applied during the last 2 years), but I hope my thoughts will be helpful to you. Don't rely solely on them, though :). Note that I haven't submitted the same idea twice, so I am speculating based on the T&C. Short answer: I think it depends on what your substantial changes actually are. You're saying they are substantial, so if your app is very different from your previous submission (but shares the same core concept), it might be fine. As you probably know, the terms say that one of the reasons of disqualification is if "You submit the same app playground that you submitted previously, with minimal or no changes." I think this means you shouldn't submit the same app, with just a few new lines of code & features. So, unless you submit a very similar App Playground (almost the same one), it is permissible. I think there's two main things you should do: Don't submit an app playground that you submitted previously, with minimal or no changes. Otherwise you might be disqualified. Brainstorm what you could've done better in your submission (better implementation / better idea etc.) to change the outcome of your submission. Even if you don't have the same playground and it is new, it could still be rejected, so try to find out what you could've done better to turn it into a winning project. Do you think your substantial changes might turn this into a winning submission? now that I have had the opportunity to learn more about Swift and SwiftUI over the past year Try to showcase that. I would rewrite most of my app and use my new knowledge. It sounds like you think your idea was great but you could've worked more on its implementation. If that's the case and you truly believe the idea is a good one, I would try to rewrite most of the app and add some substantial changes as you said. I'd think of it like this: how much of the app (both code and feature-wise) is new? If that's above 50%, it should be acceptable, and if it's above 75% then I would consider it "A new playground with some features from my older submission". Again, I am not a judge, and I haven't tried submitting the same idea twice. It totally depends on your submission.
Feb ’24
Reply to HELP!
Hi! I am not entirely sure what you were trying to do with the var Player = (characterName: ... part, but I assumed you wanted to create a new object of your struct. You should do this after you declare your struct. I've fixed a few things and this is a working code: var firstName = "Bella" var lastName = "Achi" let fullName = firstName + " " + lastName print(fullName) struct Player { var characterName: String var strength: Int var intelligence: Int var wisdom: Int var dexterity: Int var constitution: Int // I fixed a typo here var charisma: Int var itemsCharacterHas: String var characterCatchPhrase: String var currentHP: Int var maximumHP: Int func printCurrentHP() { print(currentHP) } func printCharacterCatchPhrase() { print(characterCatchPhrase) } mutating func majorDamage() { currentHP = -25 } mutating func healthPack() { currentHP = +15 let currentHP = 138 if self.currentHP == maximumHP{ self.currentHP = 145 } } mutating func healthRestore() { currentHP == maximumHP let currentHP = currentHP if currentHP < 0{ print("Player died")} } } // creating a new var of type Player var player = Player(characterName: "Rumble McSkirmish", strength: 18, intelligence: 5, wisdom: 3, dexterity: 15, constitution: 18, charisma: 10, itemsCharacterHas: "Red headband", characterCatchPhrase: "Fireball! Upper cut! Downer cut! Bowl of punch!", currentHP: 138, maximumHP: 145) player.printCharacterCatchPhrase()
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’24
Reply to SwiftUI Sheet race condition
Indeed, that seems to be a fix for the nil case. But consider the following example: struct ContentView: View { @State var myVar: Int = 0 @State private var presentSheet: Bool = false var body: some View { VStack { Button { myVar = 0 } 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 == 0 { Text("The value is nil") .onAppear { print(myVar) // prints 1 } } else { Text("The value is not nil") } }) } } This seems to fail as well, kind of... At least if the first / only button I click is the "open sheet" one. Once I click the "Set value to nil." button as well it starts working properly. It seems to me this might be some sort of race condition in which the sheet's View is "constructed" and presented to the user before / while (starts before and continues while) myVar becomes 1 without triggering another view refresh due to myVar's update in this process.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to hdiutil failure (bug?)
Well, I'm not sure... It could be expected behaviour, since it thinks the folder is normally accessible to the user (has at least sudo read permissions when you check with ls or stat) but MAC/TCC prevents it from reading. The man description is "skip files that can't be read by the copying user and don't authenticate". The user could read them, but the app doesn't have the necessary permissions. I'm curious about what others think as well. I'm not sure you will find a Siri-specific setting, but you could try giving Full Disk Access to Terminal just for this command (I do not recommend keeping "Full Disk Access" on for Terminal though as all commands you will run will be able to bypass all MAC restrictions! Do this only for testing your hdiutil command once). Giving Terminal FDA rights will most likely work, but giving FDA rights to an app / Terminal isn't recommended. If running the command with this doesn't work, you might be encountering a Data Vault, but that's unlikely.
Topic: Media Technologies SubTopic: General Tags:
Feb ’24
Reply to hdiutil failure (bug?)
There are some files (for example, in ~/Library there are some folders such as Calendars) for which a local user, even sudo, needs additional TCC permissions (the mechanism behind the "Do you want to allow app ... to acces your Calendar / Camera etc." type of alerts). Perhaps the -skipunreadable doesn't detect locations not accessible due to missing TCC permissions? (I need to check this). It must be noted that TCC permissions are tied to apps. In order to be able to access, let's say, the Calendar folder from Terminal, you must give Calendar access rights to the Terminal app in System Settings.
Topic: Media Technologies SubTopic: General Tags:
Feb ’24
Reply to What's the difference
Edit: I started writing this some time ago and haven't seen Eskimo's reply, which is very straightforward and easy to understand :). Mine emphasizes the same points. What is the difference between swift playground and Xcode playground? First of all, for the challenge, you need to create a Swift Playgrounds App (.swiftpm) also known as "App Playground", and you can make it either in Swift Playgrounds or Xcode. Here is a thread that can help you choose the right thing in Playgrounds / Xcode. Xcode playgrounds (File > New > Playground) are Swift testing environments in which you can write code rapidly, seeing results instantly (kind of like a REPL; you can't really build apps with them but they're great for prototyping). However, for the Swift Student Challenge, you need to make an App Playground, not an Xcode Playground / Swift Playground Book, as explained in the thread I previously mentioned. Also, is it possible to develop vision OS in the playground? I don't think you can make visionOS apps in App Playgrounds today (in either Xcode or Swift Playgrounds), but iPad apps can usually be easily converted to functional visionOS Apps, so you could run these with minimal changes once you "port" your app into an Xcode project. This would be outside the scope of the challenge (but still a fun learning exercise!). If you're wondering about the differences between Swift Playgrounds and Xcode There are a number of differences between Xcode and Swift Playgrounds (the apps you will use to code your app). Xcode is usually more advanced, having more features and being widely-used by professional developers. Swift Playgounds, however, is designed for new learners, but App Playgrounds are really powerful, allowing you to create and publish apps for iPhone, iPad and Mac (with Mac Catalyst) directly from an iPad! From my experience both work quite well, and Swift Playgrounds doesn't really miss out on much when developing App Playgrounds! It has a simple, elegant interface and works well, so if you're starting your learning journey this could be the best choice (though I guess you could start with Xcode as well). In Xcode you can choose multiple run targets (iPad simulator, iPhone simulator, Mac app etc.), but Playgrounds take care of that for you and you don't have to install additional simulators. Also, I believe Swift Playgrounds is a much lighter app (takes less space and less time to install). Xcode, however, takes up a bit more space, and you'll need to install simulators as well. If you already used Xcode / have some programming experience you could go ahead and use it, as this will help you familiarize yourself with it, and you can also start directly with Xcode, but Swift Playgrounds will essentially do the same job in most cases. Ultimately it's your preference. The App Playground you make will usually work on both Xcode and Swift Playgrounds (I think last year I couldn't run my app built with Xcode due to some differences in how Playgrounds handled ML resources, but this doesn't happen often) on macOS. When switching from iPad to Mac and vice versa you might encounter some platform differences - such as stuff that isn't supported in Catalyst.
Feb ’24
Reply to SwiftData confusing crash
Edit: this is basically an explanation of @zikomiko's solution Hi! I'm also starting out with SwiftData, but I believe these crashes usually happen when you create significant changes to your app's models. When you reinstall the app the database is deleted, which makes the new one fully compatible with your newest changes in your model. Do you usually encounter these crashes after modifying your app's models? If yes, these crashes might be caused due to storing old data that is not compatible with your newer version of your model. Other issues I've encountered were due to using certain types (like SwiftUI Image - it's best to store images as Data with @Attribute(.externalStorage)), but these usually result in build issues.
Feb ’24
Reply to Is This How You "Get Ready" for the Swift Student Challenge?
Make sure to check all these details (for all 3 questions) in the official terms and conditions on February 5th! Don't rely solely on the information I provided here. Do the students have a specific topic for the app they are going to make? (If so, will it be given on February 5, 2024?) I don't think so, at least that was not the case during the last years. I believe you are supposed to make an app on a topic of your choice. Be creative. The students are expected to submit their apps within three weeks from February 5, 2024, am I correct? That's what I understood from the website as well. The apps the students are creating are expected to be "iPhone" Swift Playground apps, am I correct? You need to create a Swift Playgrounds app (.swiftpm) also known as "App Playground", and you can make it either in Swift Playgrounds or Xcode. Here is a thread that can help you choose the right thing in Playgrounds / Xcode. I am not sure what you mean by "iPhone" - yes, in Xcode, they appear as "iOS" apps, if this is what you're saying. But they can also run on iPad and Mac via Catalyst. I am not sure and what run destination will be chosen in Xcode (iPhone / iPad simulator, Mac (Designed for iPad) etc.), but I would wait for the terms & conditions to be published if this is a concern. Good luck!
Feb ’24
Reply to Preview Autogenerated Code Error
@Mikachupichu I think that's it, yes. @State variables are supposed to be defined in Views. You could create a constant binding for your preview like this: #Preview { let randomWord1 = FetchWord.getRandomWord() let randomWord2 = FetchWord.getRandomWord() let randomWords = [Word(word: randomWord1.0, IPA: randomWord1.1, lineNumber: randomWord1.2), Word(word: randomWord2.0, IPA: randomWord2.1, lineNumber: randomWord2.2)] return HistoryView(words: .constant(randomWords)) } You won't be able to edit the randomWords from HistoryView in Previews, but it should be suitable for previewing your view in SwiftUI Previews. Otherwise, if you really need to edit the value from within Previews, you could create a wrapper View like this: #Preview("HistoryView Preview with Wrapper") { // I like giving names to custom previews in order to make them easy to find in Xcode :) struct WrapperView: View { let randomWord1 = FetchWord.getRandomWord() let randomWord2 = FetchWord.getRandomWord() @State let randomWords = [Word(word: randomWord1.0, IPA: randomWord1.1, lineNumber: randomWord1.2), Word(word: randomWord2.0, IPA: randomWord2.1, lineNumber: randomWord2.2)] var body: some View { HistoryView(words: $randomWords) } } return WrapperView() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to Swift Student Challenge Vision
I believe the issue could be that the App is unable to find your ML model. Check out this response to another thread and this one as well. You need to make some changes in how the App Playground handles resources. You will also need your own Swift model class file, since in App Playgrounds these are not automatically generated. You can copy the one generated by your Xcode project.
Jan ’24