Will UVC native support come for the Iphone as well?
So, using external cameras with the ipad is greatly beneficial, but for the iphone, it can make it a production powerhouse!
So, have there been discussions around bringing UVC support for the Iphone as well? and if so, what were your conclusions?
Delve into the world of built-in app and system services available to developers. Discuss leveraging these services to enhance your app's functionality and user experience.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm using SwiftData to persist my items in storage. I used .modelContext to pass in my shared context, and on iOS 18 (both on a physical device and a simulator), I discovered a bug where SwiftData doesn't automatically save my data. For example, I could add a new item, go to the next screen, change something that reloads a previous screen, and SwiftData just forgets the item that I added. Please find the fully working code attached.
While writing this post, I realized that if I use .modelContainer instead of .modelContext, the issue is solved. So I have two questions:
It seems like .modelContainer is the go-to option when working with SwiftData, but why did an issue occur when I used .modelContext and passed in a shared container? When should we use .modelContext over .modelContainer?
What was the bug? It's working fine in iOS 17, but not in iOS 18. Or is this expected?
Here's the fully working code so you can copy and paste:
import SwiftUI
import SwiftData
typealias NamedColor = (color: Color, name: String)
extension Color {
init(r: Double, g: Double, b: Double) {
self.init(red: r/255, green: g/255, blue: b/255)
}
static let namedColors: [NamedColor] = [
(.blue, "Blue"),
(.red, "Red"),
(.green, "Green"),
(.orange, "Orange"),
(.yellow, "Yellow"),
(.pink, "Pink"),
(.purple, "Purple"),
(.teal, "Teal"),
(.indigo, "Indigo"),
(.brown, "Brown"),
(.cyan, "Cyan"),
(.gray, "Gray")
]
static func name(for color: Color) -> String {
return namedColors.first(where: { $0.color == color })?.name ?? "Blue"
}
static func color(for name: String) -> Color {
return namedColors.first(where: { $0.name == name })?.color ?? .blue
}
}
@main
struct SwiftDataTestApp: App {
var sharedModelContainer: ModelContainer = {
let schema = Schema([
Item.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
@AppStorage("accentColor") private var accentColorName: String = "Blue"
var body: some Scene {
WindowGroup {
NavigationStack {
HomeView()
}
.tint(Color.color(for: accentColorName))
}
.modelContainer(sharedModelContainer) // This works
// .modelContext(ModelContext(sharedModelContainer)) // This doesn't work
}
}
@Model
final class Item {
var timestamp: Date
init(timestamp: Date) {
self.timestamp = timestamp
}
}
struct HomeView: View {
@State private var showSettings = false
@Environment(\.modelContext) var modelContext
@AppStorage("accentColor") private var accentColorName: String = "Blue"
@Query private var items: [Item]
var body: some View {
List {
ForEach(items) { item in
NavigationLink {
Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))")
} label: {
Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))
}
}
Button {
withAnimation {
let newItem = Item(timestamp: Date())
modelContext.insert(newItem)
}
} label: {
Image(systemName: "plus")
.frame(maxWidth: .infinity)
.frame(maxHeight: .infinity)
}
}
.navigationTitle("Habits")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: { showSettings = true }) {
Label("", systemImage: "gearshape.fill")
}
}
}
.navigationDestination(isPresented: $showSettings) {
colorPickerView
}
}
private var colorPickerView: some View {
Form {
Section(header: Text("Accent Color")) {
Picker("Accent Color", selection: $accentColorName) {
ForEach(Color.namedColors, id: \.name) { namedColor in
Text(namedColor.name)
.tag(namedColor.name)
.foregroundColor(namedColor.color)
}
}
.pickerStyle(.wheel)
}
}
.navigationTitle("Settings")
}
}
I've started getting reports of this today and I am able to replicate it on my end but looking to see if anyone else can verify or if it's possibly regional to me (Canada).
In Apple Maps (iOS or macOS), if you search a latitude and longitude -- for example: "49.110,-112.110" and search, it centers on the location as it always has and shows the "Directions" button. When you tap the directions button, I get "A route can't be shown because of a problem connecting to the server.".
Alternatively, if you pass the coordinate in via Apple Maps URL (https://maps.apple.com/?daddr=49.110,-112.110) it will route but the route is no longer to those specific coordinates, Apple Maps alters them to some nearest known entity (in this case, the RM of Warner County). If you compare the suggested route end destination with the search results for specifically entering the coordinates, you will see they are different locations and mapping routes are not actually taking you to the coordinates anymore.
In the last photo attached, the arrow points to where "49.110,-112.110" is actually located which tapping the "Directions" button cannot figure out a route because of a server issue. If you pass it in via URL, it changes the destination coordinates and begins a route quite a ways away from the intended coordinate.
The problem started happening either this morning or last night.
Can anyone else confirm this happens to them?
Thanks,
Mike
Hello everyone,
I've built a @CurrentValue property wrapper that mimics the behavior of @Published, allowing a property to publish values on "did set". I've also created my own assign(to:) implementation that works with @CurrentValue properties, allowing values to be assigned from a publisher to a @CurrentValue property.
However, I'm running into an issue. When I use this property wrapper with two classes and the source class (providing the publisher) is not stored as a property, the subscription is deallocated, and values are no longer forwarded.
Here's the property wrapper code:
@propertyWrapper
public struct CurrentValue<Value> {
/// A publisher for properties marked with the `@CurrentValue` attribute.
public struct Publisher: Combine.Publisher {
public typealias Output = Value
public typealias Failure = Never
/// A subscription that forwards the values from the CurrentValueSubject to the downstream subscriber
private class CurrentValueSubscription<S>: Subscription where S: Subscriber, S.Input == Output, S.Failure == Failure {
private var subscriber: S?
private var currentValueSubject: CurrentValueSubject<S.Input, S.Failure>?
private var cancellable: AnyCancellable?
init(subscriber: S, publisher: CurrentValue<Value>.Publisher) {
self.subscriber = subscriber
self.currentValueSubject = publisher.subject
}
func request(_ demand: Subscribers.Demand) {
var demand = demand
cancellable = currentValueSubject?.sink { [weak self] value in
// We'll continue to emit new values as long as there's demand
if let subscriber = self?.subscriber, demand > 0 {
demand -= 1
demand += subscriber.receive(value)
} else {
// If we have no demand, we'll cancel our subscription:
self?.subscriber?.receive(completion: .finished)
self?.cancel()
}
}
}
func cancel() {
cancellable = nil
subscriber = nil
currentValueSubject = nil
}
}
/// A subscription store that holds a reference to all the assign subscribers so we can cancel them when self is deallocated
fileprivate final class AssignSubscriptionStore {
fileprivate var cancellables: Set<AnyCancellable> = []
}
fileprivate let subject: CurrentValueSubject<Value, Never>
fileprivate let assignSubscriptionStore: AssignSubscriptionStore = .init()
fileprivate var value: Value {
get {
subject.value
}
nonmutating set {
subject.value = newValue
}
}
init(_ initialValue: Output) {
self.subject = .init(initialValue)
}
public func receive<S>(subscriber: S) where S: Subscriber, Failure == S.Failure, Output == S.Input {
let subscription = CurrentValueSubscription(subscriber: subscriber, publisher: self)
subscriber.receive(subscription: subscription)
}
}
public var wrappedValue: Value {
get { publisher.value }
nonmutating set { publisher.value = newValue }
}
public var projectedValue: Publisher {
get {
publisher
}
mutating set {
publisher = newValue
}
}
private var publisher: Publisher
public init(wrappedValue: Value) {
publisher = .init(wrappedValue)
}
}
/// A subscriber that receives values from an upstream publisher and assigns them to a downstream CurrentValue property.
private final class AssignSubscriber<Input>: Subscriber, Cancellable {
typealias Failure = Never
private var receivingSubject: CurrentValueSubject<Input, Never>?
private weak var assignSubscriberStore: CurrentValue<Input>.Publisher.AssignSubscriptionStore?
init(currentValue: CurrentValue<Input>.Publisher) {
self.receivingSubject = currentValue.subject
self.assignSubscriberStore = currentValue.assignSubscriptionStore
}
func receive(subscription: Subscription) {
// Hold a reference to the subscription in the downstream publisher
// so when it deallocates, the susbcription is automatically cancelled
assignSubscriberStore?.cancellables.insert(AnyCancellable(subscription))
subscription.request(.unlimited)
}
func receive(_ input: Input) -> Subscribers.Demand {
receivingSubject?.value = input
return .none
}
func receive(completion: Subscribers.Completion<Never>) {
// Nothing to do here
}
public func cancel() {
receivingSubject = nil
assignSubscriberStore = nil
}
}
public extension Publisher where Self.Failure == Never {
/// Assigns the output of the upstream publisher to a downstream CurrentValue property
/// - Parameter currentValue: The CurrentValue property to assign the values to
func assign(to currentValue: inout CurrentValue<Self.Output>.Publisher) {
let subscriber = AssignSubscriber(currentValue: currentValue)
self.subscribe(subscriber)
}
}
Here’s an example demonstrating the issue, where two classes are used: Source, which owns the @CurrentValue property, and Forwarder1, which subscribes to updates from Source:
final class Source {
@CurrentValue public private(set) var value: Int = 1
func update(value: Int) {
self.value = value
}
}
final class Forwarder1 {
@CurrentValue public private(set) var value: Int
init(source: Source) {
self.value = source.value
source.$value.dropFirst().assign(to: &$value)
// The source is not stored as a property, so the subscription deallocates
}
func update(value: Int) {
self.value = value
}
}
With this setup, if source isn’t retained as a property in Forwarder1, the subscription is deallocated prematurely, and value in Forwarder1 stops receiving updates from Source.
However, this doesn’t happen with @Published properties in Combine. Even if source isn’t retained, @Published subscriptions seem to stay active, propagating values as expected.
My Questions:
What does Combine do internally with @Published properties that prevents the subscription from being deallocated prematurely, even if the publisher source isn’t retained as a property?
Is there a recommended approach to address this in my custom property wrapper to achieve similar behavior, ensuring the subscription isn’t lost?
Any insights into Combine’s internals or suggestions on how to resolve this would be greatly appreciated. Thank you!
After pairing and having subscribed to a service, and even after having exchanged messages, the service fails after a period of time and both devices need to pair again.
Topic:
App & System Services
SubTopic:
Networking
Hi All,
I am facing one problem in my app.
That is open battery settings from my app.
It is working fine in iOS 16.0.0 and it's not working in iOS 18.6.1
is it possible to make it workable in iOS 18.6.1?
If so How to do that?
Please help me over this to resolve the problem.
Thanks,
Nguyen Quang Minh
I've tried to use AppTransaction.shared / AppTransaction.refresh() to verify that my app has been purchased from the Mac App Store.
It works when testing a release build on my Mac, using a Sandbox Apple ID.
But when I submit the app for review, the reviewer says it doesn't work. The error message returned by AppTransaction is "Unable to Complete Request", which is pretty vague.
I get the same error when I try to use a real Apple ID for testing on my machine, so I have been wondering if maybe the problem is that App Review is testing a build that doesn't accept Sandbox Apple IDs?
My app doesn't have a provisioning profile, could it be that this is the problem? As a Mac app developer, I'm not sure what provisioning profiles are good for, I thought they were only useful for iOS.
Has anybody successfully submitted a Mac app that uses AppTransaction?
Hi,
On iOS 26 beta, calls can no longer be reported by swiping left on a call.
This is unfortunately a breaking change.
I have submitted a report on this on June with Feedback Assistant: FB17893517
I hope it will get some more exposure by posting here.
After the macOS Sequoia update, my app seems to have an issue with Bluetooth communication between macOS and iOS that uses CoreBluetooth for Central-Peripheral communication.
Setup:
The iPhone (in my case: iPhone 14 Pro with iOS 18.0 (22A3354)) acts as the Central, and the Mac (in my case: 14" MacBook Pro 2023 with macOS 15.0 (24A335)) as the Peripheral.
I’ve implemented a mechanism where the Central (iPhone) sends a message to the Peripheral (Mac) every 15 seconds to keep the connection alive (Because it needs to wait for notify characteristic updates).
I never noticed this kind of issue before, but with macOS Sequoia I get it permanently.
Issue:
The connection drops unexpectedly after a period of time (sometimes 20 seconds, sometimes a few minutes) with CBErrorDomain - code 6: The connection has timed out unexpectedly.
Sample Code:
Peripheral (Mac):
ContentView (Peripheral).txt
ContentViewModel (Peripheral).txt
Central (iPhone):
ContentView (Central).txt
ContentViewModel (Central).txt
Reproduce:
I attached sample code including the Central-Sample (for iPhone) and Peripheral-Sample (for Mac).
Just run the Peripheral-Sample (after granting Bluetooth permissions).
Then run the Central-Sample and select the Mac device in the list
After selecting it should connect, discover the service & characteristic and should start writing messages to it.
After some time the func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: (any Error)?) {should get called with timed out unexpectedly error.
Could anyone please look into this issue and advise on whether there’s a known bug or any workaround? Any guidance would be greatly appreciated, as this impacts the stability of Bluetooth communication between the devices.
Thanks in advance.
Logs:
I also ran the console.app during this issue which got these errors (if this is helpful):
console_logs.txt
The Wallet Passes docs, https://developer.apple.com/documentation/walletpasses seem to be missing any information about the features coming in iOS 18, specifically the new posterEventType, new semantic tags, and how to build out the event guide for a given ticket.
WWDC24 session: https://developer.apple.com/wwdc24/10108
I created an APNs Auth Key in the Apple Developer portal and downloaded it successfully once.
Later, due to some issues, I revoked that key.
After that, I created a new APNs Auth Key.
The download button appears, but when I click it, I get the message:
"Auth Key can only be downloaded once. This auth key has already been downloaded."
This is incorrect because:
The key is newly created in my account.
I have tried multiple browsers (Safari, Chrome), private/incognito mode, and even a different laptop.
I have no other active APNs Auth Keys in my account.
Without this .p8 file, I cannot configure push notifications for my iOS app (using Firebase Cloud Messaging).
This is blocking my production release.
Has anyone else experienced this? Is there a way to reset or force a fresh APNs Auth Key when this happens?
we are seeing what appears to be an internal healthkit error appearing in our app. not sure if it's connected, but we've mostly seen it reported on devices running ios 16. even though our app's primary language is japanese, and in all reported occurrences the app was running in japanese, the error message itself appears in english. searching the error string on the web yields surprisingly few results (including only two mentions on this forum that i could find, neither of which seemed relevant). this would seem to suggest that it's coming from something deep inside healthkit, since the error message is not localized.
in all reported cases, the user had recently upgraded to a new iphone. in most cases, the problem only occurs on the new device even though everything had been working correctly prior to the upgrade. the error occurs when the app is unable to read step count data from healthkit.
we have confirmed that the app has been granted access permissions to all health data via os settings. we've also tried having the user toggling those settings off, then back on, rebooting the device, deleting and reinstalling the app, etc., to no avail.
the error message is "Unable to invalidate interval: no data source avallable."
we'd appreciate it if anyone can shed more light on this issue.
thanks!
Hi,
I'm struggling with SwiftData and the components for migration and could really use some guidance. My specific questions are
Is it possible to go from an unversioned schema to a versioned schema?
Do all @Model classes need to be converted?
Is there one VersionedSchema for the entire app that handles all models or one VersionedSchema per model?
What is the relationship, if any, between the models given to ModelContainer in a [Schema] and the models in the VersionedSchema in a [any PersistentModel.Type]
I have an app in the AppStore. I use SwiftData and have four @Models defined. I was not aware of VersionedSchema when I started, so they are unversioned. I want to update the model and am trying to convert to a VersionedSchema. I've tried various things and can't even get into the migration plan yet. All posts and tutorials that I've come across only deal with one Model, and create a VersionedSchema for that model.
I've tried to switch the one Model I want to update, as well as switching them all. Of course I get different errors depending on what configuration I try.
It seems like I should have one VersionedSchema for the app since there is the static var models: [any PersistentModel.Type] property. Yet the tutorials I've seen create a TypeNameSchemaV1 to go with the @Model TypeName.
Which is correct? An AppNameSchemaV1 which defines four models, or four TypeNameSchemaV1?
Any help will be much appreciated
Is it possible to use the Matter.xcframework without the MatterSupport extension for onboarding a Matter device to our own ecosystem(own OTBR and matter controller) for an official App Store release?
Currently, we can achieve this in developer mode by adding the Bluetooth Central Matter Client Developer mode profile (as outlined here https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/darwin.md). For an official release, what entitlements or capabilities do we need to request approval from Apple to replace the Bluetooth Central Matter Client Developer mode profile?
Thank you for your assistance.
Hi! After upgrading my Macbook Pro M1 Pro to MacOS Sequoia 15.0 when I run my python backend code i show in dock all python process as Exec Icon. Now work with backend so hard, because all my dock in this icons( How I can fix this? Support dont help me, because resinstall and e t c dont work for me.
Before updating to macOS 15 Sequoia, I used to be able to create file bookmarks with this code:
let openPanel = NSOpenPanel()
openPanel.runModal()
let url = openPanel.urls[0]
do {
let _ = try url.bookmarkData(options: [.withSecurityScope])
} catch {
print(error)
}
Now I get an error
Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key"
These are the entitlements:
com.apple.security.app-sandbox
com.apple.security.files.user-selected.read-write
com.apple.security.files.bookmarks.app-scope
Strangely, my own apps continued working, after updating to macOS 15 some days ago, until a few moments ago. Then it seems that all of a sudden my existing bookmarks couldn't be resolved anymore, and no new bookmarks could be created. What could be the problem?
I have been battling this intermittent error for some time. It is generally random and has been difficult to reproduce until yesterday when I stumbled across a way to reproduce it each time. I can cause the code to throw this error:
Task <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2103, _NSURLErrorFailingURLSessionTaskErrorKey=BackgroundDownloadTask <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"BackgroundDownloadTask <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1>",
"LocalDownloadTask <70E3909F-8C30-4F34-A8B0-4AF3B41DD81B>.<1>"
), NSLocalizedDescription=The request timed out., _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=https://redacted*, NSErrorFailingURLKey=https://redacted*}
*"redacted" is the backend URL, and it is the correct and same path for each
immediately after restarting an actual device. I have been over the following threads with no results:
What is kCFStreamErrorCodeKey=-4 (kCFStreamErrorDomainKey=4)
Request timed out with _kCFStreamErrorCodeKey=60
How to better diagnose -1001 "The request timed out." URLSession errors
Random timed out error on app start
Because I was able to reproduce it, I have been able to get the following logs:
Console Logs.txt
Last bit of information is that I had Network Instruments running, and when this error occurred, I found that the Connection ID was "No Connection" and it appears the request was never actually sent, though it waited the full time out for a backend response.
Any help would be appreciated. This data request is being used after sending a certain APNs to update necessary data in the background, and has been the source of many user complaints.
I'm encountering an issue with the App Store Server API where the appAccountToken is not preserved when users migrate their Apple ID email addresses. I've submitted
Feedback Assistant ticket FB18709241 but wanted to check if anyone else has experienced this and get community input on best practices.
The Issue
When a user migrates their Apple ID from one email to another (e.g., from olduser@example.com to newuser@icloud.com), the App Store creates a new subscription
transaction with a different originalTransactionId, but the appAccountToken is not carried forward from the original transaction.
What I'm Seeing
note: these values are fake
When querying /inApps/v1/subscriptions/{originalTransactionId} with the either post-migration transaction ID or the pre-migration transaction ID, the API returns both transactions:
Pre-migration transaction (status: 2 - inactive):
originalTransactionId: "12345678910111"
Contains: "appAccountToken": "abc123-def456-ghi789"
Post-migration transaction (status: 1 - active):
originalTransactionId: "67891011121314"
Missing: appAccountToken entirely
The Problem
The appAccountToken is our only way to link App Store subscriptions to user accounts. Without it on the new transaction:
Users lose access to premium features despite having valid subscriptions
Server-side renewal notifications can't be matched to user accounts
Manual support intervention is required for each affected user
Questions for the Community
Has anyone else encountered this issue with Apple ID migrations?
What's the recommended approach for handling this scenario?
Is there an alternative mechanism to maintain the subscription-to-user linkage across migrations?
Questions for Apple Engineers
Is this the expected behavior, or should the appAccountToken be preserved?
Are there any planned improvements to handle this migration scenario?
What's the best practice for developers to handle this case?
Interestingly, both the old and new transaction IDs return the same JSON response from the App Store Server API, suggesting Apple maintains internal linkage between
these transactions, but the appAccountToken isn't carried forward to the active transaction.
Any insights or similar experiences would be greatly appreciated!
Thank you!!
Feedback Assistant: FB18709241
Topic:
App & System Services
SubTopic:
StoreKit
Tags:
StoreKit
App Store Server Notifications
App Store Server API
Hello!
I am attempting to add Subscriptions to an App that Is already published on the App Store.
I cannot get Xcode to actually sync what is in my App Store Connect.
When adding the Storekit configuration file, I go through the automatic linking process and select the proper bundleID. The configuration file says 'Synced @ [CurrentTime]' however there are no subscriptions listed in there.
I have attempted deleting the file several times, creating a new subscription group. With no success.
Do I need to publish the subscriptions without the features first? Upon attempting to write the supporting code that will enable these features within the app, I cannot get Xcode to identify that I have these subscriptions.
I have also tried pushing these to TestFlight, still with no success.
Thank you.
I have a device. After pairing, it is shown as connected in the Bluetooth list of the mobile phone. Before iOS 18, I could retrieve the device through the retrieveConnectedPeripherals method, but after iOS 18, I cannot retrieve it. What is the reason? Because when the device is connected, it no longer sends broadcast packets. How can I retrieve the device?