My app has been in the App Store a few months. In that time I've added a few updates to my SwiftData schema using a MigrationPlan, and things were seemingly going ok. But then I decided to add CloudKit syncing. I needed to modify my models to be compatible. So, I added another migration stage for it, changed the properties as needed (making things optional or adding default values, etc.). In my tests, everything seemed to work smoothly updating from the previous version to the new version with CloudKit. So I released it to my users. But, that's when I started to see the crashes and error reports come in. I think I've narrowed it down to when users update from older versions of the app. I was finally able to reproduce this on my end, and Core Data is throwing an error when loading the ModelContainer saying "CloudKit integration requires that all attributes be optional, or have a default value set." Even though I did this in the latest schema. It’s like it’s trying to load CloudKit before performing the schema migration, and since it can’t, it just fails and won’t load anything. I’m kinda at a loss how to recover from this for these users other than tell them to delete their app and restart, but obviously they’ll lose their data that way. The only other idea I have is to setup some older builds on TestFlight and direct them to update to those first, then update to the newest production version and hope that solves it. Any other ideas? And what can I do to prevent this for future users who maybe reinstall the app from an older version too? There's nothing special about my code for loading the ModelContainer. Just a basic:
let container = try ModelContainer(
for: Foo.self, Bar.self,
migrationPlan: SchemaMigration.self,
configurations: ModelConfiguration(cloudKitDatabase: .automatic)
)
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
Some paid users are unable to use the paid features unlocked by purchasing our subscription plan. It seems that this is due to StoreKit 2's Transaction.currentEntitlements not working the way we would expect it to work.
Are you also encountering this issue? Do you have any idea to improve this situation?
At launch, our app checks if the user is subscribed to the plan, using Transaction.currentEntitlements. As a result, the currentEntitlements array was empty.
Our app then fetches the products from StoreKit 2 using Product.products(for:). As a result, the Product.SubscriptionInfo.RenewalState value of the corresponding Product (product.subscription.status.first.state) is subscribed, which confirms that the user has indeed purchased our plan, but seems to contradict the absence of the corresponding transaction in Transaction.currentEntitlements.
Proactive in-app purchase restore and a restore purchase button calling the AppStore.sync() method are implemented, but using the button did not solve the issue.
Hello, I have a question about sending data in QUIC DATAGRAM.
Regarding sending data in QUIC DATAGRAM, when I create a NWConnectionGroup and then use the send method of that group to send data in sequence, quite often I get an Optional(POSIXErrorCode(rawValue: 89): Operation canceled) error.
A little Thread.sleep between sends improves the situation somewhat, but the above error still occurs.
Also, since I want to send the frame data of the video in this communication process, adding a wait will drastically reduce performance and make the speed impractical.
However, if send is executed continuously without adding weights, the above error will occur 80% of the time or more.
Is it necessary to send while monitoring some status when sending?
In communication using QUIC Stream, when connecting to the server with NWConnection and sending with its send method, the above error does not occur even if send is executed without wait, and data can be transferred with good performance.
I am trying to use DATAGRAM communication to further increase throughput, but I am not having much success, and there is not much information on DATAGRAM communication.
Thank you in advance for your help.
This error occurs in Apple Pay Wallet In-App Provisioning Flow for Credit / Debit Cards
When the data received from the PNO (Visa) is passed to PKAddPaymentPassRequest this error is seen in addPaymentPassViewController, in the finalize stage.
Docs provide no clue as to what could be wrong.
iOS 18.2.1
XCode 15.2
Error description mentions "unsupportedVersionError"
Is the pass version not supported?
Is the wallet version not supported?
Is it an app implementation error or error in the data received from the PNO?
Invalid entitlement for core nfc framework. The sdk version '18.2' and min OS version '14.0' are not compatible for the entitlement 'com.apple.developer.nfc.readersession.formats' because 'NDEF is disallowed'.
Anyone knows what is the correct configuration SDK version and minimum iOS deployment target for NFC that has NDEF format?
For years our iOS apps have experienced a networking problem, which blocks them connecting to our servers via their API endpoint domains.
How can we recover after the scenario described below?
Using 3rd party error logging solutions, which have different endpoint domains, we can record the error:
NSUnderlyingError": Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9816, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9816, _NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: pdp_ip0[lte], ipv4, dns, expensive, uses cell}, "_NSURLErrorFailingURLSessionTaskErrorKey": LocalDataTask <DEDBFA4D-810D-4438-A6A0-95E3B9668B9E>.<308>, "_kCFStreamErrorDomainKey": 3, "_NSURLErrorRelatedURLSessionTaskErrorKey": <__NSSingleObjectArrayI 0x301f82e60>(
LocalDataTask <DEDBFA4D-810D-4438-A6A0-95E3B9668B9E>.<308>
)
"NSLocalizedDescription": An SSL error has occurred and a secure connection to the server cannot be made., "NSLocalizedRecoverySuggestion": Would you like to connect to the server anyway?
-9816 is the "server closed session with no notification" error based on comments in CoreFoundation source files. Subsequent API endpoint calls to the same domain return the same error.
The SSL error occurs most prevalently after a server outage. However, despite our best efforts, we have been unable to replicate triggering the problem for development purposes via experiments with our server.
When the error occurs the users report that:
Fully closing (i.e. not just sending to background) and reopening the app does NOT clear connectivity to our server being blocked.
Problem seems more prevalent when using mobile/cell data.
Switching from mobile/cell data to WIFI resolves the connection problem and then switching back to mobile/cell data shows the problem again. So the underlying problem is not cleared.
All other apps on the same device and mobile/cell data or WIFI connection, like Safari, have no problems connecting to the Internet.
Deleting and reinstalling, or updating (when an update is available) resolves the problem.
Or after waiting a few days the problem seems to resolve itself.
The last two point above suggest that something is persisted/cached in the app preventing it from connecting properly with subsequent network attempts.
Notes:
We have one shared instance of the URLSession in the app for its networking because we are aware of the perils of multiple URLSession instances.
We recently added conditions to call the URLSession await reset() method when detecting the SLL errors before repeating the request. It is debatable whether this reduces the problem as we still see logged cases with the subsequent requests hitting the same -9816 error.
URLSession configuration:
let config = URLSessionConfiguration.default
config.timeoutIntervalForResource = 22
config.timeoutIntervalForRequest = 20
config.requestCachePolicy = .reloadIgnoringLocalCacheData
config.urlCache = nil
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?
macOS 15 has added a new "Local Network" permission under Security & Privacy.
I had a bug in my app that led to a crash when the user denied this permission. Now I've fixed it and would like to verify that it all works fine.
The problem is: I need to remove my app from the settings so that macOS will show the prompt again (e.g. to verify that my custom message appears correctly).
Usually, sudo tccutil reset All would do the trick. But not for this permission! The apps do not get cleared with this command.
So, there's two issues:
tccutil should remove it but doesn't.
How can I remove this settings?
Update
I had a look at the "TCC.db" (see https://www.rainforestqa.com/blog/macos-tcc-db-deep-dive), and it seems to me that the Local Network permission isn't even managed by the TCC system, as it doesn't appear in it. This is odd.
Hello,
I’m struggling to go from unversioned data model in SwiftData, to starting to version it.
Some FYI:
I’m using CloudKit
I’m using a widget, where I also pass in my data model and setup my container, this is shared over a group container/app group.
My migration is very simple, I’m adding a property which is not optional ( has default value set, and a default value in initialiser ).
Model:
@Model
class NicotineModel {
var nicotineType: NicotineType = NicotineType.snus
var startDate: Date = Date() + 30
var spendingAmount: Int = 0
var nicotinePerDay: Int = 0
var quittingMethod: QuittingMethod = QuittingMethod.coldTurkey // this is the change in the model, V1 doesn't have the quittingMethod property
var setupComplete: Bool = false
I’ve tried with:
static let migrateV1toV2 = MigrationStage.lightweight(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self
)
But also
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: nil,
didMigrate: {
context in
let nicotineModels2 = try context.fetch(FetchDescriptor<SchemaV2.NicotineModel>())
let nicotineModels = try context.fetch(FetchDescriptor<SchemaV1.NicotineModel>())
for model in nicotineModels {
let newModel = SchemaV2.NicotineModel(
nicotineType: model.nicotineType,
startDate: model.startDate,
spendingAmount: model.spendingAmount,
nicotinePerDay: model.nicotinePerDay,
setupComplete: model.setupComplete,
quittingMethod: .coldTurkey
)
context.insert(newModel)
context.delete(model)
}
try context.save()
}
)
and simply
static let migrateV1toV2 = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: nil,
didMigrate: { context in
let nicotineModels = try context.fetch(FetchDescriptor<SchemaV2.NicotineModel>())
for model in nicotineModels {
model.quittingMethod = .coldTurkey
}
try context.save()
}
)
This gives me the error on startup
SwiftData/ModelCoders.swift:1762: Fatal error: Passed nil for a non-optional keypath \NicotineModel.quittingMethod
On https://icloud.developer.apple.com I can see that the record doesn't include my quittingMethod.
I'm loosing my mind, what am I doing wrong?
I've been trying to setup a successful migration, but it keeps failing with this error:
NSCloudKitMirroringDelegate are not reusable and should have a lifecycle tied to a given instance of NSPersistentStore.
I can't find any information about this online. I added breakpoints throughout the code in willMigrate, and it originally failed on this line:
try? context.save()
I removed that, and it still failed. After I reload the app, it doesn't run the migration again and the app loads successfully. I figured since it crashed, it would keep trying, but I guess not. Here's how my migration is setup.
enum MigrationV1ToV2: SchemaMigrationPlan {
static var schemas: [any VersionedSchema.Type] {
[SchemaV1.self, SchemaV2.self]
}
static var stages: [MigrationStage] {
[stage]
}
static let stage = MigrationStage.custom(
fromVersion: SchemaV1.self,
toVersion: SchemaV2.self,
willMigrate: { context in
// Get cycles
let cycles = try? context.fetch(FetchDescriptor<SchemaV1.Cycle>())
if let cycles {
for cycle in cycles {
// Create new recurring objects based on what's in the cycle
for income in cycle.income {
let recurring = SchemaV2.Recurring(name: income.name, frequency: income.frequency, kind: .income)
recurring.addAmount(.init(date: cycle.startDate, amount: income.amount))
context.insert(recurring)
}
for expense in cycle.expenses {
let recurring = SchemaV2.Recurring(name: expense.name, frequency: expense.frequency, kind: .expense)
recurring.addAmount(.init(date: cycle.startDate, amount: expense.amount))
context.insert(recurring)
}
for savings in cycle.savings {
let recurring = SchemaV2.Recurring(name: savings.name, frequency: savings.frequency, kind: .savings)
recurring.addAmount(.init(date: cycle.startDate, amount: savings.amount))
context.insert(recurring)
}
for investment in cycle.investments {
let recurring = SchemaV2.Recurring(name: investment.name, frequency: investment.frequency, kind: .investment)
recurring.addAmount(.init(date: cycle.startDate, amount: investment.amount))
context.insert(recurring)
}
}
//try? context.save()
} else {
print("The cycles were not able to be fetched.")
}
},
didMigrate: { context in
// Get new recurring objects
let newRecurring = try? context.fetch(FetchDescriptor<SchemaV2.Recurring>())
if let newRecurring {
for recurring in newRecurring {
// Get all recurring with the same name and kind
let sameName = newRecurring.filter({ $0.name == recurring.name && $0.kind == recurring.kind })
// Add amount history to recurring object, and then remove matching
for match in sameName {
recurring.amountHistory.append(contentsOf: match.amountHistory)
context.delete(match)
}
}
//try? context.save()
} else {
print("The new recurring objects could not be fetched.")
}
}
)
}
Here's is my modelContainer in the app file. There is a fatal error occurring here that's crashing the app.
var sharedModelContainer: ModelContainer = {
let schema = Schema(versionedSchema: SchemaV2.self)
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(
for: schema,
migrationPlan: MigrationV1ToV2.self,
configurations: [modelConfiguration]
)
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
Does anyone have any suggestions for this?
EDIT:
I found this error in the console that may be relevant.
BUG IN CLIENT OF CLOUDKIT: Registering a handler for a CKScheduler activity identifier that has already been registered (com.apple.coredata.cloudkit.activity.export.8F7A1261-4324-40B4-B041-886DF36FBF0A).
CloudKit setup failed because it couldn't register a handler for the export activity. There is another instance of this persistent store actively syncing with CloudKit in this process.
And here is the fatal error
Fatal error: Could not create ModelContainer: SwiftDataError(_error: SwiftData.SwiftDataError._Error.loadIssueModelContainer, _explanation: nil)
The following code works perfectly fine in iOS 17, where I can retrieve the desired dependency value through @IntentParameterDependency as expected. However, in iOS 18, addTransaction always returns nil.
struct CategoryEntityQuery: EntityStringQuery {
@Dependency
private var persistentController: PersistentController
@IntentParameterDependency<AddTransactionIntent>(
\.$categoryType
)
var addTransaction
func entities(matching string: String) async throws -> [CategoryEnitity] {
guard let addTransaction else {
return []
}
// ...
}
func entities(for identifiers: [CategoryEnitity.ID]) async throws -> [CategoryEnitity] {
guard let addTransaction else {
return []
}
// ...
}
func suggestedEntities() async throws -> [CategoryEnitity] {
guard let addTransaction else {
return []
}
// ...
}
}
Has anyone else encountered the same issue? Any insights or potential workarounds would be greatly appreciated.
iOS: 18.0 (22A3354)
Xcode 16.0 (16A242d)
We are currently experiencing a very interesting issue when accessing the location in the background with CLLocationManager.
The user has given our app the "whenInUse" permission for locations and in most cases the app provides location updates even when it's in the background.
However, when we started to use other navigation apps in the foreground we saw that the func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) method was called with (kCLErrorDomain error 1.).
The user hasn't changed the location permission and we saw that locations were delivered once the user opened the app again.
I don't see anything in the documentation explaining this issue, but I chatted with other developers that confirm that specific behavior.
Am I missing something here?
I have a strange crash which I have problems understanding. It only happens on a few devices, after a ModelContainer migration, and it doesn't seem to crash on the migration itself.
The fetch is done in onAppear, and shouldn't necessarily result in a crash, as it is an optional try:
let request = FetchDescriptor<Rifle>()
let data = try? modelContext.fetch(request)
if let data, !data.isEmpty {
rifle = data.first(where: { $0.uuid.uuidString == settings.selectedRifleId }) ?? data.first!
}
When I get logs from users, there seems to be an error in encoding?
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018e8bfd78
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [71687]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libswiftCore.dylib 0x18e8bfd78 _assertionFailure(_:_:file:line:flags:) + 264
1 SwiftData 0x24e18b480 0x24e14c000 + 259200
2 SwiftData 0x24e193968 0x24e14c000 + 293224
3 SwiftData 0x24e195a78 0x24e14c000 + 301688
4 libswiftCore.dylib 0x18e8e4084 _KeyedEncodingContainerBox.encodeNil<A>(forKey:) + 352
5 libswiftCore.dylib 0x18e8d79f0 KeyedEncodingContainer.encodeNil(forKey:) + 64
6 SwiftData 0x24e19f09c 0x24e14c000 + 340124
7 SwiftData 0x24e1a3dec 0x24e14c000 + 359916
8 libswiftCore.dylib 0x18ec10be8 dispatch thunk of Encodable.encode(to:) + 32
9 SwiftData 0x24e1cd500 0x24e14c000 + 529664
10 SwiftData 0x24e1cd0c8 0x24e14c000 + 528584
11 SwiftData 0x24e1da960 0x24e14c000 + 584032
12 SwiftData 0x24e1ee2ec 0x24e14c000 + 664300
13 SwiftData 0x24e1d97d8 0x24e14c000 + 579544
14 SwiftData 0x24e1eada0 0x24e14c000 + 650656
15 SwiftData 0x24e1d989c 0x24e14c000 + 579740
16 SwiftData 0x24e1eee78 0x24e14c000 + 667256
17 Impact 0x1027403bc 0x10268c000 + 738236
I recently encountered an issue with Xcode 16.2 while attempting to integrate Settings.bundle into a new app. I added Settings.bundle as a new file (using the provided template), but when I ran the app (the default "Hello World" project), the expected three default controls (Name, Enabled, Slider) did not appear in the app's settings.
To troubleshoot, I downgraded my system to macOS Sonoma 14.7.2 and Xcode 15.4 (on a 2023 Mac Mini, M2). After this downgrade, everything worked as expected. With a new project, adding Settings.bundle, and running the app, the settings entry for the app appeared, including the three default fields.
This behavior suggests a potential issue or incompatibility with Xcode 16.2.
I’m testing an auto-renewable subscription on TestFlight. Now the user can't re-purchase the same product – Apple just restores the old (expired) one, and no payment sheet appears.
How can I let the same TestFlight user re-subscribe to an expired product?
Do I have to create a new productId for every test cycle?
I have an iPhone 14 Pro. I downloaded the iOS 26 beta and had a SERIOUS error, rendering the phone unusable.
I charged it to 60% and kept it plugged in while updating.
While updating, I restarted several times at the Apple logo, then at the Welcome screen, and it had quite a few bugs with low battery warnings.
When I turned it on, I noticed I had 1% (I thought it was strange).
When it was plugged in, it wouldn't charge; it only had 1% left, and it also restarted every 2 minutes. Off-plugged, it did exactly the same thing.
In the end, I had to go back to iOS 18.5; I had no problems with this version.
Hi Apple Support,
I am encountering an issue while testing in-app purchases in the sandbox environment.
I have created a sandbox tester account
Logged out of the App Store and System Settings on my Mac.
My main developer account is signed in under Sign In & Capabilities in Xcode.
The Bundle ID matches the one configured in App Store Connect.
The Product ID I am querying also matches the configuration.
Deleting the app and reinstalling.
Restarting my Mac.
When running my code in debug mode, I observe the following:
Running debug build
App Store environment: Production
[1b294b55] Error updating Storefront: Error Domain=StoreKit_Shared.StoreKitInternalError Code=7 "(null)"
Valid products: []
Invalid product IDs: ["com.x.x.x.monthly"]
No products found
The Product ID (com.x.x.x.monthly) matches the one I have configured in App Store Connect.
The bundle id matches.
When I create a StoreKit Configuration file in Xcode and sync it with my app, I can see the product IDs correctly.
Below are the relevant code snippets for fetching and handling products:
func fetchProducts() {
guard !productIDs.isEmpty else {
print("No product IDs configured")
return
}
let request = SKProductsRequest(productIdentifiers: productIDs)
request.delegate = self
print("Starting product request...")
request.start()
}
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
DispatchQueue.main.async {
print("Valid products: \(response.products)")
print("Invalid product IDs: \(response.invalidProductIdentifiers)")
self.products = response.products
if self.products.isEmpty {
print("No products found")
} else {
print("products not empty")
for product in self.products {
print("Fetched product: \(product.localizedTitle) - \(product.priceLocale.currencySymbol ?? "")\(product.price)")
}
}
}
}
func debugStoreSetup() {
if let receiptURL = Bundle.main.appStoreReceiptURL {
if receiptURL.lastPathComponent == "sandboxReceipt" {
print("App Store environment: Sandbox")
} else {
print("App Store environment: Production")
}
} else {
print("No receipt found")
}
}
Could you help identify why my app is not recognizing the Product ID in the sandbox environment?
Thank you for your assistance.
We’ve noticed that in iOS 18, the "Deactivate Configuration" button within the Per-App VPN settings immediately disables the VPN for selected apps without any confirmation prompt. This can be problematic for users, as there is no warning or verification before the action is taken, which may lead to unintended disruptions in VPN connectivity.
We haven’t found any relevant documentation on Apple’s developer website addressing this behavior.
Any insights or suggestions would be greatly appreciated and if we can have documentation to disable this button using MDM profile it will be great
I have 6 Mac App Store apps. They're all upfront paid, with no IAP, and they've all used the same on-device Mac App Store receipt validation code for years, which returns 173 in main() if there's not a valid receipt. Incidentally, the apps are entirely Objective-C.
I've just learned that if I compile an app with Xcode 16 and the macOS 15 SDK, I get the alert "exit(173) Not Available" when the app returns 173 on macOS 15 Sequoia. The rest of the alert text says, "The exit(173) API is no longer available. You can use Transaction.all or AppTransaction.shared to verify in-app purchases instead."
I have several questions:
Why was this done?
Where is this behavior change documented?
What are my options, given the above description of my apps?
We are preparing to address the upcoming change to the Certification Authority (CA) for the Apple Push Notification service (APNs). We have a few questions regarding the necessary measures.
Is the change of the Certificate Authority (CA) related to APNs something that needs to be handled on the server that sends push messages?
In relation to the CA change, do we need to reissue the APNs certificate?
If we handle the CA change on the server side and the new CA certificate already exists there, is there no need to make any further changes?
If the server’s trust store already includes the new CA certificate, it seems that no additional changes are needed. Is it possible to verify right now that everything will function correctly?
Topic:
App & System Services
SubTopic:
Notifications