Post

Replies

Boosts

Views

Activity

OSLog: anyway to get unified/combined logging from app and app extensions?
I've got a complex app extension and I'd like to be able to combine the logging from the app and the extension into a single file (for extraction/uploading etc.) I experimented adding the following code to both the app and the extension i.e. using the same subsystem for both app and extension logging. let subsystem = "mySubsystem" let logger = Logger(subsystem: subsystem, category: "main") logger.info("Log from within extension") // the version in the app says Log from within app do { let logStore = try OSLogStore(scope: .currentProcessIdentifier) let oneHourAgo = logStore.position(date: Date().addingTimeInterval(-3600)) let allEntries = try logStore.getEntries(at: oneHourAgo) let filtered = allEntries .compactMap { $0 as? OSLogEntryLog } .filter { $0.subsystem == subsystem } } The filtered content only contains logging from either the app or the extension. I suppose the issue might be the use of .currentProcessIdentifier as the scope, however that's the only scope that is defined. Is what is being attempted here possible? Is there any way to write to and extract a unified log for an app and app extension? If not, how about adding it, surely this would be something useful for people to be able to do
1
0
697
Aug ’23
Xcode 15.0 Beta 6 is unusable due to hanging installation and attaching phases
The previous betas have all been ok, but beta 6 is for me totally and utterly unusable because it keeps hanging forever during the installation and attaching phases when trying to run an app (attached physically via cable, not bluetooth). The first time or two of making a code change, then running, its ok, but then its guaranteed to hang eventually, it gets stuck on the "Installing app to iPhone" phase. If I restart the phone and try again it might get past that, but then it just gets stuck on "Waiting to attach to app on iPhone" phase. I know its beta software and not expected to be perfect, but its unusable and previous beta versions are no longer available to rollback to. Has anybody encountered this before and knows of any tricks to get it to stop hanging and load/run the app? (Restarting Xcode, restarting the phone, re-building, does not fix it for me)
2
0
523
Aug ’23
Is there a way of accessing/viewing files in an iOS app's shared group location from a Mac?
My goal is to try and get a unified logging system set up where logging from an iOS app and its extensions (primarily a notification service extension) get written into one central repository. So I was planning on setting up CocoaLumberjack in the app and the extension to use the same file path/name, adding the group capability to the app and the extensions and specifying the shared group directory as the file path. By default, for an app, CocoaLumberjack writes its files to: var/mobile/Containers/Data/Application/05464D4A-20F6-4E1F-9DBC-3109C053A1E8/Library/Caches/Logs/ On a Mac using an application such as iExplorer the above file and be located and viewed and copied etc. For an extension, it writes them to: /var/mobile/Containers/Data/PluginKitPlugin/5542F5EA-EB3A-4728-B33E-4E57C1B7B3B4/Library/Caches/Logs/ Now if I configure Cocoalumberjack to instead write the logger file to the shared group directory, then that will be at: /private/var/mobile/Containers/Shared/AppGroup/6CD5AF2C-54C9-46EF-B831-997B1DD6664F/ However its not possible using iExplorer to access this location. Using a Mac connected to the iPhone, is there an app or tool etc., that will enable me to locate the log file if it's created in the above AppGroup location?
1
0
1k
Sep ’23
Is there any way of adjusting logging level dynamically at run time?
I've gone through several tutorials, and the documentation, it seems there's no way to adjust the logging level dynamically, or even at build time for that matter. i.e. there is apparently nothing that exists such as: static let logger = Logger(subsystem: subsystem(), category: category()) logger.setMinimalLevel(.Warning) logger.trace("I won't get displayed because minimal level is debug") Am I mistaken and there is something like this?
3
0
743
Sep ’23
How to reset Keychain "certificate is not trusted" error caused by VPN, without rebooting?
If I turn on (my company supplied VPN access) and then attempt to build with Xcode then that has the consequence that all the dev/distribution certificates in the keychain turn red and say "certificate is not trusted". Turning off VPN doesn't reset them back and of course re-attempting to build will fail. However if I reboot my MacBook, then the keychain is back in a good state again. However as I work remotely I constantly have to flick VPN on and off throughout the day, and having to reboot endlessly is a pain. Is there something I can do to reset the Keychain's certs to a good state without having to reboot? (and without having to delete them all and re-add them all back to the keychain).
1
0
669
Sep ’23
Is this crash due to too much logging?
I'm occasionally getting a crash (on iOS) after a hang and termination by the OS. While reproducing it and watching the Mac console I don't see any obvious cause of the issue. There shouldn't be anything synchronous and long running in the main thread. Verbose logging is turned on, is it possible too much logging is causing this (its using NSLog for the console and also echoing logging to Crashlytics.log())? If so why is it not deterministic in its reproducibility? Here's a crash stack: > Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: FRONTBOARD 2343432205 <RBSTerminateContext| domain:10 code:0x8BADF00D explanation:[application<com.appname>:3315] failed to terminate gracefully after 5.0s ProcessVisibility: Unknown ProcessState: Running WatchdogEvent: process-exit WatchdogVisibility: Background WatchdogCPUStatistics: ( "Elapsed total CPU time (seconds): 4.260 (user 2.150, system 2.110), 11% CPU", "Elapsed application CPU time (seconds): 0.022, 0% CPU" ) reportType:CrashLog maxTerminationResistance:Interactive> Triggered by Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x1dd27b7dc __ulock_wait + 8 1 libsystem_platform.dylib 0x1fe05efb0 _os_unfair_lock_lock_slow + 176 2 CoreFoundation 0x19e3a6648 _logToStderr + 148 3 CoreFoundation 0x19e421500 __CFLogCString + 84 4 CoreFoundation 0x19e34fc8c _CFLogvEx2Predicate + 344 5 CoreFoundation 0x19e35e548 _CFLogvEx3 + 252 6 Foundation 0x1986195c0 _NSLogv + 124 7 Foundation 0x198617f58 NSLog + 56 8 AppName 0x1042dd480 +[Logger trace:] + 70784 (Logger.m:48) 9 AppName 0x104311ae4 CallExtensionManager.appBecameActive() + 285412 (<compiler-generated>:0) 10 AppName 0x104312004 @objc CallExtensionManager.appBecameActive() + 286724 (<compiler-generated>:0) 11 CoreFoundation 0x19e2f2590 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148 12 CoreFoundation 0x19e396828 ___CFXRegistrationPost_block_invoke + 88 13 CoreFoundation 0x19e3798b8 _CFXRegistrationPost + 440 14 CoreFoundation 0x19e306afc _CFXNotificationPost + 700 15 Foundation 0x1985d1d18 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 16 UIKitCore 0x1a05b61e8 -[UIApplication _stopDeactivatingForReason:] + 1236 17 UIKitCore 0x1a05b5c98 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 280 18 UIKitCore 0x1a05b5a84 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 620 19 UIKitCore 0x1a05b5634 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 252 20 UIKitCore 0x1a05b5500 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 148 21 UIKitCore 0x1a0ca2a68 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 736 22 UIKitCore 0x1a0d41074 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 224 23 UIKitCore 0x1a0462c70 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 316 24 UIKitCore 0x1a08d41ac __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.223 + 556 25 UIKitCore 0x1a0533c60 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 216 26 UIKitCore 0x1a0533ad0 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 244 27 UIKitCore 0x1a0533910 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 336 28 FrontBoardServices 0x1b4340ac8 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 420 29 FrontBoardServices 0x1b4340904 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 152 30 FrontBoardServices 0x1b4344120 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168 31 FrontBoardServices 0x1b434403c __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 344 32 libdispatch.dylib 0x1a578beac _dispatch_client_callout + 20 33 libdispatch.dylib 0x1a578f91c _dispatch_block_invoke_direct + 264 34 FrontBoardServices 0x1b434e24c __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52 35 FrontBoardServices 0x1b434dde8 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 220 36 FrontBoardServices 0x1b4350694 -[FBSSerialQueue _performNextFromRunLoopSource] + 28 37 CoreFoundation 0x19e38e128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 38 CoreFoundation 0x19e39a7b4 __CFRunLoopDoSource0 + 176 39 CoreFoundation 0x19e31f648 __CFRunLoopDoSources0 + 340 40 CoreFoundation 0x19e3350d4 __CFRunLoopRun + 828 41 CoreFoundation 0x19e33a3ec CFRunLoopRunSpecific + 612 42 GraphicsServices 0x1d985035c GSEventRunModal + 164 43 UIKitCore 0x1a06c6f58 -[UIApplication _run] + 888 44 UIKitCore 0x1a06c6bbc UIApplicationMain + 340 45 AppName 0x1042dfbf0 main + 80880 (main.m:7) 46 dyld 0x1bd86cdec start + 2220 Can't get the stack trace for Thread 0 to display nicely
1
0
777
Oct ’23
Does anybody know if its possible to manually do something with raw Crashlytics files directly extracted from a phone?
I've got a crash occurring at app launch time, its crashing too early for Crashlytics to have a chance to send off its stuff to its website. The person on who's phone it is crashing is tech savvy so we've managed to extract the Apple crash report and the Crashlytics directly full of loads of stuff. The Apple crash report is very useful, but I'd like to supplement the information obtained from the with that from Crashltyics (not the actual crash stack, Crashlytics can't improve on what Apple do) but some breadcrumbs that Crashlytics ought to have. I've opened all the files but there's nothing human readable, I asked this question of their customer support but they never replied. Anybody happen to know if the raw Crashlytics files can manually be munged into a human readable form, or manually uploaded to the Crashlytics web site?
0
0
361
Oct ’23
Changes to light/dark mode aren't detectable within a notification service extension unless the phone is restarted
UPDATE: So I discovered that if UIScreen.main.traitCollection.userInterfaceStyle is called in a notification service extension then it doesn't detect any change to the iPhones light/dark mode unless the phone is restarted. (I tried with other extensions, changes are detected immediately in other extensions, however not with a notification service extension nor in a notification content extension). ORIGINAL POSTING: I've got a notification service extension which is populating the notification with images before it's displayed. The images are part of an image set with different images for light and dark modes. What I've discovered is that which image is displayed in the notification depends upon whatever mode the phone was in when the app was installed or when the phone was restarted and it will stay like that for any subsequent posted notifications forever regardless of what the phone's light/dark mode setting is, unless the phone is restarted. Here's an example to illustrate what I mean, here's an image set in the Media.xcassets for the extension, its called "Grunt". And here's some code in the extension: notificationContent!.title = "GRUNT" if let url = URL(forImageResource: "Grunt") { do { let attachment = try UNNotificationAttachment(identifier: "imageAttachment", url: url) notificationContent!.attachments = [attachment] } catch { NSLog("error") } } contentHandler(notificationContent!) When the app is installed, if the phone is set to light mode, then when a notification is posted the 2x Light image is displayed in the notification. If the phone's setting is then changed to dark, then the 2x Light image still continues to displayed in all subsequent notifications that get posted. Conversely, if the phone is set to dark mode when the app is installed then the 2x Dark image is displayed in a notification, similarly if the phone's settings are changed to Light, the Dark image continues to be displayed for any new notifications posted. Until the phone is restarted - then any new notification display in accordance with whatever the phone's dark mode is set to at the time the phone is restarted. In other words, if the phone's light/dark mode setting is changed, new notifications posted don't display the appropriate light/dark image from the image set unless the phone is restarted. (Occurs with both iOS 16 and 17)
3
0
1.2k
Nov ’23
Interactively running app extensions in Xcode 15 is dreadfully unreliable
Xcode has had the ability to debug app extensions for many years. However, several years ago it used to be so bad as to be unusable (extremely slow to load, very slow to run, and just utterly utterly unreliable). I'm glad to say this situation changed and for the past few years its been great, interactively running app extension with Xcode 14.2 or 14.3 is as stable and almost as quick as interacting with the main app. But unfortunately there's been a big step back in reliability in Xcode 15. Many times with Xcode 15 it just stops working, its just not possible to step into the code, stop at a breakpoint for app extensions. It's not like this all the time, sometimes it works just fine, but the problem is quite often it just stops working (by not working I mean breakpoints set in an app extension aren't hit, despite the path of control going through them and the extension being selected as the scheme to execute) The problem is once it stops working there's no way I've found to get it working again, restarting XCOde, rebuilding, restarting the phone, none of this works. Once Xcode has decided to stop working for debugging app extensions there's no apparent way to get it going again. It doesn't matter what type of extension it is - action extension, unwanted communication extension, notification service extension, ..... There's just something fundamentally regressed in XCode 15 that didn't exist with Xcode 14. Apple please can you investigate fixing this, it makes developing and debugging app extension impossible. At least are there any tips to try to attempt to reset Xcode to try and get it working again once its stopped interactively running the extensions?
0
0
634
Oct ’23
Xcode not creating readme, documentation, licenses files/folders for Swift Package
Looking at some tutorials on how to create a swift package (for iOS) they all start by creating a package within Xcode and then showing what files Xcode auto-generated. However with Xcode 15.1 there's lots of stuff mentioned in tutorials which isn't getting created, for example the readme file, the licenses file, a documentation directory and contents. Why is it not creating them? How to add them manually then? Because File/New doesn't have the option to create a Readme.md file for example.
1
0
484
Dec ’23
Loads of keychain dialogs that won't dismiss when building
I'm attempting to build and have lots of code sign dialogs pop up. I'm entering the correct password and selecting Always Allow (selecting just Allow doesn't make any different) but they won't dismiss, instead more appear. I've not found a way of getting rid of them - all the buttons are greyed out. Restarting the desktop doesn't get rid of them. I have to restart the Mac to get rid of them. Why won't they go away and how can I force them to go away? (Sonoma 14.2.1 / Xcode 15.2)
0
0
315
Jan ’24