Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Sheet race condition
@malc Thanks! To be honest, I forgot about this thread. I had to recall this issue from a year ago :) Yeah, it makes sense now. Just to be sure that I understood this correctly - the issue is that myVar's getter is never called by the View's body, and thus body doesn't refresh on its updates (and it makes sense now why that additional Text() fixed this issue). And .sheet references external state (from the parent view) that isn’t part of the isPresented binding, so changes to myVar won’t automatically affect the sheet’s presentation unless they cause body to be re-evaluated. And, given this, another solution (yours works great as well) that works would be to create a new View used by the .sheet with its own State& Binding variables, etc. // ContentView body: .sheet(isPresented: $presentSheet) { MySheetView(myVar: $myVar) } // Additional View: struct MySheetView: View { @Binding var myVar: Int var body: some View { // ... (something that uses myVar getters) VStack { if myVar == 0 { Text("The value is nil") } else { Text("The value is 1") .onAppear { print(myVar) // prints 1 } } Text("The value is \(myVar)") } } } Now, myVar's change will invalidate MySheetView, causing it to be re-evaluated. Plus, either way, it's better to do it this way from a modularization perspective. Now, for the last part, quoting @Engineer : Since SwiftUI is declarative rather than procedural, and .onAppear performs its action asynchronously, I don’t think the value of myVar is guaranteed to match its outer context. It definitely makes sense why the .onAppear used to give a different value (and this is actually why I used it; to check myVar's actual value). Now the answer is complete; I wasn't understanding why the .sheet wasn't being refreshed in the process. Can you confirm that I understood this correctly? Thanks a lot!
1w
Reply to Regarding AR App Submission Built in Xcode - Swift Student Challenge submission
My app uses ARKit and requires Metal files for shaders, which are not supported by Swift Playgrounds. Thankfully there are solutions to make this work; check out the Apple engineer's response on your other thread. I think the form field makes it clear that the playground will be run in either Xcode (in Simulator) or Swift Playground (on a real iPad). A combination of both seems unlikely, and personally, I wouldn't take that risk. I'm in a similar spot as you, and what I decided to do is to make my app compatible with Playgrounds and get it judged on an iPad.
1w
Reply to Metal not working in Swift Playgrounds (SSC Scene)
@Graphics and Games Engineer Hi! I'm in a similar spot; I have my own small CIKernel written in Metal. In order to add it to Playgrounds I compiled it myself and added the resulted.metallib directly to the resources folder, quite simlar to what I described on this thread. Your answer got me wondering, do you think this approach is fine as well, or should I rather try to compile this at runtime? If the latter is preferred, is it possible to provide the required CLI arguments (in my case, -fcikernel and / or -cikernel)?
1w
Reply to Trouble Loading Precompiled Metal Shader (.metallib) into ShaderLibrary
I've been in the exact scenario you described, but thankfully I got mine working. In fact, I think I've done pretty much what you described already: compile the model separately(ince Playgrounds cannot compile it, similar to how CoreML models need to be compiled first) and include the metallib as a Resource. My app consistently seems to crash on the ShaderLibrary initialization, rendering the app unusable. Why does ShaderLibrary(url: shaderURL) cause a crash, even though my .metallib file is valid? Are there additional requirements for loading a ShaderLibrary that I may have missed? I don't think there's anything else you need. Here's a test SwiftUI View similar to yours, but without the Dynamic Member enum: struct ContentView: View { var library: ShaderLibrary { // note that i'm force-unwrapping some optionals here, // but maybe you can make this an Optional type instead // (i.e. SharedLibrary? and return nil on error) // if you want to be safe in case something goes wrong. let shaderPath = Bundle.main.path(forResource: "Shader", ofType: "metallib")! let shaderURL = URL(fileURLWithPath: shaderPath) let library = ShaderLibrary(url: shaderURL) return library } var body: some View { View() .colorEffect(library.myEffect()) } I've ran this successfully without any issues. My Shader.metallib was placed inside the Resources folder, and displays as a resource inside Playgrounds, and you likely did this too for the reasons described below. So we confirmed that the issue is not regarding the Metal shader itself. Now, looking back at your example, everything looks pretty normal, I'm not exactly sure what goes wrong, but here's what I would check: ShaderFunction(library: SwiftUI.ShaderLibrary(rbLibrary: <RBShaderLibrary: 0x60000000cf80>), name: "passthrough") This indeed confirms that your metallib url path is correct, and your library was loaded correctly. But there's a catch: you're using @dynamicMemberLookup here, which means you can subscript absolutely anything, including inexistent shaders. Meaning that, if there's no actual passtrough shader available, your print will be the same. You can check that yourself: if you change passthrough to an inexistent, shadeer, something random, you'll see that your print is the same. Note: this is also the case in my example above; ShaderLibrary is a @dynamicMemberLookup type itself, so it is prone to issues like this as well. TL;DR Can you check that the passthrough shader actually exists (and was compiled correctly in your metallib)?
1w
Reply to Swift Student Challenge table's two questions
One of the options asks, “Did you use open source software, other than Swift?” I think this refers to non-Apple frameworks (or, let's say, frameworks that aren't included with the SDK by default) that you used in your app. For example, a package from the Swift Package Index. I would like to provide a demo video to ensure that the reviewers can use the app properly and experience all of its features in the shortest amount of time. For certain reasons, I do not plan to play the video directly in the App Playground. Instead, I intend to include a link in the “Comments” section at the end of the form, which will redirect to a webpage (requiring an internet connection) containing the demo video. Will the reviewers be able to view the link and access the video as intended? Unfortunately, I think they won't have time for that. There are reasons why they can only experience the app within 3 minutes - there are many applicants whose submissions need to be judged. If you feel that your app is quite complicated and may be hard to understand without a video, why don't you provide an in-app tutorial insstead? I think you could also describe how it's meant to be used in the App Playground essay.
2w
Reply to Link in Swift Student Challenge
FYI, the submission form has a Socials text box, so you may want to link your website there (and they don't mention anything about it not influencing the judging process, compared to the one for App Store apps! So it may actually count for the judging process). As far as it goes for your app, I think it's pretty clear what your link does, given it's label: Label("Developer Website - .....com", systemImage: "arrow.right"). So, imo, I think it may be fine, especially if your app's design makes it clear that it's not part of the main experience, but rather something extra, external. If you're really worried about this, consider rather linking your website via the specific submission form item I mentioned above.
3w
Reply to Unable to rename the Swift Playground or add an icon when package dependencies is imported
I was able to reproduce the behavior you described, and I recommend you submit a bug via Feedback Assistant, and make sure to reply with the feedback's ID on this thread for reference. You may also link this thread on your feedback. Some details about this bug Swift Playgrounds are a superset of swiftpm (the Swift Package format), and they have a "Package.swift` settings file that you may access via clicking on "Show Package Contents" option in Finder: This file includes all your App Playground's settings and used packages. Here's how it looks on a functional app, with the same package you were using: // swift-tools-version: 5.9 // WARNING: // This file is automatically generated. // Do not edit it by hand because the contents will be replaced. import PackageDescription import AppleProductTypes let package = Package( name: "My App", platforms: [ .iOS("18.1") ], products: [ .iOSApplication( name: "My App", targets: ["AppModule"], displayVersion: "1.0", bundleVersion: "1", appIcon: .placeholder(icon: .palette), accentColor: .presetColor(.purple), supportedDeviceFamilies: [ .pad, .phone ], supportedInterfaceOrientations: [ .portrait, .landscapeRight, .landscapeLeft, .portraitUpsideDown(.when(deviceFamilies: [.pad])) ] ) ], dependencies: [ .package(url: "https://github.com/simibac/ConfettiSwiftUI", "2.0.2"..<"3.0.0") ], targets: [ .executableTarget( name: "AppModule", dependencies: [ .product(name: "ConfettiSwiftUI", package: "ConfettiSwiftUI") ], path: ".", swiftSettings: [ .enableUpcomingFeature("BareSlashRegexLiterals") ] ) ] ) And here is how it looks after renaming the project: // swift-tools-version:5.3 // WARNING: // This file is automatically generated. // Do not edit it by hand because the contents will be replaced. import PackageDescription import AppleProductTypes let package = Package( name: "My TEST App", platforms: [ .iOS("18.1"), .macOS("11.0"), .tvOS("14.0"), .watchOS("7.0") ], products: [ .library( name: "ConfettiSwiftUI", targets: ["ConfettiSwiftUI"] ) ], targets: [ .target( name: "ConfettiSwiftUI", path: "Sources" ), .testTarget( name: "ConfettiSwiftUITests", dependencies: [ "ConfettiSwiftUI" ], path: "Tests" ) ] ) Clearly, something's off. This file gets corrupted when changing the app's settings after importing a package. Workaround solution To solve this, you'll need to restore this file manually (as far as I know, there's no way to do it in Playgrounds). If you're unfamiliar with this file's format & settings, you can create a new blank Playground with the settings your project needs, then copy the Package.swift file to your old one. For more information on the warning at the top of this file, here's a relevant thread. I think it's safe to change this file manually in this case, since all you're doing is restoring things back to normal.
3w
Reply to Swift playgrounds and display orientation swift student challenge submission
[quote='773756021, DhruvG24, /thread/773756, /profile/DhruvG24'] I reckon I can develop in Xcode and then copy those files in playgrounds app, make some changes, for it to work. [/quote] You can also make an App Playground directly in Xcode by selecting File > New > Project > iOS > App Playground. also I made my project in landscape mode in Xcode, in playgrounds can I lock display orientation through package.swift file or I should continue making me app in landscape mode and ask players to change their viewing orientation via a popup? I think this thread may be helpful.
3w
Reply to Winner's visa issue
I can't talk from experience here, and I obviously cannot give you an official response, but you're likely not the first person from China, neither the first one who needs to apply for a visa, if this helps! :) I'm pretty sure I saw a video with last years' distinguished winners, and I'm quite sure there was a student from China as well. If you don't receive a response here, maybe you can contact the Swift Student Challenge team at swifstudentchallenge@apple.com (from their T&C).
3w
Reply to Essay
A good indicator is the word count limit. If you take a look at the Swift Student Challenge submission form, you'll see that there's two non-optional text boxes that have: a limit of 500 words for describing your App Playground (seems to have increased from last year! hooray! 🎉), and a limit of 200 words for describing how you used your coding skills "Beyond the Swift Student Challenge". I believe these are the main essays, based on the word limit and the prompt itself. At least, these are the questions for which I responded in the form of an essay during my previous years' submissions. Other text prompts, essays There is a prompt asking you to describe your app in one sentence, in a concise manner. You definitely don't want to write an essay for this one. Depending on whether you used open source software, other than Swift, or content that you don't have ownership rights to, you will have two 200-word boxes to explain your use. I assume you’re not supposed to write an essay for these; likely the limit is set this high to allow enough space. There is also an App Store (optional) entry which is not mandatory and doesn't influence the judjing process. I think you can write an essay here as well, if you've published apps to the App Store before. Also, there is a Social Media (optional) entry. Based on its' description, I assume you don't have to write an essay about your socials, but I believe it rather has the 200-word limit so that you're able to link everything you want. Maybe you can provide a short description for each? Some closing remarks Finally, I don't think you're required to write an essay close to the word limit, but personally, I always tended to write more than 300 words (which I believe used to be the limit for the App Playground essay), and had to shrink it down. Write as much as you think it's needed to describe your app and yourself. If anyone else has any tips on the essays, I'd also be willing to hear them! :) Note: I am not a judge. I am a previous years' participant, also planning to also submit an app this year. I am writing from my experience, but take this with a grain of salt! Use your own judgement and, don't forget, be yourself! Good luck!
3w