Post

Replies

Boosts

Views

Activity

Reply to Combining SwiftUI & SpriteKit
I have not tried loading a SpriteKit scene from a .sks file to a SwiftUI sprite view so I don't have a specific solution for you. I have some tips and suggestions that may help you solve the problem yourself or give other people here enough information to help you. It works with some changes Show the code you use to declare the property for the scene in the SwiftUI view. I still can't interact with the MapScene Provide more details. What are you trying to do? What do you expect to happen? What happens? Set a breakpoint in your touchesBegan or mouseDown functions. If you run your project and tap or click in the scene, does the breakpoint fire? If you have not used Xcode's debugger before, read the following article: https://www.swiftdevjournal.com/an-introduction-to-xcodes-debugger/ I doubt you are the first person to have trouble loading a SpriteKit scene into a SwiftUI view. Search on Stack Overflow or a search engine, and chances are high someone has had the same problem and received a solution.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Reply to Documentation for MACOSX_DEPLOYMENT_TARGET?
I found a mention of MACOSX_DEPLOYMENT_TARGET in Xcode's Build Setting Reference. https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW129 I created a new Mac app project in Xcode 14.2, and the project has a setting for the macOS deployment target, so I think the MACOSX_DEPLOYMENT_TARGET build setting is still used.
Topic: App & System Services SubTopic: Core OS Tags:
Oct ’23
Reply to fatal error: Index out of range...
What is golfDBdata? I don't see it declared in the code you showed. I assume it's an array. How many elements does it have? What is numDB? What is its value? The error message is telling you that the value of numDB is greater than or equal to the number of elements in golfDBdata. Another potential problem you have is you are running the code asynchronously. You may be trying to access data before it's been fetched.
Oct ’23
Reply to Combining SwiftUI & SpriteKit
It shows a black screen because you passed an empty scene to the sprite view. SpriteView(scene:MapScene()) Calling MapScene() creates an empty scene. You must add a property to your view that holds the scene to show in the sprite view. Call newGameScene to initialize it. @State var mapScene = MapScene.newGameScene() I haven't tested that line of code so you may have to make some changes to get it to work. But it gives you an idea of what you need to do. Pass that property to the sprite view. SpriteView(scene: mapScene)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Reply to Combining SwiftUI & SpriteKit
Create a subclass of SKScene for your SpriteKit scene and use that class to write the code to interact with the scene. Interact with the scene by overriding the touch functions on iOS and the mouse functions on Mac. On iOS you must override touchesBegan. You may also need to override touchesMoved and touchesEnded. On Mac you must override mouseDown. You may also need to override mouseDragged and mouseUp.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Reply to SwiftData Component
Your decks property is an array of type Deck, not a single deck. An array of Deck does not have a name, therefore the following line of code won't work: Text(decks.name) You need to show the name of a single deck in the Text label. If you want to show the names of all the decks, create a list and have a Text label for each item in the list. List(decks) { deck in Text(deck.name) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’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 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 Combining SwiftUI & SpriteKit
I have not tried loading a SpriteKit scene from a .sks file to a SwiftUI sprite view so I don't have a specific solution for you. I have some tips and suggestions that may help you solve the problem yourself or give other people here enough information to help you. It works with some changes Show the code you use to declare the property for the scene in the SwiftUI view. I still can't interact with the MapScene Provide more details. What are you trying to do? What do you expect to happen? What happens? Set a breakpoint in your touchesBegan or mouseDown functions. If you run your project and tap or click in the scene, does the breakpoint fire? If you have not used Xcode's debugger before, read the following article: https://www.swiftdevjournal.com/an-introduction-to-xcodes-debugger/ I doubt you are the first person to have trouble loading a SpriteKit scene into a SwiftUI view. Search on Stack Overflow or a search engine, and chances are high someone has had the same problem and received a solution.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to Documentation for MACOSX_DEPLOYMENT_TARGET?
I found a mention of MACOSX_DEPLOYMENT_TARGET in Xcode's Build Setting Reference. https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW129 I created a new Mac app project in Xcode 14.2, and the project has a setting for the macOS deployment target, so I think the MACOSX_DEPLOYMENT_TARGET build setting is still used.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to fatal error: Index out of range...
What is golfDBdata? I don't see it declared in the code you showed. I assume it's an array. How many elements does it have? What is numDB? What is its value? The error message is telling you that the value of numDB is greater than or equal to the number of elements in golfDBdata. Another potential problem you have is you are running the code asynchronously. You may be trying to access data before it's been fetched.
Replies
Boosts
Views
Activity
Oct ’23
Reply to Combining SwiftUI & SpriteKit
It shows a black screen because you passed an empty scene to the sprite view. SpriteView(scene:MapScene()) Calling MapScene() creates an empty scene. You must add a property to your view that holds the scene to show in the sprite view. Call newGameScene to initialize it. @State var mapScene = MapScene.newGameScene() I haven't tested that line of code so you may have to make some changes to get it to work. But it gives you an idea of what you need to do. Pass that property to the sprite view. SpriteView(scene: mapScene)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to Combining SwiftUI & SpriteKit
Create a subclass of SKScene for your SpriteKit scene and use that class to write the code to interact with the scene. Interact with the scene by overriding the touch functions on iOS and the mouse functions on Mac. On iOS you must override touchesBegan. You may also need to override touchesMoved and touchesEnded. On Mac you must override mouseDown. You may also need to override mouseDragged and mouseUp.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to SwiftData Component
Your decks property is an array of type Deck, not a single deck. An array of Deck does not have a name, therefore the following line of code won't work: Text(decks.name) You need to show the name of a single deck in the Text label. If you want to show the names of all the decks, create a list and have a Text label for each item in the list. List(decks) { deck in Text(deck.name) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’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 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