We have an app that uses the Screen Time APIs to block certain apps set by the user on a schedule:
We use ManagedSettings to shield selected apps
We use DeviceActivityMonitor to shield the apps automatically on a schedule set by the user. The shielding starts during the intervalDidStart callback function and ends during the intervalDidEnd callback function
We are getting reports from the majority of our iOS 17 users that the app blocking schedules no longer work on iOS 17. We have tested this on our own iOS 17 devices and reproduced the behavior. But the feature still works consistently on iOS 16 devices.
The app is still built using Xcode 14 instead of Xcode 15 due to another issue - the DeviceActivityReport is blank for all iOS 16 users when built in Xcode 15 (link to issue on the developer forums: https://developer.apple.com/forums/thread/735915). When testing with Xcode 15 builds, the bug appears to improve - however it still occurs intermittently.
Are there any other mechanisms to run tasks on repeating schedules? For this specific feature, we don't need to eventDidReachThreshold callbacks, which is the main purpose of DeviceActivityMonitor. So we really don't need any Device Activity integration at all, just setting and disabling ManagedSettings shields at certain times. Would love if anyone could suggest and alternative to DeviceActivityMonitor.
General
RSS for tagDelve 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.
Post
Replies
Boosts
Views
Activity
If a user sets up a Shortcut to execute when the Settings app is opened, it will only trigger if the Settings app is opened from the home screen.
If, though, the user opens settings through the Control Center (e.g. by holding down on Wi-Fi and tapping "Wi-Fi Settings..."), it will open the Settings app but not trigger the Shortcut.
Is there any way to fix this?
I have a widget that has timeline entries for Monday, Tuesday, Wednesday, etc.
For example, today is Tuesday, but the widget displays the timeline entry for Monday. When I delete the Monday entry, it does display the Tuesday entry. So it's like it's selecting Monday even though today is Tuesday.
Is there a trick I'm missing?
thanks
Some websites and apps keep showing up on my screen time even though I don't use them generally. I don't even use Google Drive, but this is the one app that always shows up as 24 hour screen time.
Our app uses DeviceActivityReport to display the user’s screen time. The performance of DeviceActivityReport is often very poor. These issue occur commonly:
Screen time is reported as 0 minutes
DeviceActivityReport View appears completely blank
The host app loses connection with the DeviceActivityReport altogether
I have implemented several workarounds which only slightly improve the performance, to varying degrees depending on the device iOS:
Inside the DeviceActivityReport code - retry fetching screen time data until it returns a non-zero result
Implement a “refresh” button which reloads the DeviceActivityReport view from the host app
However, due to the sandboxed nature of DeviceActivityReport, there is no way for the host application to tell if the DeviceActivityReport extension is experiencing these performance issues. It results in a really bad user experience.
I am building the app with Xcode 14 due to another issue where DeviceActivityReport fails to load for all iOS 16 devices when built with Xcode 15 (this is a know issue, here’s a link to a discussion on the developer forums: https://developer.apple.com/forums/thread/735915). However, when testing on iOS 17 devices with Xcode 15 builds, the above issues still occur.
I have received no crash reports from DeviceActivityReport.
These issues are known bugs and have been discussed on the developer forums, but I haven't yet seen a solution. Other screen time apps exist that use the DeviceActivityReport seemingly flawlessly, so I know that there is a way to improve the performance of DeviceActivityReport in my app.
Please help! I have been dealing with this poor performance for a long time now with almost no improvement!
the following code produces this crash for about 0.5% of the users :
guard let encodedData = try? jsonEncoder.encode(project) else {
throw AutoCapError.encodeVideoProject
}
Crashed: com.apple.root.background-qos
0 libswiftCore.dylib 0x20e468 StringObject.getSharedUTF8Start() + 8
1 libswiftCore.dylib 0x20e498 StringObject.sharedUTF8.getter + 24
2 Foundation 0x259698 specialized String.withUTF8(:) + 1348
3 Foundation 0x25986c JSONWriter.serializeString(:) + 100
4 Foundation 0x44648 JSONWriter.serializeJSON(:depth:) + 92
5 Foundation 0x44d68 JSONWriter.serializeObject(:depth:) + 1344
6 Foundation 0x4474c JSONWriter.serializeJSON(:depth:) + 352
7 Foundation 0x44d68 JSONWriter.serializeObject(:depth:) + 1344
8 Foundation 0x460a8 JSONWriter.serializeArray(:depth:) + 892
9 Foundation 0x44718 JSONWriter.serializeJSON(:depth:) + 300
10 Foundation 0x44d68 JSONWriter.serializeObject(:depth:) + 1344
11 Foundation 0x460a8 JSONWriter.serializeArray(:depth:) + 892
12 Foundation 0x44718 JSONWriter.serializeJSON(:depth:) + 300
13 Foundation 0x44d68 JSONWriter.serializeObject(:depth:) + 1344
14 Foundation 0x4474c JSONWriter.serializeJSON(:depth:) + 352
15 Foundation 0x43ce8 JSONEncoder.encode(:value:) + 608
16 Foundation 0x43a7c JSONEncoder.encode(:) + 64
17 Foundation 0x43a34 dispatch thunk of JSONEncoder.encode(_:) + 56
the crash started since the iOS 17 (worked before)
the project Object is has many String fields and it mostly crashes on none english languages,
Why isn't the try catches the crash?
what might be causing it?
fool crash report is attached
laika.autocap_issue_b2c4b37d2bb22ddab10152c2bb743fbc_crash_session_cb8d05d0956f4bf38de34d313bb64067_DNE_0_v2_stacktrace.txt
I've created a barebones Multiplatform app and added an App Intent and App Shortcut. When running on iOS, I can see my app show up in Shortcuts and use the intent or App Shortcut as normal. On macOS, my app does not appear in the Shortcuts app, neither the App Shortcut nor the intent.
Is there additional configuration required to enable Shortcuts / App Intents on macOS?
This is the only code I've added to a brand-new Xcode Multiplatform project:
import AppIntents
struct OpenIntent: AppIntent {
static let title: LocalizedStringResource = "Open MacShortcut"
static let description: LocalizedStringResource = "Opens the app"
/// Launch your app when the system triggers this intent.
static let openAppWhenRun: Bool = true
/// Define the method that the system calls when it triggers this event.
@MainActor
func perform() async throws -> some IntentResult {
/// Return an empty result since we're opening the app
return .result()
}
}
struct MacShortcutShortcutsProvider: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: OpenIntent(),
phrases: [
"Open a session of \(.applicationName)"
],
shortTitle: "Open",
systemImageName: "arrow.up.circle.fill"
)
}
}
Like the image showing, the element 'Ask ChatGPT' attaches below siri search suggestion , I guess SiriKit or Spotlight can implement it.
But i searched a lot, no one introduct the detail technology.
Do anyone ever implement it?
Please help me. Thanks.
I have a requirement where I have enabled the widget for my app but I don't want to show it to some specific user. And on click of any button on my app, I can enable the widget for that user.
Basically I can pass the value to supportedFamilies(_:) on runtime?
Any help will be appreciated
After updating our app some of our users are seeing that their widget has gone blank, the whole widget it just white. The only way to make the widget render again is to reboot the phone. This seems to be happening randomly and mainly on iOS17.
Looking on the web, seems like other people are also having this issue so hopefully Apple will make a fix at some point but I'm wondering if other people have had this issue and figured out a workaround to stop it happening?
Thanks.
I have a button in my iOS app that opens the Settings app to my app's Notification permissions section. I use UIApplicationOpenSettingsURLString for this (or UIApplicationOpenNotificationSettingsURLString on iOS 15.4 and later). On Catalyst, both of these simply open the settings screen that is auto-generated from the Settings bundle.
How do I get it to open to the appropriate place in System Settings?
I have Rectangular, Circular and Inline and home screen widgets in my application.
After updating to iOS 17.2 , only blank screen is seen in place of widgets.
Any suggestions or finding would be helpful to resolve this issue.
A case occured where the Structure Builder is crashing with EXC_BAD_ACCESS and the error cannot be handled without the app crashing.
I have two minimalistic models, one even reduced to the minimum of the "coreModel" itself. (See attachment)
Each model alone in the StructureBuilder works fine.
Using both causes the crash.
Has anyone found a way to handle this error without the app crashing?
override func viewDidLoad() {
super.viewDidLoad()
let capturedRooms: [CapturedRoom] = [
loadCapturedRoom(fileName: "appleModel1"),
loadCapturedRoom(fileName: "appleModel2")
]
buildStructure(capturedRooms)
}
func buildStructure(_ capturedRooms: [CapturedRoom]) {
let structureBuilder = StructureBuilder(options: [])
Task {
print("----- START BUILDING STRUCTURE -----")
do {
let capturedStructure = try await structureBuilder.capturedStructure(from: capturedRooms)
} catch {
print("----- FAILED BUILDING STRUCTURE -----")
}
// Crashing with: EXC_BAD_ACCESS
// This part will never be reached
print("----- FINISH BUILDING STRUCTURE -----")
}
}
func loadCapturedRoom(fileName: String) -> CapturedRoom {
do {
guard let jsonFileURL = Bundle.main.url(forResource: fileName, withExtension: "json") else {
fatalError("JSON file not found.")
}
let data = try Data(contentsOf: jsonFileURL)
return try JSONDecoder().decode(CapturedRoom.self, from: data)
} catch {
fatalError(error.localizedDescription)
}
}
appleModel1.json
appleModel2.json
The iPhone Target Build Phase for my Apple Watch companion app specifies the source of the Product to embed as: build/Debug-watchos, however,
the Watch build is located at build/Debug-watchsimulator.
I am receiving an error from Xcode when trying to install the Apple Watch app in the watch simulator, as follows: An application bundle was not found at the provided path. Provide a valid path to the desired application bundle.
Failed to install the requested application
Domain: NSPOSIXErrorDomain
Code: 2
Failure Reason: An application bundle was not found at the provided path.
Recovery Suggestion: Provide a valid path to the desired application bundle.
I have tried deleting the Watch target and re-adding the target but the misconfiguration remains. I have also tried adding my own Copy Build Phase but when selecting the Product for the Apple Watch companion app the same incorrect folder is used. Any ideas?
Hi,
Recently I bought 2 HomePod minis and placed them in my kitchen and bathroom. I have noticed that they keep their alarms/reminders device-local and take priority over any other device.
For example I can hold up my phone, say something like "hey siri set alarm for 7am" and the kitchen echo will respond something like "none of your devices can do that" (obviously sound quality suffered from distance) or worse, it sets an alarm on the device not my phone, waking everyone in the household not just me.
Another annoying habit it has is to set a reminder on one device, then later I say something like "cancel my reminders", accidentally the other HomePod picks it up, says something like "I cancelled all your reminders" then a few minutes later the first HomePod will still remind me - so it's not even shared across HomePods.
Setting wake-up alarms gotten so bad and complicated (walk out of a room, whisper to the phone directly) I had to disable both HomePods from listening to "siri". Now all they are is expensive decoration (except when once a week we listen to some music on it).
Is there no way to make HomePods not to be the highest priority devices and use alarms/reminders from the phone (like it does with shopping lists)? This annoying experience I would expect from MS and Alexa maybe, but not Apple.
I tried to archive a NSDictionary with a NSColor :
data = [NSKeyedArchiver archivedDataWithRootObject: <vrRoot> requiringSecureCoding:YES error:&error];
and I get this error :
Printing description of error:
Error Domain=NSCocoaErrorDomain Code=4864 "value for key 'NS.objects' was of unexpected class 'NSColor' (0x7ff8465d0d88) [/System/Library/Frameworks/AppKit.framework].
Allowed classes are:
{(
"'NSMutableDictionary' (0x7ff8465f9b48) [/System/Library/Frameworks/CoreFoundation.framework]"
)}" UserInfo={NSDebugDescription=value for key 'NS.objects' was of unexpected class 'NSColor' (0x7ff8465d0d88) [/System/Library/Frameworks/AppKit.framework].
Allowed classes are:
{(
"'NSMutableDictionary' (0x7ff8465f9b48) [/System/Library/Frameworks/CoreFoundation.framework]"
)}}
Then I transferred NSColor to NSArray - but the error was the same.
I want data save in Core Data, please help me ♡.
Hello,
I am having an issue with my request response only containing a partial response body despite the request having a 200 http response status.
When I print out the raw response without parsing it to JSON I can see that the content is truncated (leading to an invalid JSON).
I am unable to reproduce the same issue on Postman, so this seems to be isolated to my ios app (I have had the same issue with the endpoint in React Native as well).
Any tips or suggestions would be appreciated!
(Excuse the code, learning swift as I go)
class Fetcher<T, G>: ObservableObject where T: Decodable, G: Codable {
@Published var data: T? = nil
@Published var isLoading: Bool = false
public var path: [String] { return [] }
func fetchData(body: G) async
throws {
Task { @MainActor in
isLoading = true
}
var url = NetworkManager.shared.baseUrl;
for p in path {
url = url.appending(path: p)
}
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONEncoder().encode(body)
// TODO: This should be handled with auth challenges
if let token = NetworkManager.shared.token {
request.setValue(token, forHTTPHeaderField: "Authorization");
}
// Set timezone header
request.setValue(TimeZone.current.identifier, forHTTPHeaderField: "TIMEZONE");
let (respData, response) = try await NetworkManager.shared.session.data(for: request)
let json = String(data: respData, encoding: String.Encoding.utf8)
if let token = (response as? HTTPURLResponse)?.value(forHTTPHeaderField: "Authorization") {
NetworkManager.shared.token = token
}
guard (response as? HTTPURLResponse)?.statusCode == 200 else {
Task { @MainActor in
isLoading = false
}
throw FetchError.badRequest
}
let temp = try JSONDecoder().decode(T.self, from: respData)
Task { @MainActor in
data = temp
isLoading = false
}
}
}
class NetworkManager{
static let shared = NetworkManager(baseUrl: "https://my-api-url.com");
let baseUrl: URL
let session: URLSession
var token: String?
private init(baseUrl: String) {
// TODO: Throw well defined error
self.baseUrl = URL(string: baseUrl)!
let configuration = URLSessionConfiguration.default
self.session = URLSession(configuration: configuration)
}
}
For locations in timezones East of me the returned results start at yesterday, Today is Saturday, the results start at Friday. Sometimes results can start 2 gays ago. Locations in my timezone and those west do not behave this way; the results start at Saturday.
I'm doing the most basic request:
self.weather = try await weatherService.weather(for: CLLocation(latitude: location.latitude, longitude: location.longitude) )
My understanding this returns 10-days of forecast.
What is going on?
I need to know if the results are appropriate for the days returned. IE. Is today's forecast for tomorrow, today or yesterday?
Any guidance is appreciated.
Kirk Mahr
As can be seen here, all categories are expanded but nothing under them:
Not sure if related, but when I tried to upload my app for internal TestFlight testing I got following error:
The code looks like this:
@ObservedObject var model : MyModel
@State var isPresented = false
var body: some View {
Button("select apps to discourage"){
isPresented = true
}.onAppear {
Task {
do {
try await AuthorizationCenter.shared.requestAuthorization(for: .child)
} catch {
}
}
}.familyActivityPicker(isPresented: $isPresented, selection: $model.selectionToDiscourage)
}
}
Now I am wondering, is there one more thing that I need to do before familyActivityPicker would work?
Here is what I have done: I subscribed to $99 Apple developer plan, Then I was finally able to see and add Family Controls capability under my Xcode project, Then I created Apple Family and logged in iphone (and simulator) as child. Then several days ago I submitted this form - https://developer.apple.com/contact/request/family-controls-distribution (not sure if this was mandatory for internal testing, but I have not received any communication from Apple - even confirmation for my request).
Hello all, I'm porting my existing app to catalyst with optimized for mac option. However, I noticed the app will sometimes restore previous open windows if I previously kill it in Xcode. However, these restored windows are also just showing the app entry content instead of restoring the previous scene content. Question, is there anyway to disable this restore scene behavior? Thanks!