Post

Replies

Boosts

Views

Activity

Reply to Run on iOS 17 with Xcode 13.2.1
The following article shows ways to get around your issue. https://www.swiftdevjournal.com/dealing-with-failed-to-prepare-device-for-development-error-message-in-xcode/ If the workarounds in that article don't work, you will need to find a device running an older version of iOS to run your project on your Mac.
Mar ’24
Reply to SwiftUI Binding property from view model to a value outside of that view model
I don't have any simplified approach for you. I can tell you two things. First, to pass a view model to a SwiftUI view, do the following: Have the view model conform to ObservableObject. Add @Published properties in the view model for any properties where you want the view to update when the property's value changes. Use @StateObject in the view that owns the view model. Use @ObservedObject in the other views where you want to use the view model. Second, avoid nesting observable objects. SwiftUI views may not update properly when a property in a nested observable object has its value change. If you are unfamiliar with nested observable objects, read the following article: https://holyswift.app/how-to-solve-observable-object-problem/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to Detecting touching a SKSpriteNode within a touchesBegan event?
I don't see anything obviously wrong in your code. The only possible problem I see is a coordinate system problem where the values of the touch location may not be what you expect because the view and the scene have different coordinates. Set a breakpoint at the following line of code: let node:SKNode = ourScene.atPoint(location) Check if location is where you expect it to be.
Topic: Graphics & Games SubTopic: General Tags:
Feb ’24
Reply to SwiftUI Binding property from view model to a value outside of that view model
I made a mistake in my answer. The @ObservedObject property wrapper is for SwiftUI views. You can't use it in a view model. The following declaration: @ObservedObject var dataManager = DataManager() Should be something like @Published var dataManager = DataManager() I am not sure what you are asking in your second response. You described what you are trying to do but didn't ask a question.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to SwiftUI Binding property from view model to a value outside of that view model
Bindings are for SwiftUI views. Using @Binding in a view model isn't going to work. Creating a binding like Binding<Bool> in a view model isn't going to work either. For passing data from a view model to a SwiftUI view, you are on the right track with the following code in ContentViewModel: class ContentViewModel: ObservableObject { @ObservedObject var dataManager = DataManager() @Published var isOn: Bool = false } Have the view model conform to ObservableObject. Use @Published for any properties where you want the view to update when the property's value changes. The view that owns the view model uses the @StateObject property wrapper, like you have in your content view. @StateObject var viewModel = ContentViewModel() Use the @ObservedObject property wrapper to pass the view model from the content view to other views. I am not sure why the content view model needs its own isOn property. Can't it use the data manager's isOn property?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’24
Reply to .playground to .swiftpm
For the Swift Student Challenge, either create an App playground in the Swift Playgrounds app or create a Swift Playgrounds App project in Xcode. That will give you a playground or project that meets the challenge's eligibility requirements. https://developer.apple.com/swift-student-challenge/eligibility/
Feb ’24
Reply to Developing with an older Mac
Starting April 29 Apple is going to require Xcode 15 for App Store submissions. Xcode 15 requires macOS 13+. https://developer.apple.com/news/?id=fxu2qp7b The chances are high you won't be able to submit apps with that MacBook Air. I recommend buying a Mac with an ARM processor. ARM Macs are going to be supported longer than Intel Macs.
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’24
Reply to URL (via .fileImporter) to a ReadConfiguration - How to?
The .fileImporter modifier isn't for opening your SwiftUI app's documents. It's for opening other types of files in your app. The document struct's init that takes a ReadConfiguration is for opening your app's documents, either from a document picker (iOS) or by choosing File > Open (Mac). Instead of using your document struct's init that takes a ReadConfiguration, write a function to process the JSON that takes a URL as an argument. Pass the URL the file importer gives you to the JSON processing function.
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’24
Reply to support need for old swift Vs new swift
I'm trying to follow STORMVIEWS tutorial which was made with an old version of swift were viewed load was still available The viewDidLoad method is still available. Your problem is that you are using SwiftUI to follow a tutorial that uses UIKit. Start over by creating a UIKit project. Take the following steps to create a UIKit project in Xcode: In Xcode choose File > New > Project. Select iOS from the platforms at the top of the New Project Assistant. Select the App template from the list of iOS app templates. Click the Next button. Choose Storyboard from the Interface menu. Read the following article for more details and a screenshot: https://www.swiftdevjournal.com/xcode-11-missing-view-controllers/
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’24