Post

Replies

Boosts

Views

Activity

How do we install older iOS SDKs in Xcode?
Hi all. I'm writing an app that targets iOS 15 and beyond. I can't build or test because Xcode complains that iOS 17 SDK is not installed, which is true. But my deployment target is set for 15.6. I installed a simulator for 15 by downloading iOS 15 simulator support from the Platforms tab in settings. This is also where you see that iOS SDKs there are... but there's no way to add them. The + button in the corner only lets you install more simulators. Where do you install support for earlier iOS versions? This is in Xcode 15.0.1. Thanks.
2
4
2.1k
Oct ’23
SwiftUI seems to assume that no one uses optionals anymore.
I'm wrestling with a view that handles a class whose members are mostly optional. This does not appear to be a scenario that SwiftUI envisions. What is the expected approach? Take this class, for example, which represents a user: class User : Equatable, Codable, ObservableObject { var ID: String? var pw: String? var username: String? var firstName: String? var lastName: String? var EMail: String? var phoneNbr: String? var avatarURL: String? var mediaServiceID: String? var validated: Bool = false ... } I can't directly show a form to fill this thing out in SwiftUI, because you can't bind text fields to optionals. Most of the published workarounds to that involve using let to create a non-optional variable if the member isn't nil; but this is unworkable because that won't populate a nil member if someone enters text in the text field. Apple docs talk about custom binding, which would probably work to populate an optional member. That means doing this in the SwiftUI view to set the object's username, for example: @State private var tempUser = User() private var username: Binding<String> { Binding { if let theName = tempUser.username { return theName } else { return "" } } set: { newName in tempUser.username = newName } } But that means setting up one of these verbose methods for every single optional member of every class I want to show in a UI. At that point I might as well just make a shadow structure that's all non-optionals that I can bind directly to. Or just make all the members non-optional and just face the fact that optionals are done with in the age of SwiftUI. Or is there some succinct approach I'm missing here? Thanks for any insight.
2
1
1.3k
Jan ’24
Are changes to published embedded objects really not detected in SwiftUI?
Let's say I have a class to represent a user: class User : Equatable, Codable, ObservableObject { @Published var ID: String = "" @Published var username: String = "" @Published var firstName: String = "" @Published var lastName: String = "" @Published var EMail: String = "" @Published var phoneNbr: String = "" @Published var avatarURL: String = "" @Published var mediaServiceID: String = "" @Published var validated: Bool = false ... } I also have a controller ("viewmodel") to broker interactions between SwiftUI views and the User. It contains a User object as: @MainActor class UserManager : ObservableObject { @Published var user: User ... } And finally of course the view, into which I pass the UserManager upon initialization: struct StartupView: View { @ObservedObject var userMgr: UserManager ... } Changing published members of the User embedded in UserManager does not trigger a UI refresh. That strikes me as broken, since everything is published. Is it expected behavior?
3
0
935
Jan ’24
Downloaded certificates not showing up in Certificate Trust Authority
Under iOS 18.0.1, I can't do any development that uses HTTPS, because I can't authorize my generated certificates on my phone. This was not a problem in the past. Normally you AirDrop a root certificate authority to your phone, install the "profile" for it, and then trust it in Settings / General / About / Certificate Trust Authority. Then you can connect to another server on your network that's using the accompanying certificates. But after sucessfully installing two profiles on my phone, neither shows up in Certificate Trust Authority. Anybody else seeing this? This problem, in combo with this one (which prevents running on my Mac as an iPad app) has completely halted my project. I've found reports of this problem that blamed an empty "common name" field in the certs, but that field is populated in both of these.
3
1
1k
Oct ’24
Xcode's new-tab vs. reuse-tab behavior is still infuriating and baffling.
Is there any way to stop Xcode from randomly re-using a tab when you click on a file in the project treeview? I never, never, NEVER want the file in the current tab replaced. If the clicked-on file is not already open in a tab, I want a new one. Every time. But in Xcode, you sometimes get a new tab, and sometimes don't. I can't find any pattern to this absurd behavior. Even double-clicking doesn't produce a new tab, even though the Navigation settings say, "Double-click: Opens tab in focused editor." WTH is this thing doing, and how do we stop it? This is Xcode 16.4.
3
1
329
Sep ’25
App crashes at launch on missing symbol AVPlayerView... except on first launch
I don't know what triggered this in a previously-running application I'm developing: When I have the build target set to "My Mac (designed for iPad)," I now must delete all the app's build materials under DerivedData to get the app to build and run exactly once. Cleaning isn't enough; I have to delete everything. On second launch, it will crash without even getting to the instantiation of the application class. None of my code executes. Also: If I then set my iPhone as the build target, the app will build and run repeatedly. If I then return to "My Mac (designed for iPad)," the app will again launch once and then crash on every subsequent launch. The crash is the same every time: dyld[3875]: Symbol not found: _OBJC_CLASS_$_AVPlayerView Referenced from: <D566512D-CAB4-3EA6-9B87-DBD15C6E71B3> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Debugger/libViewDebuggerSupport.dylib Expected in: <4C34313C-03AD-32EB-8722-8A77C64AB959> /System/iOSSupport/System/Library/Frameworks/AVKit.framework/Versions/A/AVKit Interestingly, I haven't found any similar online reports that mention this symbol. Has anyone seen this behavior before, where the crash only happens after the first run... and gets reset when you toggle the target type?
6
0
1.1k
Nov ’24
Why aren't changes to @Published variables automatically published on the main thread?
Given that SwiftUI and modern programming idioms promote asynchronous activity, and observing a data model and reacting to changes, I wonder why it's so cumbersome in Swift at this point. Like many, I have run up against the problem where you perform an asynchronous task (like fetching data from the network) and store the result in a published variable in an observed object. This would appear to be an extremely common scenario at this point, and indeed it's exactly the one posed in question after question you find online about this resulting error: Publishing changes from background threads is not allowed Then why is it done? Why aren't the changes simply published on the main thread automatically? Because it isn't, people suggest a bunch of workarounds, like making the enclosing object a MainActor. This just creates a cascade of errors in my application; but also (and I may not be interpreting the documentation correctly) I don't want the owning object to do everything on the main thread. So the go-to workaround appears to be wrapping every potentially problematic setting of a variable in a call to DispatchQueue.main. Talk about tedious and error-prone. Not to mention unmaintainable, since I or some future maintainer may be calling a function a level or two or three above where a published variable is actually set. And what if you decide to publish a variable that wasn't before, and now you have to run around checking every potential change to it? Is this not a mess?
9
0
3.7k
Oct ’24