Post

Replies

Boosts

Views

Activity

Reply to Permission to read a local file
Are you making an app for yourself or for other people to use? If you are making an app for other people and want to play an audio file, you should bundle the file with the app and load and play the file from the app bundle. Using the app bundle is better than relying on a file being in the Downloads folder. macOS has privacy preferences in the Security & Privacy section of its Settings/System Preferences app. You can give an app full disk access or give an app access to specific folders. If you are making an app for yourself, use these settings to give your app permission to access what you need on the file system. You can give a sandboxed app access to the Downloads folder from the File Access section of the App Sandbox settings in Xcode.
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’23
Reply to error: Failed with exit code exited with status 1 error in Xcode14.3.1
I tried solution mentioned in support page. But it is not working out. What specifically is the solution you tried that did not work? Xcode's issue navigator will show the build errors in your project. Press Cmd-4 in Xcode to open the issue navigator. What are the build errors the issue navigator shows? If the only build error the issue navigator shows is Error: Failed with exit code exited with status 1, clean the build folder by choosing Product > Clean Build Folder in Xcode. After cleaning the build folder, build the project again. Are you using CocoaPods in your project? Using them can cause build errors where you would need to update the pods.
Jul ’23
Reply to Why must I wrap a call to call to an async/await method in a Task?
You have to wrap calls to async functions in a Task block if the function or closure where you make the call does not support Swift's async await syntax. If you are getting build errors if you remove the Task block, it's a sign the function or closure does not support the async await syntax. See the following article for additional explanation: https://www.swiftdevjournal.com/fixing-the-async-call-in-a-function-that-doesnt-support-concurrency-error-in-swift/ SwiftUI has a .task modifier you can use to make an async call from a SwiftUI view. You may be able to use it to avoid having to wrap your button code in a Task block. See the following article for an introduction to the .task modifier: https://www.hackingwithswift.com/quick-start/concurrency/how-to-run-tasks-using-swiftuis-task-modifier
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Xcode 15 no storyboard
What type of project did you create? The multi-platform app projects use SwiftUI so there's no option to choose a storyboard for the user interface. If you create an iOS or Mac app project, there should be an Interface menu where you can choose to use a storyboard for the app's user interface.
Jul ’23
Reply to Xcode debugging breakpoints only show stack trace without corresponding line.
What appears in Xcode's editor instead of your source code? If you see a bunch of assembly language code in Xcode's editor, look for a function you wrote in the stack trace and click that function. Xcode should take you to that function in your code. If that does not help, you have to provide more details on what you are doing, such as the following: The version of Xcode you are using The type of Xcode project you created What kind of breakpoints you set: line, symbolic, or exception.
Jul ’23
Reply to FirstTimeDebugging - compile warning
The following condition: if false Will never be true so the code inside the if block print("Will this line of code ever be reached") someMethod() Will never execute. I have not read the book you are following. But it looks like the point of that code is to quiz you on whether the code in the if block will ever be reached, and not to build without any warnings. If you want to remove the warning, provide a condition that could be true or false or remove the if statement and the braces. But I think removing the warning defeats the point of the exercise.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
Reply to App Development For Newbie
Are you asking if an app you created with Xcode 13 and the iOS 15 SDK will run on iOS 16? If so, the answer is Yes, the app will run on iOS 16. You can make apps that support iOS 15 with Xcode 14. Set the deployment target, the minimum OS the app will run on, to iOS 15, and the app will run on iOS 15+ as long as you don't use anything Apple added in iOS 16. The following article provides screenshots and other details on supporting older versions of iOS: https://www.swiftdevjournal.com/supporting-older-versions-of-ios-and-macos/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Basics for App development (macOS)
I doubt you are going to find a course that teaches you how to build Mac apps with Python using Xcode. If you all you want to do is add a GUI to an existing command-line app, take a look at the Process class. This class lets a Mac app run command-line apps as subprocesses. Create a Swift app project and use Process to run the Python app. The Process class used to be named NSTask, which may provide better search results as Process is a generic name. If you are looking for resources to learn Mac app development, take a look at the following article: https://www.swiftdevjournal.com/resources-for-learning-mac-development/
Jul ’23
Reply to Can't figure out why nothing conforms to "View"
I would start by commenting out the call to EditButton() and see if that fixes the error. If that doesn't work, comment out the code to create the "hi" toolbar item. The only other thing I see that could cause a problem is the following line of code: Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") That string looks fishy. It looks like you're missing a parenthesis at the end of item.timeStamp. I would start with something like the following: Text("Item at \(item.timestamp)") And add the format argument to the item text after you get the basic text to appear in the list.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’23
Reply to Extra argument in call when adding a new line of text
A SwiftUI view is limited to 10 subviews. If you have more than 10 subviews, you will get an Extra Arguments build error. It looks like you have more than 10 Text and Image views inside your table cell view. The workaround is to place your Text and Image views in multiple groups. Group { Text("Natural Slope") Text("Paragraph 1 over here . . . . . long 300-words at least") Image("artificial") Text("Artificial Slope") Text("another paragraph in this area containing 300 words") } Group { Image("reinforced") Text("Reinforced Slope and Gabions") Text("another paragraph words words words words words") Text("Purpose") Text("this should be a single paragraph explaining the purpose of this app") } Notice how each group has fewer than 10 subviews inside them. I omitted the modifiers for the Text and Image views to keep the code block from getting too long.
Jun ’23
Reply to Issue with founding any File.swift in the scope after update to Xcode 14.3.1
The name of the class you showed is Products, not ProductManager. That is why the compiler can't find ProductManager. Does the error go away if you change the name of the class to ProductManager or if you change ProductManager to Products in the .onAppear block? You also need to create an instance of your class to call the function. .onAppear { let manager = ProductManager() manager.loadProduct() } In a real SwiftUI app you would add a property to the view. @StateObject manager = ProductManager() My examples assume you changed the name of the class from Products to ProductManager. I recommend taking a course like Hacking with Swift's 100 Days of SwiftUI to learn SwiftUI. A course like that would help you deal with problems like the one you asked about here. https://www.hackingwithswift.com/100/swiftui
Jun ’23