Post

Replies

Boosts

Views

Activity

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
Reply to Issue with founding any File.swift in the scope after update to Xcode 14.3.1
If the project built with no errors previously, clean the build folder and try building again. Choose Product > Clean Build Folder in Xcode to clean the build folder. If you still get a build error, show the code for Controller. What is Controller? What is the following code supposed to do? .onAppear { Controller() } When showing code, paste it as text and put it in a code block. The code block button is the fourth button from the left in the group of formatting buttons at the bottom of the post editor. You can also use Markdown syntax for a code block by putting three backticks on the line above and below the code in the block. https://www.markdownguide.org/extended-syntax/#fenced-code-blocks Code is easier to read in a text block than in a screenshot. Plus, people can copy and paste the text from a code block.
Jun ’23
Reply to Error setting up git hub
Are you trying to put your Xcode project on GitHub? Or do you have an existing project on GitHub that you want to import in Xcode? To put your Xcode project on GitHub, open the source control navigator in Xcode by pressing Cmd-2 and create a remote branch. To work on a GitHub project in Xcode, clone the project by choosing Source Control > Clone in Xcode. Is there an article on how to setup github with xcode? The following article may help: https://www.swiftdevjournal.com/putting-your-xcode-project-on-github-bitbucket-or-gitlab/
Jun ’23
Reply to Apple Mac install XCODE getting error when trying to install update - won't run without it
What version of Xcode is installed on your Mac? Gone to open, wants to install update. But errors when tries so can no longer use. What specifically happens when you try to launch Xcode and it asks to install and update? List each step you take and be specific. The people on this forum aren't sitting next to you in front of your Mac. They can't read your mind. They can only go by what you write here. And you didn't write enough for people to help you.
Jun ’23
Reply to Crash: Thread 2: "-[NSTaggedPointerString count]: unrecognized selector sent to instance 0xaa672ff3b4678003"
There is nothing obvious in your code that causes the crash, making this a tough error to fix. Start by adding an exception breakpoint to your project. When your app crashes Xcode will pause and show you the line of code where the crash. You can also set a breakpoint at the start of the updateLocalizedTexts function, which is the function that gets called when the app finishes launching. Then you can step through the code line by line to figure out what is causing the crash. The following article should help if you have never used Xcode's debugger before: https://www.swiftdevjournal.com/an-introduction-to-xcodes-debugger/
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’23
Reply to Xcode bug
Your app most likely has crashed. To see where the app is crashing, create an exception breakpoint in Xcode by choosing Debug > Breakpoints > Create Exception Breakpoint. If the app crashes Xcode will pause the app where the crash occurs. The following article may help: https://www.swiftdevjournal.com/fixing-and-avoiding-crashes-in-swift-code/
May ’23
Reply to Bug in SwiftUI List view
I can reproduce the behavior. The following Stack Overflow question has a workaround: https://stackoverflow.com/questions/56561064/swiftui-multiple-buttons-in-a-list-row You can file a bug report with Apple on this by choosing Help > Report an Issue in Xcode.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23