iOS is the operating system for iPhone.

Posts under iOS tag

72 Posts

Post

Replies

Boosts

Views

Activity

iPadOS, IOKit and Sandbox/MACF
I am trying to run a program that queries a device connected to the USB-C connection on my iPad Air (IpadOS 17). Some IOKit calls work and some fail, with the error message Sandbox: iOSNXLauncher(5338) deny(1) iokit-get-properties iokit-class:IOUSBHostDevice property:sessionID or something similar. Which entitlement should I use to be able to execute the IOKit calls needed to see, for example, the Device ID and the Vendor ID? I would like to use the IOKit calls to communicate withUSB devices. If IOKit doesn't allow USB device communication in iOS, does DriverKit have all of the capabilities to query USB attached devices and pass data back and forth? I am trying to port a program from MacOS to iOS. The MacOS software uses "libUSB" to interface to USB devices. I am trying to use a version compiled for iOS but Sandbox is stopping me (even when Xcode has the "Sandbox App" option set to NO.). Am I missing entitlements or will this approach not work? Gene
7
0
1.1k
Oct ’24
SwiftUI : NavigationStack in new iOS 18 TabView pushes twice when path in parameter
Hello, With iOS 18, when NavigationStack is in new TabView, with path parameter containing current navigation state is set, the navigation destination view is pushed twice. See below with example that pushes twice on iOS 18 but is correct on iOS 17 @MainActor class NavigationModel: ObservableObject { static let shared = NavigationModel() @Published var selectedTab: String @Published var homePath: [Route] @Published var testPath: [Route] } struct ContentView: View { @StateObject private var navigationModel: NavigationModel = NavigationModel.shared var body: some View { TabView(selection: $navigationModel.selectedTab){ HomeView() .tabItem { Label("Home", systemImage: "house") } .tag("home") TestView() .tabItem { Label("Test", systemImage: "circle") } .tag("test") } } } struct HomeView: View { @StateObject private var navigationModel: NavigationModel = NavigationModel.shared var body: some View { NavigationStack(path: $navigationModel.homePath){ VStack{ Text("home") NavigationLink(value: Route.test1("test1")){ Text("Go to test1") } } .navigationDestination(for: Route.self){ route in NavigationModelBuilder.findFinalDestination(route:route) } } } } I don't what causes the issue because it works well on iOS 16 and iOS 17. I think the path is somehow reset but I don't why (maybe by the TabView ?) Note that the bug only occurs with TabView. Don't really know if it is a TabView bug or if it is on my side. I filed a feedback with sample project FB14312064
34
11
6.8k
Oct ’24
How to Obtain Device Support Files for iOS 17 and iOS 18?
Hi everyone, I am currently using Xcode 16.1, which only includes device support files up to iOS 16.4. However, I need to target iPhones running iOS 17 and iOS 18 (e.g., iPhone 15 and iPhone 16). Is there any way to acquire the device support files for iOS versions above 16.4 without upgrading to a new Xcode version that hasn't been released yet? I’m unable to upgrade my Xcode due to hardware limitations, but I still need to test my app on these newer devices. I’ve heard about manually adding device support files, but I’m unsure of the process or where to obtain them safely. Can anyone provide guidance or direct me to where I can find these files? Thanks in advance for your help!
3
1
3.6k
Oct ’24
MacOSX Sonoma 14.7 + XCode 16.0 + iOS 17.6.1:
I am trying to install an app from a XCode project onto a iOS 17.6.1 device. The Macbook is a MacOSX Sonoma 14.7, Apple M2 Pro. I'm running XCode 16.0. I receive a series of alerts before receiving the final message. I tried to delete everything in this folder: rm ~/Library/Caches/com.apple.dt.Xcode/Downloads/* I reviewed the XCode components currently installed: I downloaded more runtime simulators from this link. I then followed the instructions provided in this link. For example: xcrun simctl runtime add "~/Downloads/iOS_17.4_Simulator_Runtime.dmg" xcrun simctl runtime add "~/Downloads/iOS_17.5_Simulator_Runtime.dmg" I'm still getting a message beside the device I want to install my app: The Developer Disk Image Could Not Be Staged On The Host I need help. I don't know what else to do. I don't see any matching simulators available for 17.6.1 and 17.7. Does anyone have any ideas?
7
0
2.5k
Oct ’24
Button icon in List to match style?
I am trying to figure out how to set a button's label icon to match the button style when inside a list. These four buttons display differently depending on context – if put inside a List or a VStack: Button(role: .destructive) {} label: { Label("Test", systemImage: "figure") }.buttonStyle(.automatic) Button(role: .destructive) {} label: { Label("Test", systemImage: "figure") }.buttonStyle(.bordered) Button {} label: { Label("Test", systemImage: "figure") }.buttonStyle(.borderedProminent) Button(role: .destructive) {} label: { Label("Test", systemImage: "figure") }.buttonStyle(.borderedProminent) Inside a List, which looks weird in my opinion. For reference, this is what they look like inside a VStack, which is what I'd expect: I am not sure if this is intentional or a bug. If there are any workaround which do not explicitly set a specific color, like .foreground(.red), please let me know.
3
0
646
Oct ’24
Error Trying to Install iOS 18.0 in Xcode 16(16A242d)
Ussing XCodes I am trying to install the iOS 18.0 Platform in Xcode 16(16A242d). I am getting the error : "Unable to Install Xcode Invalid runtime source" I am a complete mac newbie. I am using (hoping to use) .net MAUI to build an app that i have created in windows for Andriod. Any help would be much appreciated. I am using Sequoia 15.0.1
0
0
305
Oct ’24
[iOS18]My apps do not appear in the shortcut apps.
It is no longer displayed as a target for shortcut app actions. It was displayed until iOS 17.7. Tried with iOS 18.0 and 18.0.1 but it does not appear. Shortcuts created when under iOS 18 work fine. Only INPlayMediaIntent is supported and is targeted at iOS 15 and above, so no Extension is used and is handled directly in the app. Is anyone else suffering from the same problem?
1
0
603
Oct ’24
[iOS 18] Scrolling behavior does not work only when built in Xcode 16
Code that worked well before upgrading to Xcode 16 doesn't work if it builds on Xcode 16. What doesn't work will not scroll when you use ScrollViewReader to scrollTo with View assigned id. The bug is only reproduced on iOS 18 devices, and it works well on IOS 18 devices when built on Xcode 15 version. Attached is the sample code below. import SwiftUI struct RegisterSheetView: View { @State private var keyword = "" @State private var descriptionMessage: String? @State private var sheetHeight: CGFloat = .zero @State private var sheetFirstPageHeight: CGFloat = .zero @State private var sheetSecondPageHeight: CGFloat = .zero @State private var sheetScrollProgress: CGFloat = .zero var body: some View { GeometryReader(content: { geometry in let size = geometry.size ScrollViewReader(content: { proxy in ScrollView(.horizontal) { HStack(alignment: .top, spacing: 0) { FirstPage(size) .id("First") SecondPage(size) .id("Second") } .scrollTargetLayout() } .scrollTargetBehavior(.paging) .scrollIndicators(.hidden) .overlay(alignment: .topTrailing) { Button(action: { if sheetScrollProgress < 1 { // First Page Button Action withAnimation(.snappy) { proxy.scrollTo("Second", anchor: .leading) } } else { // Second Page Button Action print("Register Button Action") } }, label: { Text("continue") .fontWeight(.semibold) .opacity(1 - sheetScrollProgress) .frame(width: 120 + (sheetScrollProgress * 15)) .overlay(content: { Text("regist") .fontWeight(.semibold) .opacity(sheetScrollProgress) }) .padding(.vertical, 12) .foregroundStyle(.white) .background(.linearGradient(colors: [.red, .orange], startPoint: .topLeading, endPoint: .bottomTrailing), in: .capsule) }) .padding(15) .offset(y: sheetHeight - 100) .offset(y: sheetScrollProgress * -90) } }) }) .presentationCornerRadius(30) .presentationDetents(sheetHeight == .zero ? [.medium] : [.height(sheetHeight)]) .onDisappear { keyword = "" } } // First View @ViewBuilder func FirstPage(_ size: CGSize) -> some View { VStack(alignment: .leading, spacing: 12, content: { Text("First Page") .font(.largeTitle.bold()) .lineLimit(2) Text(attributedSubTitle) .font(.callout) .foregroundStyle(.gray) Text("What's the problem") .foregroundStyle(.blue) .font(.system(size: 16, weight: .semibold)) .frame(width: size.width, alignment: .leading) .onTapGesture { print("Tapped") } }) .padding(15) .padding(.horizontal, 10) .padding(.top, 15) .padding(.bottom, 130) .frame(width: size.width, alignment: .leading) .heightChangePreference { height in sheetFirstPageHeight = height sheetHeight = height } } var attributedSubTitle: AttributedString { let string = "It works fine on Xcode 15 but builds on Xcode 16 and doesn't work on iOS 18 devices." var attString = AttributedString(stringLiteral: string) if let xcode16Range = attString.range(of: "Xcode 16") { attString[xcode16Range].foregroundColor = .black attString[xcode16Range].font = .callout.bold() } if let ios18Range = attString.range(of: "iOS 18") { attString[ios18Range].foregroundColor = .black attString[ios18Range].font = .callout.bold() } return attString } // Second View @ViewBuilder func SecondPage(_ size: CGSize) -> some View { VStack(alignment: .leading, spacing: 12) { Text("Key Registration") .font(.largeTitle.bold()) CustomTextField(hint: "Please enter the contents", text: $keyword, icon: "person") .padding(.top, 20) } .padding(15) .padding(.horizontal, 10) .padding(.top, 15) .padding(.bottom, 190) .overlay(alignment: .bottom, content: { VStack(spacing: 15) { Text("Apple **[Developer Forums](https://developer.apple.com/forums/)**") .font(.caption) .tint(.blue) .foregroundStyle(.gray) } .padding(.bottom, 15) .padding(.horizontal, 20) .multilineTextAlignment(.center) .frame(width: size.width) }) .frame(width: size.width) .heightChangePreference { height in sheetSecondPageHeight = height let diff = sheetSecondPageHeight - sheetFirstPageHeight sheetHeight = sheetFirstPageHeight + (diff * sheetScrollProgress) } .minXChangePreference { minX in let diff = sheetSecondPageHeight - sheetFirstPageHeight let truncatedMinX = min(size.width - minX, size.width) guard truncatedMinX > 0 else { return } let progress = truncatedMinX / size.width sheetScrollProgress = progress sheetHeight = sheetFirstPageHeight + (diff * progress) } } } extension View { @ViewBuilder func heightChangePreference(completion: @escaping (CGFloat) -> ()) -> some View { self .overlay { GeometryReader(content: { geometry in Color.clear .preference(key: SizeKey.self, value: geometry.size.height) .onPreferenceChange(SizeKey.self) { value in DispatchQueue.main.async { completion(value) } } }) } } @ViewBuilder func minXChangePreference(completion: @escaping (CGFloat) -> ()) -> some View { self .overlay { GeometryReader(content: { geometry in Color.clear .preference(key: OffsetKey.self, value: geometry.frame(in: .scrollView).minX) .onPreferenceChange(OffsetKey.self) { value in DispatchQueue.main.async { completion(value) } } }) } } } struct SizeKey: PreferenceKey { static var defaultValue: CGFloat = .zero static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value = nextValue() } } struct OffsetKey: PreferenceKey { static var defaultValue: CGFloat = .zero static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value = nextValue() } } struct CustomTextField: View { var hint: String @Binding var text: String var icon: String var body: some View { VStack(alignment: .leading, spacing: 12) { TextField(hint, text: $text) .padding(.trailing, 28) .padding(.top, 10) Divider() } .overlay(alignment: .trailing) { Image(systemName: icon) .foregroundStyle(.gray) } } } struct ContentView: View { @State private var isPresented: Bool = false var body: some View { Button { isPresented.toggle() } label: { Text("Show Bottom Sheet") .padding() .background(Color.yellow) } .sheet(isPresented: $isPresented) { RegisterSheetView() } } }
3
2
1.5k
Oct ’24
iOS app loses access to the Documents folder inside the iCloud ubiquity container
I have an iOS app that writes files to its iCloud ubiquity container. The container is specified in Signing & Capabilities as iCloud.com.myappbusiness.myappid where "com.myappbusiness.myappid" is the bundle identifier. It works most of the time but for some users (less than 1%) it stops working at some point, most likely after any update of my app. Device reboot or app reinstallation does not help. What seems to help is turning off iCloud for the app in the iOS Settings (at which point the app saves files to the device locally) and then turning it on again. I cannot replicate the issue and have to rely on user feedback. I have tried various fixes over the past half a year, added retries after timeout, error handlers, tracing, etc. But the error always appears to someone after another app update. I have narrowed it down to the three lines of code below that check for the existence of the app iCloud container: NSFileManager* fileManager = [[NSFileManager alloc] init]; NSURL* containerUrl = [[fileManager URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:@"Documents"]; BOOL doesExist = [fileManager fileExistsAtPath:containerUrl.path]; doesExist returns NO when the issue happens. I.e. the app does not see its container and it looks like it does not exist. The folder should exist as this happens to long term users that have used the app before. Regarding the containerUrl, I can see it in the log that I get from the affected users and it is the correct path to the container, e.g. /private/var/mobile/Library/Mobile Documents/iCloud~com~myappbusiness~myappid/Documents I have tried the code above as it is and also within a file coordinator handler: [[[NSFileCoordinator alloc] initWithFilePresenter:nil] coordinateWritingItemAtURL:targetFileUrl options:NSFileCoordinatorWritingForReplacing error:&error byAccessor:^(NSURL * _Nonnull newURL) { ... the code here ... }]; I have run out of ideas what else to try. Is there anything obviously wrong with this approach or am I missing something in the code here? Is this a permission issue? Do I need to recreate the Documents folder if it's not accessible?
0
1
477
Oct ’24
Challenges with Remotely Controlling iPhone Camera from Mac: Need Guidance
Hello everyone, I am working on an iOS app that involves capturing images automatically, and I would like to control the start/stop of the capture process remotely from a Mac app. I explored the iPhone Mirroring feature, which allows some remote control but has the limitation of only functioning when the iPhone is locked, and it doesn’t permit access to the iPhone’s camera from the Mac. Ideally, I am looking for a solution that would allow me to: Remotely control the camera capture process on the iOS app from the Mac app. Ensure the iPhone’s camera remains fully operational and controllable from the Mac during the capture process. I have considered using options like Handoff for communication between the apps but faced some issues while communicating between the iOS and mac app. I would like to know if there is a more optimal solution within Apple’s ecosystem, or if there are APIs I might have overlooked. Any advice or guidance on how to achieve this functionality would be greatly appreciated! Thanks in advance!
1
0
578
Oct ’24
Meetings color in calendar
Hi, starting from iOS18, it is impossible to differentiate between completed meetings and future meetings in calendar - almost the same color (unless I switch to dark mode). Is there a way to fix it or is it a human engineering bug?
Topic: Design SubTopic: General Tags:
2
0
493
Oct ’24
AVPlayerViewController not displaying playback controls in iOS 18
Hi everyone, I’ve encountered an issue with the showsPlaybackControls property in AVPlayerViewController after updating to iOS 18. Even though it’s set to true, the native playback controls (play, pause, etc.) are no longer appearing as they used to in previous iOS versions. This behavior was consistent and worked perfectly prior to iOS 18. Additionally, I’m seeing the same problem when using the VideoPlayer in SwiftUI. The native controls that should appear by default seem to have vanished after the update. Has anyone else experienced this? Is there any workaround or additional configuration required to restore the native controls? Any help or insights would be appreciated. Thanks! struct CustomPlayerView: UIViewControllerRepresentable { let player: AVPlayer func updateUIViewController(_ playerController: AVPlayerViewController, context: Context) { playerController.player = player playerController.showsPlaybackControls = true player.play() } func makeUIViewController(context: Context) -> AVPlayerViewController { return AVPlayerViewController() } }
8
1
1.6k
Oct ’24
iOS 18: "Invalid number of items in section 0"
Hi, I recently started experiencing the following bug in the code listed below. The app is a dieting/calorie logging app with a function that presents a List() of calories in different days, separated into sections for each Meal as derived from an array of Meals. Part of this functionality is that the user can swipe an entry in the List to delete one. If the user has one entry and they delete it, behaviour is as expected. If they have more than one entry and they delete one, behaviour is as expected. If they have more than one entry and they delete two items, one after another, the app crashes with the message "Invalid number of items in section 0". If they have more than one entry and they delete one, then go back to the main screen of the app, then delete another one, behaviour is as expected. Searches online suggest that this is because the array underpinning the list has not updated. However the app crashes before it has even reached the delete() function called by onDelete, so there is no opportunity to update the model before something refreshes and the app crashes. Does anyone have any idea how to resolve this? This code worked fine up until iOS 18. List { if list.budgieData.count != 0 { ForEach(list.mealList.indices, id: \.self) { idx in Section(header: Text(list.mealList[idx].name)) { ForEach(list.budgieData.indices, id: \.self) { entryIdx in if list.budgieData[entryIdx].meal == list.mealList[idx].mealUUID { CalorieEntryView(calories: list.budgieData[entryIdx].calories, narrative: list.budgieData[entryIdx].narrative ?? "Quick calories", realEntry: list.budgieData[entryIdx].realEntry, date: list.budgieData[entryIdx].date) } }.onDelete(perform: delete) } } } else { Text("You have no calories logged in Budgie Diet on this day.") } if list.hkCalories != 0 { Section(header: Text("Calories from other apps"), footer: Text("These are calories logged in Health by other apps. You'll need to go to the app that logged them to change or delete them.")) { CalorieEntryView(calories: list.hkCalories, narrative: "Calories from other apps", realEntry: false, date: list.curDate) .deleteDisabled(true) } } }.listStyle(.grouped)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
207
Oct ’24
SwiftUI conditional modifier depending on OS type and version
This app may run on MacOS or iOS. I want to use windowResizability modifier (specially In MacOS) which is only available on masOS 13+ and iOS 17+, but still need to run on macOS 12 or iOS 15… So I need something like #if os(macOS) if #available(macOS 13 *) { use windowResizability #else do not use windowResizability #endif #else // iOS if #available(iOS 17 *) { use windowResizability #else do not use windowResizability #endif Here is the code where to apply (in @main) struct TheApp: App { var body: some Scene { WindowGroup { ContentView() // 1.11.2023 .frame( minWidth: 1200, maxWidth: .infinity, minHeight: 600, maxHeight: .infinity) } .windowResizability(.contentSize) // BTW: is that really necessary ? } } How can I achieve this ? Do I need to write a WindowGroup extension for the modifier ? If so, how ? BTW: is windowResizability really necessary ? App seems to work the same without it.
1
1
709
Oct ’24
iOS widget crashing in body getter with -[NSTaggedPointerString identifier]: unrecognized selector sent to instance
Here is the code where the crash occurs var body: some WidgetConfiguration { IntentConfiguration(kind: WidgetKind, intent: ConfigurationIntent.self, provider: provider) { entry in // Parse config if let config = entry.configuration { if let fg = config.foreground, let fgColorId = fg.identifier, <---- let fgColors = AppSettings.sharedInstance()?.object(forKey: kWidgetForeground) as? [String:String], let fgColor = fgColors[fgColorId] { theme.textColor = Color.init(UIColor.fromHex(fgColor)) theme.iconColor = Color.init(UIColor.fromHex(fgColor)) } else { theme.textColor = .white//Color.primary theme.iconColor = .white//Color.primary } configuration is INIntent with foreground var which is INObject but some times it seems its not... and instead its NSTaggedPointerString unless I'm missing something here.
3
0
535
Oct ’24
Unacceptable, Dangerous Bugs with VPN configuration profiles.
I'm trying to set up a configuration profile on a supervised device for a kid's phone. I want to force a VPN 100% of the time except for local network activity and some specific domains. Or at the very least, have a few apps go outside the tunnel. Apple makes this IMPOSSIBLE even though according to the documentation it should be possible. The IKEv2 vpntype has a key "OnDemandUserOverrideDisabled" which is supposed to prevent a user from toggling off the vpn, which obviously defeats the purpose of having it. However, as other users have posted, this DOES NOT WORK. So anyone can just turn off the vpn and be connected to the internet unprotected. On the "AlwaysOn" vpntype, the element "ApplicationExceptions" which would allow you to list a few applications that can go outside the tunnel DOES NOT WORK. This is critical because so many domains automatically block vpn servers and it's a huge pain. Also local network activity also gets blocked, which makes it impossible to connect to local devices. And there's no split tunneling possible with this vpntype. So basically, it's impossible. I WOULDN'T BE SURPRISED IF APPLE DID THIS INTENTIONALLY TO KEEP KIDS ADDICTED AND IN DANGER SO THEY USE THE PHONE MORE.
0
0
442
Oct ’24
Ethernet / TCP socket direct to server device with static IP
Hi, I have a hardware device that asks as an ethernet server. I need to connect to it using a TCP socket over ethernet. Problem is, I cannot find an API or example code on how to go about this. I have tried to search through the available network interfaces using AF_LINK (link layer) family but only the wifi shows up (en0), even when the device is connected and the iPhone self-assigns an IP etc. Extra challenge is, I am using objective C because all of my other code is written that way. I'm happy to add a swift module where that is the only option. Can someone please point me in the right direction?
1
0
344
Oct ’24
users Widgets disappear!!! Xcode 16
Some users have reported that the app's widgets have disappeared after we updated to the latest Xcode for iOS 18 development. They are unable to find our app in the widget search, which prevents them from re-adding the widget. We were unable to reproduce this issue on our own devices during testing. Could this be a system bug? Have others encountered a similar issue?
11
8
1.8k
Oct ’24
iOS SwiftUI WidgetKit: My widgets don’t show up in the ‘Add Widgets’ section
I developed an app with 10 widgets but some iPhone, iPad or macOS users report that my widgets or the "App Name" don't appear in the widgets list when they tried to add the widgets of my app. There's no way I can replicate the problem, but the number of the users that report this issue is growing up every day. It’s not clear if the problem is caused by the iPhone model, a crash on the widget preview or other factors. My widgets previews are built reading static data, so this data is the same in every conditions. I suggest my users to do the following steps: Start the app and go to check again if "App name" appears among widget List Close every app and restart the device; then start the app and go to check again if "App name" appears among widget List Temporarily change system language and turn on Bold Text and go to check again if "App Name" appears among widget List Uninstall and reinstall the app, start the app and go to check again if "App Name" appears among widget List But all users who have tried these steps say that the app still does not appear in the list of widgets. The following code is the one I use inside the main widgets swift file called TodayWidgetExtension: import WidgetKit import SwiftUI struct PlaceholderView : View { var body: some View { Text("loading") } } //MARK: - Main widget bundle configuration @main struct WidgetBundle: WidgetBundle { @WidgetBundleBuilder var body: some Widget { //MARK: - 1 Widget1Large() Widget1Medium() Widget1Small() if #available(iOSApplicationExtension 16.0, *) { Widget1Accessory() } //MARK: - 2 Widget2Large() //MARK: - 3 #if !targetEnvironment(macCatalyst) Widget3Medium() #endif //MARK: - 4 Widget4Large() //MARK: - 5 Widget5Medium() //MARK: - 6 Widget6Large() Widget6Medium() } } struct todaywidgetextension_Previews: PreviewProvider { static var previews: some View { PlaceholderView() .previewContext(WidgetPreviewContext(family: .systemSmall)) } } The only thing that I've noticed debugging the widgets extension is that, even if I don't add any of them to my iPhone screen, Xcode tells me that widgets occupied 20mb of memory (the limit for widgets is 30mb). I tried removing all the widgets from the above code leaving only one (Widget1Small for example), but Xcode continues to tell me that 20mb of memory are still occupied. I hope that someone can help me. Thank you.
1
0
1k
Oct ’24