Post

Replies

Boosts

Views

Activity

Reply to NSUnknownKeyException when connecting property IB
Is there a reason you are using a xib file and an IBOutlet to show a single label? It would be easier to create the label in code inside the makeUIView function. If you have a more complex view that requires a xib file or storyboard, use UIViewControllerRepresentable to create a view controller instead of using UIViewRepresentable for a single UI view.
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’23
Reply to How do I edit default C++ file templates for Xcode?
Apple's C++ templates are at the following path: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source You should create a custom file template instead of editing the templates in the Xcode app bundle. Copy the C++ file template from Xcode to the path for custom templates. ~/Library/Developer/Xcode/Templates/File Templates You'll probably want to create another folder to hold your custom templates. The following article shows you how to create a custom file template for Xcode: http://www.popcornomnom.com/create-custom-xcode-file-template-for-ios-and-macos-swift-5/ If that article is too complicated, do a search for creating custom Xcode file templates in a search engine. That will give you multiple articles on creating file templates.
Topic: App & System Services SubTopic: Core OS Tags:
May ’23
Reply to NavigationSplitView & CoreData Generating an error when adding first entity
Show the code where you add the entity. If you want to see whether the issue is with the split view, create a list that just shows the items and add a way to add new items. If you still have problems, you know the split view isn't causing the problems. Also see the following Stack Overflow question: https://stackoverflow.com/questions/73028881/swiftui-list-crashes-when-adding-items-on-macos
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to SwiftUI
The usual cause of the "Closure containing a declaration cannot be used with result builder ViewBuilde" error is doing something besides showing views inside the body of a SwiftUI view. If you do something like declare a function or make a network call inside the body of a SwiftUI view, you will get this error. If you want a fix for the error, show the code for the SwiftUI view where you get this error. Without that code, no one can tell you the mistake you made that caused the error or tell you what you need to do to fix the error.
Topic: Programming Languages SubTopic: Swift Tags:
May ’23
Reply to ld: symbol(s) not found for architecture x86_64
Please list the steps in detail on what you did to create the code and compile it. The information you provided isn't enough for people to answer your question. Providing more details on what you did to create the code and compile it will give people here a chance to give you a helpful answer. You tagged your question as Xcode, but your screenshot looks like Visual Studio Code. Did you create a project in Xcode or create a C++ file in Visual Studio Code? Does you MacBook have an Intel processor or an Apple Silicon (M1 or M2 chip)? The linker error says it can't find a main function for the Intel architecture.
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
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 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 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 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 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 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 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 NSUnknownKeyException when connecting property IB
Is there a reason you are using a xib file and an IBOutlet to show a single label? It would be easier to create the label in code inside the makeUIView function. If you have a more complex view that requires a xib file or storyboard, use UIViewControllerRepresentable to create a view controller instead of using UIViewRepresentable for a single UI view.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to How do I edit default C++ file templates for Xcode?
Apple's C++ templates are at the following path: /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source You should create a custom file template instead of editing the templates in the Xcode app bundle. Copy the C++ file template from Xcode to the path for custom templates. ~/Library/Developer/Xcode/Templates/File Templates You'll probably want to create another folder to hold your custom templates. The following article shows you how to create a custom file template for Xcode: http://www.popcornomnom.com/create-custom-xcode-file-template-for-ios-and-macos-swift-5/ If that article is too complicated, do a search for creating custom Xcode file templates in a search engine. That will give you multiple articles on creating file templates.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to NavigationSplitView & CoreData Generating an error when adding first entity
Show the code where you add the entity. If you want to see whether the issue is with the split view, create a list that just shows the items and add a way to add new items. If you still have problems, you know the split view isn't causing the problems. Also see the following Stack Overflow question: https://stackoverflow.com/questions/73028881/swiftui-list-crashes-when-adding-items-on-macos
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to SwiftUI
The usual cause of the "Closure containing a declaration cannot be used with result builder ViewBuilde" error is doing something besides showing views inside the body of a SwiftUI view. If you do something like declare a function or make a network call inside the body of a SwiftUI view, you will get this error. If you want a fix for the error, show the code for the SwiftUI view where you get this error. Without that code, no one can tell you the mistake you made that caused the error or tell you what you need to do to fix the error.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’23
Reply to ld: symbol(s) not found for architecture x86_64
Please list the steps in detail on what you did to create the code and compile it. The information you provided isn't enough for people to answer your question. Providing more details on what you did to create the code and compile it will give people here a chance to give you a helpful answer. You tagged your question as Xcode, but your screenshot looks like Visual Studio Code. Did you create a project in Xcode or create a C++ file in Visual Studio Code? Does you MacBook have an Intel processor or an Apple Silicon (M1 or M2 chip)? The linker error says it can't find a main function for the Intel architecture.
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
May ’23
Reply to XCode multiple versions on one host. How?
Yes, you can install multiple versions of Xcode. You can switch between different versions by opening a particular version, like any other Mac app. The Xcodes app simplifies installing multiple versions of Xcode and switching between them. https://github.com/XcodesOrg/XcodesApp
Replies
Boosts
Views
Activity
May ’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/
Replies
Boosts
Views
Activity
May ’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:
Replies
Boosts
Views
Activity
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.
Replies
Boosts
Views
Activity
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/
Replies
Boosts
Views
Activity
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.
Replies
Boosts
Views
Activity
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
Replies
Boosts
Views
Activity
Jun ’23
Reply to Can @AppStorage be used on Storyboard objects?
@AppStorage is part of SwiftUI so you can't use it if you are using UIKit and storyboards for your user interface. The UserDefaults class is the UIKit equivalent of @AppStorage.
Replies
Boosts
Views
Activity
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.
Replies
Boosts
Views
Activity
Jun ’23