@NSApps Did you try Product > Clean Build Folder? Sometimes File > Packages > Reset Package Caches could also work when using packages in your app but I don't think it makes a difference here (since the package is the app).
Did you set a team in the Signing and Capabilities editor? Maybe try to select it again.
Post
Replies
Boosts
Views
Activity
I am testing on a physical playground on my iPad :) Do you know how to fix it?
Could you describe the error you are encountering so that we can help? Does the app throw a specific error / show a warning in Console?
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()
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.
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.
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.
@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()
}
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.
Thanks again for your response! I submitted FB13566397.
It seems that your code doesn't use any Vision Framework features, at least not yet. Removing the Vision import doesn't change anything to your current code. Perhaps you want to add some Vision-related features later?
I tried to run your code, and I only had to make some small changes in your ImagePicker since PresentationMode was deprecated:
struct ImagePicker: UIViewControllerRepresentable {
@Environment(\.dismiss) private var dismiss
@Binding var image: UIImage?
func makeUIViewController(context: Context) -> UIImagePickerController {
let picker = UIImagePickerController()
picker.delegate = context.coordinator
return picker
}
func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) {}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
var parent: ImagePicker
init(_ parent: ImagePicker) {
self.parent = parent
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
if let uiImage = info[.originalImage] as? UIImage {
parent.image = uiImage
}
parent.dismiss()
}
}
}
Everything seemed to work as expected after that. I was able to pick an image and it was displayed in the ContentView.
Also, if you want a SwiftUI Photo Picker implementation (i.e. doesn't rely on UIKit / UIViewControllerRepresentable), you can find out how to do it in this WWDC22 Session video and sample code. But your ImagePicker seems to work fine too.
I believe you are only allowed to submit App Playgrounds (.swiftpm) files as it is described on the eligibility page. That was the case for last year's challenge as well. Make sure you submit an App Playground, not an Xcode Playground. Here is a thread that explains how to properly choose the right thing in Xcode or Swift Playgrounds.
I assume you're referring to the Vision Framework, not visionOS. I would try to find out why your app doesn't work as expected in Playgrounds, as I believe it may possible to use this framework as well, perhaps with a few small changes. What is the issue with your Vision code?
Make sure to check the full terms and conditions on February 5th.
Hi! App Playgrounds don't really have an Info.plist, but you can add capabilities such as camera access via Xcode.
Click on your project > Signing Capabilities, then click the "+ Capability" Button.
Add the capabilities you want, such as camera access, via the menu that appears. Then, at the bottom of the Signing & Capabilities page, you should have the new capability added, where you can also modify settings such as the purpose string for camera access:
Internally, Xcode adds these capabilities to a Package.swift file included with your project which replaces the Info.plist. This file is not directly accessible within Xcode (you can view it in Finder if you show the .swiftpm's contents), but you can add capabilities from Xcode as I explained above.
Last year, you had to pick from one of these options:
Swift Playgrounds on iPad
Swift Playgrounds on Mac
Xcode on Mac
I guess it will probably be similar this year, if not the same. While it didn't specify if Apple Silicon Macs will be used, I suppose that will be the case, though I believe your project may work fine on Intel-based ones too.
I'm curious why your app doesn't work well on iPad, including M1 ones. Sounds like your app uses quite a lot of processing power, but I guess it should work on M1 iPads as well. Maybe you need to make some additional changes to fully support them. But, in any case, I think you will be able to select one of the options above. What I'm curious about is what run destination will be chosen in Xcode (iPhone / iPad Simulator, Mac Catalyst app etc.) - but since I made my app fully support all platforms last year, it did not really matter for me.
If you have other any specific instructions to run your playground, last year I received this response, and it might also apply this year.
Do not rely solely on this information and be sure to check the updated terms and conditions on February 5th! A link to the terms should appear here when the challenge opens.
I just tested this by creating a new iOS Xcode project with Swift & UIKit, then copied the Swift files to a new App Playground (and deleted the old MyApp and ContentView SwiftUI files). It seems to work fine (I'm not entirely sure about storyboards though), which was expected in my opinion - as long as you have the necessary code and the @main attribute somewhere in your code, the app should compile and run. What I'm not entirely sure of is how / if storyboards are supported in Playgrounds.
However, I'd definitely recommend you to learn SwiftUI as well. It should be easy to learn using the available resources and you can also use UIKit with SwiftUI code.
Good luck!