Post

Replies

Boosts

Views

Activity

Reply to Use multiple @Observable inside each other using @Enviroment
I have not used the new @Observable stuff yet, but I am pretty sure that @Environment is used in SwiftUI views, not in view models. What happens if you add the categories view model as a regular property of the NotesViewModel class without any property wrappers? @Observable class NotesViewModel { var notes: [Note] = [] var categoriesViewModel: CategoriesViewModel func foo(){ /// Thread 1: Fatal error: No Observable object of type CategoriesViewModel found. A View.environmentObject(_:) for CategoriesViewModel may be missing as an ancestor of this view. print(categoriesViewModel.categories.count) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to Unexpected crashes on Xcode 14.3 (SIGTRAP)
What is crashing: Xcode or your project? If Xcode is crashing, start by narrowing down the problem. Can you create new projects? Can you open other projects? If you can create new projects and open other projects, you know the problem is with the one project. If your project is crashing when you run it, create an exception breakpoint by choosing Debug > Breakpoints > Create Exception Breakpoint in Xcode. When your app crashes, the exception breakpoint will show you where in your code the app crashes. You will have to post your code for anyone to provide additional help to solve the crashing problem.
Aug ’23
Reply to "This NSPersistentStoreCoordinator has no persistent stores", despite setting up all capabilities
I get the error "This NSPersistentStoreCoordinator has no persistent stores (unknown). It cannot perform a save operation." What does this error exactly mean? The error message says the persistent store coordinator has no persistent stores. Core Data saves data to a persistent store. If there are no persistent stores, Core Data cannot save your app's data. My container is initialised so it should have a persistent store, right? Are you sure the container was initialized correctly? let container = NSPersistentCloudKitContainer(name: "TaskDataModel") Do you have a CloudKit container named TaskDataModel? Set a breakpoint at the start of the init function in DataController. Does the container property have the value you expect? Step through the code line by line. Does the call to loadPersistentStores run correctly or does it generate an error?
Aug ’23
Reply to new classes .h .cpp Xcode, translate from Visual Studio
What is the tutorial you are following? I have not used openFrameworks, but your Visual Studio example has a C++ file, the .cpp file, and your Xcode file has an Objective-C file, the .m file. You either need a C++ file or an Objective-C++ file (extension .mm) to get the code to work, as I doubt openFrameworks supports Objective-C. Have you gone through the openFrameworks Xcode setup tutorial? https://openframeworks.cc/setup/xcode/ You will have a better chance of getting an answer at the openFrameworks forums since I doubt very few people here use openFrameworks. I never heard of it until I read your question. https://forum.openframeworks.cc
Topic: Business & Education SubTopic: General Tags:
Aug ’23
Reply to IOS Version Incompatible with Xcode version, Looking for official Solution.
Xcode does not support devices running a newer version of iOS than the SDK version that comes with the particular version of Xcode. Xcode 14.2 comes with the iOS SDK 16.2. You won't be able to run your project on a device running anything newer than 16.2. If you can't update Xcode, you will have to download the iOS 16.6 support files and copy them to your Xcode bundle. More details are in the following article: https://www.swiftdevjournal.com/dealing-with-failed-to-prepare-device-for-development-error-message-in-xcode/ I also recommend turning off automatic updates on your iOS device. Every time your device updates, Xcode will stop working, and you will have to repeat the cycle of installing support files.
Aug ’23
Reply to CoreData / SwiftUI List selection question
The sample code is able to pass an optional managed object type Trip? to hold the selection rather than the ID type. When I try to replicate that behavior, I can't. Show the code you tried that didn't work. What is the problem you have with the code you tried? Do you get a build error? If so, what is the error? Do you get unexpected selection behavior? If so, state what you expect to see and what you see with the code you changed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’23
Reply to A stored property cannot be named 'description'
You can't name a Core Data attribute description because it conflicts with a method in the NSObject class. Currently SwiftData uses Core Data under the hood so the limitation also applies in SwiftData. See the following Stack Overflow question for more details: https://stackoverflow.com/questions/4717519/why-cant-i-use-description-as-an-attribute-name-for-a-core-data-entity Name your attribute something other than description.
Sep ’23
Reply to Multiplatform development questions
Answers to the specific questions. If you use SwiftUI, you might be able to have just one version of the code with a multiplatform app target. But there is a good chance you will need to build separate iOS and Mac user interface code in some places to provide the best experience on both platforms. SwiftData works on Mac, but it requires macOS 14, which is not out yet. I have not used RevenueCat, but you have to ask yourself if you want people who buy a subscription to get both versions with the subscription. If so, you can have one subscription that works on both platforms. If not, you need separate subscriptions. Renaming, moving, and deleting list items has a lot of differences. If your app does those things, you will need to create separate list code for iOS and Mac. Stick with one Xcode project. Either use the multiplatform app target or create separate targets for iOS and Mac. The following article has more information about multiplatform app targets: https://www.swiftdevjournal.com/xcode-multiplatform-app-targets/
Sep ’23
Reply to Getting Xcode to create an app bundle
I have not developed an iOS app in C++ so I can't give you a specific solution. I know that you need an App target to build an app bundle. When adding the App target in Xcode, choose Objective-C from the Language menu instead of Swift. Objective-C works better with C++ than Swift does. You have to add the C++ files to the App target to get them to build. Open Xcode's file inspector by choosing View > Inspectors > File. The file inspector has a Target Membership section. Make sure the checkbox is selected for the App target. One other thing you might have to do is change the extension of the Objective-C files to .mm to make them Objective-C++ files.
Sep ’23
Reply to List not updated after adding a new item
You have posted a lot of code, but there is one important piece of code missing. Your HistoryView has the following property that contains the history data: @StateObject var historyData1 = historyData() Your InvoiceView has the following property: @ObservedObject var historyData: historyData But I do not see any code on how you set the InvoiceView's historyData value. Is the value of historyData supposed to be the same as HistoryView's historyData1 property? I think you have a better chance of getting an answer if you post a new question and strip out most of the code. The problem you have is the list isn't updating when you add a new item to it. Show the code that deals with adding the items to the list and strip out the other stuff. You have posted so much code that has nothing to do with the problem, and that makes it hard for people reading the question to see the code they need to answer your question. I also recommend coming up with better names for some of your data structures and variables. You have a struct named HistoryData and a class named historyData. That is confusing because the only difference in the names is making the H in History uppercase or lowercase. You have a variable named historyData and another one named historyData1. I know it can be hard to come up with good variable names, but your code will be easier for people to read if you give your data structures and variables less confusing names.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’23
Reply to Use multiple @Observable inside each other using @Enviroment
I have not used the new @Observable stuff yet, but I am pretty sure that @Environment is used in SwiftUI views, not in view models. What happens if you add the categories view model as a regular property of the NotesViewModel class without any property wrappers? @Observable class NotesViewModel { var notes: [Note] = [] var categoriesViewModel: CategoriesViewModel func foo(){ /// Thread 1: Fatal error: No Observable object of type CategoriesViewModel found. A View.environmentObject(_:) for CategoriesViewModel may be missing as an ancestor of this view. print(categoriesViewModel.categories.count) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Unexpected crashes on Xcode 14.3 (SIGTRAP)
What is crashing: Xcode or your project? If Xcode is crashing, start by narrowing down the problem. Can you create new projects? Can you open other projects? If you can create new projects and open other projects, you know the problem is with the one project. If your project is crashing when you run it, create an exception breakpoint by choosing Debug > Breakpoints > Create Exception Breakpoint in Xcode. When your app crashes, the exception breakpoint will show you where in your code the app crashes. You will have to post your code for anyone to provide additional help to solve the crashing problem.
Replies
Boosts
Views
Activity
Aug ’23
Reply to Unexpected crashes on Xcode 14.3 (SIGTRAP)
The answers to the following Stack Overflow question may help you solve your problem with Xcode crashing when opening a specific project: https://stackoverflow.com/questions/4455903/xcode-crashing-when-opening-project-file
Replies
Boosts
Views
Activity
Aug ’23
Reply to "This NSPersistentStoreCoordinator has no persistent stores", despite setting up all capabilities
I get the error "This NSPersistentStoreCoordinator has no persistent stores (unknown). It cannot perform a save operation." What does this error exactly mean? The error message says the persistent store coordinator has no persistent stores. Core Data saves data to a persistent store. If there are no persistent stores, Core Data cannot save your app's data. My container is initialised so it should have a persistent store, right? Are you sure the container was initialized correctly? let container = NSPersistentCloudKitContainer(name: "TaskDataModel") Do you have a CloudKit container named TaskDataModel? Set a breakpoint at the start of the init function in DataController. Does the container property have the value you expect? Step through the code line by line. Does the call to loadPersistentStores run correctly or does it generate an error?
Replies
Boosts
Views
Activity
Aug ’23
Reply to new classes .h .cpp Xcode, translate from Visual Studio
What is the tutorial you are following? I have not used openFrameworks, but your Visual Studio example has a C++ file, the .cpp file, and your Xcode file has an Objective-C file, the .m file. You either need a C++ file or an Objective-C++ file (extension .mm) to get the code to work, as I doubt openFrameworks supports Objective-C. Have you gone through the openFrameworks Xcode setup tutorial? https://openframeworks.cc/setup/xcode/ You will have a better chance of getting an answer at the openFrameworks forums since I doubt very few people here use openFrameworks. I never heard of it until I read your question. https://forum.openframeworks.cc
Topic: Business & Education SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to IOS Version Incompatible with Xcode version, Looking for official Solution.
Xcode does not support devices running a newer version of iOS than the SDK version that comes with the particular version of Xcode. Xcode 14.2 comes with the iOS SDK 16.2. You won't be able to run your project on a device running anything newer than 16.2. If you can't update Xcode, you will have to download the iOS 16.6 support files and copy them to your Xcode bundle. More details are in the following article: https://www.swiftdevjournal.com/dealing-with-failed-to-prepare-device-for-development-error-message-in-xcode/ I also recommend turning off automatic updates on your iOS device. Every time your device updates, Xcode will stop working, and you will have to repeat the cycle of installing support files.
Replies
Boosts
Views
Activity
Aug ’23
Reply to CoreData / SwiftUI List selection question
The sample code is able to pass an optional managed object type Trip? to hold the selection rather than the ID type. When I try to replicate that behavior, I can't. Show the code you tried that didn't work. What is the problem you have with the code you tried? Do you get a build error? If so, what is the error? Do you get unexpected selection behavior? If so, state what you expect to see and what you see with the code you changed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to A stored property cannot be named 'description'
You can't name a Core Data attribute description because it conflicts with a method in the NSObject class. Currently SwiftData uses Core Data under the hood so the limitation also applies in SwiftData. See the following Stack Overflow question for more details: https://stackoverflow.com/questions/4717519/why-cant-i-use-description-as-an-attribute-name-for-a-core-data-entity Name your attribute something other than description.
Replies
Boosts
Views
Activity
Sep ’23
Reply to Multiplatform development questions
Answers to the specific questions. If you use SwiftUI, you might be able to have just one version of the code with a multiplatform app target. But there is a good chance you will need to build separate iOS and Mac user interface code in some places to provide the best experience on both platforms. SwiftData works on Mac, but it requires macOS 14, which is not out yet. I have not used RevenueCat, but you have to ask yourself if you want people who buy a subscription to get both versions with the subscription. If so, you can have one subscription that works on both platforms. If not, you need separate subscriptions. Renaming, moving, and deleting list items has a lot of differences. If your app does those things, you will need to create separate list code for iOS and Mac. Stick with one Xcode project. Either use the multiplatform app target or create separate targets for iOS and Mac. The following article has more information about multiplatform app targets: https://www.swiftdevjournal.com/xcode-multiplatform-app-targets/
Replies
Boosts
Views
Activity
Sep ’23
Reply to Getting Xcode to create an app bundle
You need to add an App target to the project to build an app bundle. Choose File > New > Target in Xcode to create the App target.
Replies
Boosts
Views
Activity
Sep ’23
Reply to Getting Xcode to create an app bundle
I have not developed an iOS app in C++ so I can't give you a specific solution. I know that you need an App target to build an app bundle. When adding the App target in Xcode, choose Objective-C from the Language menu instead of Swift. Objective-C works better with C++ than Swift does. You have to add the C++ files to the App target to get them to build. Open Xcode's file inspector by choosing View > Inspectors > File. The file inspector has a Target Membership section. Make sure the checkbox is selected for the App target. One other thing you might have to do is change the extension of the Objective-C files to .mm to make them Objective-C++ files.
Replies
Boosts
Views
Activity
Sep ’23
Reply to Xcode 15 breakpoints not stopping on symbolicated code
I have not used Xcode 15 yet, but most of the debugging settings are in the Debug menu. Any fixes for your issue would be there. I noticed there's a menu item Debug > Debug Workflow > Always Show Disassembly. Is that setting active in your Xcode version?
Replies
Boosts
Views
Activity
Sep ’23
Reply to List not updated after adding a new item
Show the code for the view where you add the new item and the code that adds the new item. Without that code people can only guess as to why the list is not updating when you add a new item.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to List not updated after adding a new item
You have posted a lot of code, but there is one important piece of code missing. Your HistoryView has the following property that contains the history data: @StateObject var historyData1 = historyData() Your InvoiceView has the following property: @ObservedObject var historyData: historyData But I do not see any code on how you set the InvoiceView's historyData value. Is the value of historyData supposed to be the same as HistoryView's historyData1 property? I think you have a better chance of getting an answer if you post a new question and strip out most of the code. The problem you have is the list isn't updating when you add a new item to it. Show the code that deals with adding the items to the list and strip out the other stuff. You have posted so much code that has nothing to do with the problem, and that makes it hard for people reading the question to see the code they need to answer your question. I also recommend coming up with better names for some of your data structures and variables. You have a struct named HistoryData and a class named historyData. That is confusing because the only difference in the names is making the H in History uppercase or lowercase. You have a variable named historyData and another one named historyData1. I know it can be hard to come up with good variable names, but your code will be easier for people to read if you give your data structures and variables less confusing names.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to XCode 14.2: Can't edit target properties in a project
The Value column may be hidden because the Key column is so wide. Can you see the Value column if you drag the splitter (the thin line next to Type in your screenshot) to the left? You should be able to change the values from the Value column.
Replies
Boosts
Views
Activity
Sep ’23