Task:
A child view should show depending on a boolean flag the corresponding view. The flag is calculated from a model which is given by parent view.
Problem:
The flag is false in init, which is correct. However in body it's true, which is incorrect. Why value in body isn't consistent to init? Is there a race condition? The child view's is rendered thrice, that's another issue, but flag is in init and body as described before.
Parent view looks like this:
struct ParentView: View {
private var groupedItems: [GroupedItems] = []
init(items: [Item]) {
Dictionary(grouping: items) { $0.category.name }
.forEach {
let groupedItems = GroupedItems(categoryName: $0.key, items: $0.value)
self.groupedItems.append(groupedItems)
}
}
var body: some View {
ChildView(groupedItems)
}
}
Child view looks like this:
struct ChildView: View {
@State private var showItems: Bool
init(_ groupedItems: GroupedItems) {
self._showItems = State(initialValue: !groupedItems.completed)
}
var body: some View {
if showItems {
AView()
} else {
BView()
}
}
}
Model looks like this:
@Model
final class Item: Identifiable {
@Attribute(.unique) public var id: String
public var name: String
public var completed = false
}
struct GroupedItems {
var categoryName: String
var items: [Item]
var completed: Bool {
items.filter { !$0.completed }.isEmpty
}
}
Posts under iOS tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I am seeing some unexpected behavior, in particular, is seems that iOS is periodically foregrounding my test app with no user intervention. I am curious why this is.
I wrote a simple test app to see how long the app would run to collect location while in the background with only "While in Use" location permission. The app will start location updates when foregrounded and continue in the background. While backgrounded, I see the blue arrow in the dynamic island as expected. What is unexpected is that every few days, I see the UI of the app displayed in the foreground, without having foregrounded it myself (and no, I did not tap the blue arrow).
This is using the legacy CoreLocation apis on iOS 17.5.1.
My question is how/why does this happen?
Ever since I installed iOS 18 beta my phone says it’s not in a new location even though I’m at home.. has anybody run across this problem?
Hello,
I have developed an update for my app where I handle push notifications (from APNs or FCM) and manage different notification categories using checks, storing the values in UserDefaults. So far, everything works fine, and the logs correctly indicate the state of each category when a notification is received.
The issue arises when handling notifications in three states: foreground, background, and terminated (killed). I am using UNNotificationServiceExtension and in the didReceive method, I check the state of the notification. Depending on whether the state is true or false, I want the notification to be shown or not to the user. However, despite my efforts, the alert/notification part of the payload always ends up being displayed.
Additionally, I have disabled serviceExtensionTimeWillExpire as it was being triggered, but still, after a few seconds, the notification ends up appearing.
I have configured everything correctly, including mutable content, notification handling, etc. How can I prevent these notifications from being shown to the user when needed?
Thank you for your assistance!
Upon taking a photo using the rear camera of my iPhone 14 Pro Max, I observed severe picture distortion. This issue severely undermines the functionality and reliability of the iPhone camera, raising serious concerns about its usability and trustworthiness.
My app has been approved for four days now, but the subscription items are still "Waiting for review". Online users cannot make purchases. I have already contacted Apple's technical support via email and phone, but it seems to have no effect. What should I do?
Hi all, I am developing new things on my existing .Net core application. I want to create a new page and with this page, the users will create a new app and write important informations. But I cant create a new app with sending post request with connect API. Here is my Postman requests and body.
Sending request to :
https://api.appstoreconnect.apple.com/v1/apps
Body :
{
"data": {
"type": "apps",
"attributes": {
"bundleId": "com.test.testtest",
"name": "Test Test",
"primaryLocale": "en-US",
"sku": "test2024",
"platform": "IOS"
}
}
}
Also I am using a bearer token, and this token has a admin role. When I send a post request, I am getting below error.
{
"errors": [
{
"id": "35f9631f-b8d8-408c-8dfd-adaef043d062",
"status": "403",
"code": "FORBIDDEN_ERROR",
"title": "The given operation is not allowed",
"detail": "The resource 'apps' does not allow 'CREATE'. Allowed operations are: GET_COLLECTION, GET_INSTANCE, UPDATE"
}
]
}
How can I fix this. Pls help.
Thanks.
I want to use syscall to call SYS_recvmsg_x for udp socket program, can I do that?
Hey,
I have a setup in my app that I am currently building, that uses @Observable router objects that hold the app's entire navigation state, so that I can easily set it globally and let SwiftUI show the appropriate views accordingly. Each view gets passed in such a router object and there is a global "app" router that the app's root view can access as an entry point:
@Observable @MainActor
final class AppRouter {
static let shared = AppRouter() // Entry point used by the app's root view
var isShowingSheet = false // Navigation state
let sheetRouter = SheetRouter() // Router that's passed to the sheet view. This router could contain other routers for sheets it will show, and so on
}
@Observable @MainActor
final class SheetRouter { // Example of a "nested" router for a sheet view
var path = NavigationPath()
var isShowingOtherSheet = false
func reset() {
path = .init()
isShowingOtherSheet = false
}
}
To open a sheet, I have a button like this:
@Bindable var appRouter = AppRouter.shared
// ...
Button("Present") {
appRouter.sheetRouter.reset() // Reset sheet router
appRouter.isShowingSheet = true // show sheet
}
This seems to work perfectly fine. However, this produces tons of "error" logs in the console, whenever I open the sheet for a second time:
Mutating observable property \SheetRouter.path after view is torn down has no effect.
Mutating observable property \SheetRouter.path after view is torn down has no effect.
Mutating observable property \SheetRouter.path after view is torn down has no effect.
Mutating observable property \SheetRouter.path after view is torn down has no effect.
Mutating observable property \SheetRouter.isShowingOtherSheet after view is torn down has no effect.
These errors appear when calling the reset() of the sheet view's router before opening the sheet. That method simply resets all navigation states in a router back to their defaults. It's as if the sheetRouter is still connected to the dismissed view from the previous sheet, causing a mutation to trigger these error logs.
Am I misusing SwiftUI here or is that a bug? It's also worth mentioning that these error logs do not appear on iOS 17. Only on iOS 18. So it might be a bug but I just want to make sure my usage of these router objects is okay and not a misuse of the SwiftUI API that the runtime previously simply did not catch/notice. Then I'd have to rewrite my entire navigation logic.
I do have an example project to demonstrate the issue. You can find it here: https://github.com/SwiftedMind/PresentationBugDemo.
I have also filed a feedback for this: FB14162780
STEPS TO REPRODUCE
Open the example project.
Open the sheet in the ContentView twice by tapping "Present"
Close that sheet
Open it again.
Then the console will show these error logs from above.
I'd appreciate any help with this.
Cheers
Tested on: iPhone11+iOS16.5/iPhoneXS+iOS15.4.
Compile with: XCode12/13/14.
I tried following code, compile with arch=arm64e only, and result in crash "EXC_BAD_ACCESS". at "LDRAA"
std::cout << "";
The crash will not be triggered if:
compile with arch=arm64 only
compile with arch=arm64e only and tested on iOS<=14
not use any c++ I/O api
I was taking some photos of the Milky Way while using a tripod and the stars seemed to not be in focus. I tried plenty of times to get stars in focus. I switched to other apps that have a manual focus and the problem was resolved however the results weren’t as clear as the standard app would have been. I then tried again with the standard app but while focusing on an outdoor camera on our house and yet the camera would still not focus no matter how much I tried. I’m not sure if it is a bug with the iOS 18 developer beta. Either way I figured it was best to post something I had realized. Apple please add a manual focus option.
Where and how do I find the iOS 18 beta update. I got a 15 Pro max
See FB13917278 (App Becomes Unresponsive for iOS/iPadOS 18 Regular Size Class Interactions When Selecting One Particular View in Sidebar).
我在更新到iOS 18 Beta 2时遇到了以下问题。我遇到了严重的系统错误,所以我选择通过iCloud备份我的iPhone,然后擦除并重置iPhone,最后从iCloud恢复数据。然而,我现在面临一个严重的问题:我在开发人员应用程序中登录了我的帐户,但我在设置中看不到测试版的更新部分。我怎样才能解决这个问题?
Hi all,
I have an iOS app which uses CloudKit and the standard NSPersistentCloudKitContainer, which I rely on for syncing app data between the user's devices. If the user's iCloud account is full I can see a log message while debugging in Xcode shortly after startup which looks something like this:
error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2183): <NSCloudKitMirroringDelegate: 0x281ddc1e0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringExportRequest: 0x2841e00f0> 51383346-87BA-44D8-B527-A0B1EE35A0EF' due to error: <CKError 0x282c50db0: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = 7BA17495-4F05-4AF4-A463-C0DF5A823B2E; container ID = "iCloud.com.neufsters.pangram"; partial errors: {
E30B2972-FD4B-4D2A-BD1C-EB6F33F5367D:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x282c155f0: "Quota Exceeded" (25/2035); server message = "Quota exceeded"; op = FC4D3188D0A46ABC; uuid = 7BA17495-4F05-4AF4-A463-C0DF5A823B2E; Retry after 315.0 seconds>
2FC9A487-D630-444D-B7F4-27A0F3A6B46E:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x282c52820: "Quota Exceeded" (25/2035); server message = "Quota exceeded"; op = FC4D3188D0A46ABC; uuid = 7BA17495-4F05-4AF4-A463-C0DF5A823B2E; Retry after 315.0 seconds>
903DD6A0-0BD8-46C0-84FB-E89797514D9F:(com.apple.coredata.cloudkit.zone:__defaultOwner__) = <CKError 0x282c513e0: "Quota Exceeded" (25/2035); server message = "Quota exceeded"; op = FC4D3188D0A46ABC; uuid = 7BA17495-4F05-4AF4-A463-C0DF5A823B2E; Retry after 315.0 seconds>
}>
I would like to know how I can get a callback of some sort so I can run code if this CloudKit/CoreData error happens. In particular I'd like to put up some sort of warning to the user letting them know their data isn't going to sync.
Please note that I'm not looking for how to do error handling as a result of a user-initiated CloudKit API call. I'm looking for how to get notified when the background syncing logs errors like the above.
Thanks,
Russ
We are trying to analyze how many of our users have upgraded from 17.4 (which has a major issue in compatibility with our app) to 17.5 (in which the issue does not happen).
When we use the metrics in App Store Connect, the version 17.5 does not appear in the Platform version list at all.
When we look at overall sessions, we see there are about 80 today. But when we display By Platform Version, we only see 4. I surmise that we should be seeing many sessions on 17.5 but those are being hidden because of this issue.
Hello.
I want to do a fetch when a view loads. In UIKit I would have used viewDidLoad to do this but in SwiftUI we only have onAppear and task. Is that by design, and if so, what is the recommended way to fetch data?
I wrote a little blog post for a workaround describing the issue and the found solution, but I presume there is a better way.
https://www.ludafux.com/post/viewdidload_doppelganger
Best Regards,
Luda
Should I update to iOS 18 beta 2 or not please reply (my device is a iPhone 12 mini)(DONT JUDGE ME IM SMALL)
Hi, I have an app that uses a firestore database, throughout testing I had no problems. However, I released my app and it crashes all the time.when i distribute my app to testflight this will working on the 3 ios devices with same version but the app is not working on one device which have also a same version of ios. when i open the app the app will crash and not open.
Here is a crash report I have. I am struggling to find resources online on how to interpret it but no solution found, so any help would be appreciated.
Thanks so much for any help,
You can see the error here
Dear Apple Developer Support,
I am seeking information regarding the implementation of in-app updates for iOS applications. Specifically, I would like to know if there is an available SDK or method that allows users to update their apps without being redirected to the App Store. This functionality is essential for enhancing user experience and streamlining the update process within the app itself.
Thank you for your assistance.