Post not yet marked as solved
I'm getting some Crash Reports for an app of mine that's on the Mac App Store. A few details:
-All the crash reports are on ARM-64 Macs.
-The call stack shows my app calling NSURL's -getResourceValue:forKey: method with NSURLLocalizedNameKey, which is the last call made by my app before the crash. After that crash logs look like this:
**Thread 0 Crashed:
0 libobjc.A.dylib 0x00000001a623c4b0 objc_retain + 16
1 LaunchServices 0x00000001a6954f68 -[FSNode(PathAndName) nameWithError:] + 72
2 LaunchServices 0x00000001a6a36278 +[_LSDisplayNameConstructor(ConstructForAnyFile) displayNameConstructorWithContextIfNeeded:bundle:bundleClass:node:preferredLocalizations:error:] + 2732
3 LaunchServices 0x00000001a6a357ac +[_LSDisplayNameConstructor(ConstructForAnyFile) displayNameConstructorWithContextIfNeeded:node:error:] + 44
4 LaunchServices 0x00000001a6ae5b20 LaunchServices::URLPropertyProvider::getDisplayNameConstructor(LaunchServices::Database::Context&, FSNode*, LaunchServices::URLPropertyProvider::State*, NSError* __autoreleasing*) + 88
5 LaunchServices 0x00000001a6ae1930 LaunchServices::URLPropertyProvider::prepareLocalizedNameValue(LaunchServices::Database::Context&, FSNode*, __FileCache*, __CFString const*, LaunchServices::URLPropertyProvider::State*, NSError* __autoreleasing*) + 328
6 LaunchServices 0x00000001a6953d6c LaunchServices::URLPropertyProvider::prepareValues(__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 456
7 CoreServicesInternal 0x00000001a8def6f0 prepareValuesForBitmap(__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 452
8 CoreServicesInternal 0x00000001a8dec5ec _FSURLCopyResourcePropertyForKeyInternal(__CFURL const*, __CFString const*, void*, void*, __CFError**, unsigned char) + 236
9 CoreFoundation 0x00000001a64546b0 CFURLCopyResourcePropertyForKey + 144
10 CoreFoundation 0x00000001a646b944 -[NSURL getResourceValue:forKey:error:] + 120**
--
I haven't been able to reproduce the issue on my ARM-64 Mac. Not sure what's going with _LSDisplayNameConstructor or if there is a way I can workaround/resolve.
Some of the crashes have the following lines included:
Kernel Triage:
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
VM - Compressor failed a blocking pager_get
Post not yet marked as solved
We've been working with VMWare on a ticket related to slow upload/download transfers using the VMWare API/SDK on Mac. They believe the root cause is below.
The slow performance is caused by Apple's authentication subsystem (PAM/opendrectoryd) being slow and using a lot of CPU. The security for guestOps file transfer requires an authn check for every packet, packets are limited to ~60k bytes due to the underlying arch; hence every 60k bytes of data has a ~.2 second overhead for the authn. (We see no such delays for Linux or Windows.)
Does anyone have any experience with PAM/opendirectoryd who might be able be help me?
Post not yet marked as solved
A puzzling phenomenon occurs in obtaining the week number.
Please see the attached source.
In Step 0, the correct week number can be obtained according to ISO8601.
In Step 1, by changing minimumDaysInFirstWeek, a new (correct) week number can be obtained.
In Step 2, if I re-set the firstWeekday, for some reason the week number reverts back to the original, even though the value has not been changed.
Shouldn't Step2 return 1 for both weekOfMonth and weekOfYear?
I have verified this with XCode 13.4 playground.
Thanks in advance.
import Foundation
var calendar = Calendar(identifier: .iso8601)
let date = calendar.date(from: DateComponents(year: 2022, month: 1, day: 1))
print("*** Step 0 ***")
print("firstWeekday : \(calendar.firstWeekday)")
print("minimumDaysInFirstWeek : \(calendar.minimumDaysInFirstWeek)")
print("weekOfMonth : \(calendar.component(.weekOfMonth, from: date!))")
print("weekOfYear : \(calendar.component(.weekOfYear, from: date!))")
print("\n*** Step 1 ***")
calendar.minimumDaysInFirstWeek = 1
print("firstWeekday : \(calendar.firstWeekday)")
print("minimumDaysInFirstWeek : \(calendar.minimumDaysInFirstWeek)")
print("weekOfMonth : \(calendar.component(.weekOfMonth, from: date!))")
print("weekOfYear : \(calendar.component(.weekOfYear, from: date!))")
print("\n*** Step 2 ***")
calendar.firstWeekday = 2
print("firstWeekday : \(calendar.firstWeekday)")
print("minimumDaysInFirstWeek : \(calendar.minimumDaysInFirstWeek)")
print("weekOfMonth : \(calendar.component(.weekOfMonth, from: date!))")
print("weekOfYear : \(calendar.component(.weekOfYear, from: date!))")
Result
*** Step 0 ***
firstWeekday : 2
minimumDaysInFirstWeek : 4
weekOfMonth : 0
weekOfYear : 52
*** Step 1 ***
firstWeekday : 2
minimumDaysInFirstWeek : 1
weekOfMonth : 1
weekOfYear : 1
*** Step 2 ***
firstWeekday : 2
minimumDaysInFirstWeek : 1
weekOfMonth : 0
weekOfYear : 52
Post not yet marked as solved
Hi,
We are getting this crash on client side. don't know how to reproduce this. please help in this.
CoreFoundation percentEscapeDecodeBuffer
Post not yet marked as solved
Hi
We are getting following issue on user's end. We are unable to reproduce it. Sharing the logs we have. Please help in this.
iOS : CoreFoundation _CF_forwarding_prep_0
[NSObject(NSObject) _copyDescription]
Post not yet marked as solved
I'm working on an app where we want to upload data every 5 minutes or so to a cloud server even if the app is in the background. We're able to receive data from a BLE sensor in the background, but couldn't find anything on uploading the data consistently. We think it should be possible due to products like the Dexcom glucose monitoring system which uploads data from the background every 5 minutes. Any idea on how we'd go about doing this?
I have made an app, and Im only receiving this error recently, so I don't know whats going on:
Thread 1: "*** -[__NSDictionaryM __setObject:forKey:]: object cannot be nil (key: kCLConnectionMessageNameKey)"
I've followed several tutorials and nothing works or is remotely simple. can anyone perhaps link a json tutorial that can load the following in a "SWIFT UI" format?
{
"id": 182,
"name": "message 2048",
"interactive": "https://wolvideos.firebaseapp.com/Test1.mp4",
"thumbnail": "https://wolvideos.firebaseapp.com/back.jpg",
"date": "April 1",
"videolink": "https://player.vimeo.com/external/656370948.m3u8?s=e50ca2b440798886646ba88a07e9c46a90c9df11",
"sharelink": "https://youtu.be/n7YjxFCyDNQ"
},
{
"id": 180,
"name": "Title 4",
"interactive": "https://wolvideos.firebaseapp.com/Test2.mp4",
"thumbnail": "https://wolvideos.firebaseapp.com/back.jpg",
"date": "April 2",
"videolink": "https://player.vimeo.com/external/653500077.m3u8?s=96c687bef62bfd01ea195e4113e197ebd8d09143",
"sharelink": "https://youtu.be/n7YjxFCyDNQ"
},
{
"id": 172,
"name": "Titil 20203",
"interactive": "https://wolvideos.firebaseapp.com/Test1.mp4",
"thumbnail": "https://wolvideos.firebaseapp.com/back.jpg",
"date": "April 1",
"videolink": "https://player.vimeo.com/external/656370948.m3u8?s=e50ca2b440798886646ba88a07e9c46a90c9df11",
"sharelink": "https://youtu.be/n7YjxFCyDNQ"
},
{
"id": 171,
"name": "Title 20part2",
"interactive": "https://wolvideos.firebaseapp.com/Test2.mp4",
"thumbnail": "https://wolvideos.firebaseapp.com/back.jpg",
"date": "April 2",
"videolink": "https://player.vimeo.com/external/653500077.m3u8?s=96c687bef62bfd01ea195e4113e197ebd8d09143",
"sharelink": "https://youtu.be/n7YjxFCyDNQ"
},
{
"id": 170,
"name": "Title 2021",
"interactive": "https://wolvideos.firebaseapp.com/Test1.mp4",
"thumbnail": "https://wolvideos.firebaseapp.com/back.jpg",
"date": "April 1",
"videolink": "https://player.vimeo.com/external/656370948.m3u8?s=e50ca2b440798886646ba88a07e9c46a90c9df11",
"sharelink": "https://youtu.be/n7YjxFCyDNQ"
},
{
"id": 169,
"name": "Title 2020",
"interactive": "https://wolvideos.firebaseapp.com/Test2.mp4",
"thumbnail": "https://wolvideos.firebaseapp.com/back.jpg",
"date": "April 2",
"videolink": "https://player.vimeo.com/external/653500077.m3u8?s=96c687bef62bfd01ea195e4113e197ebd8d09143",
"sharelink": "https://youtu.be/n7YjxFCyDNQ"
}
]
https://wolvideos.firebaseapp.com/Simple.json
Post not yet marked as solved
Apple's Certificate Transparency policy says that Signed Certificate Timestamps (SCTs) are accepted from TLS extension or OCSP Stapling in addition to the SCTs embedded in the certificate. If we're implementing our own Certificate Transparency enforcement in code written using URLSession, is there a way to obtain SCTs that were presented via TLS extension or OCSP Stapling?
I'm able to get the SCTs from the certificate by calling SecCertificateCopyValues with "1.3.6.1.4.1.11129.2.4.2" inside the urlSession(_:didReceive:completionHandler:) delegate function. I see that there are functions for adding TLS/OCSP SCTs to the ServerTrust, but I don't see any functions for getting them out, and I don't know if URLSession would be including those SCTs in the ServerTrust automatically anyway.
Is there any way to get these other SCTs using URLSession? Or would I have to drop down to Network Framework to do that?
Thanks for any help.
TL;DR - the API cannot be changed, and the variable parameters are a vital part of my app.
I've created a type that stores parameters for an API call.
To make use of them with a successful request, I first need to format them into the URL.
Say, my parameters are expressed as such:
struct Parameters: Encodable {
var name: String
var taste: Taste
var numberOfSpoons: Int?
var topping: Taste?
private enum CodingKeys: String, CodingKey {
case name, taste, topping
case numberOfSpoons = "spoons"
}
init(name: String, taste: Taste, numberOfSpoons: Int? = 1, topping: Taste? = nil){
self.name = name
self.taste = taste
self.numberOfSpoons = numberOfSpoons
self.topping = topping
}
}
Notice that my structure uses both Optionals (as the API does not need all the parameters from my app) and CodingKeys (as the names requested by the API look rather ugly in the code, but are necessary).
Here's the Taste - not much going on except explicit Encodable conformance.
enum Taste: String, Encodable {
case choco, strawberry, vanilla
}
Now I want to call the API, so, according to the suggestion of John Sundell (I can't provide a link to the article due to Apple's censorship), I'm using URLComponents. For example:
var components = URLComponents()
components.scheme = "ftp"
components.host = "icecream.ogs"
components.path = "/spoons"
If I were to add queryItems by hand, it would be fairly easy.
components.queryItems = [
URLQueryItem(name: "name", value: iceCreamParameters.name),
URLQueryItem(name: "numberOfSpoons", value: "\(iceCreamParameters.numberOfSpoons!)")
]
How to dynamically create URLQueryItems from a non-CaseIterable type?
The URLQueryItem needs both name and value parameters. I want the i-th name to be equal to I-thParameters.PropertyName, the same goes for values.
As CaseIterable would not be feasible to implement* in the Parameters struct, I tried to fake it using the Encodable protocol - I thought about serializing the type to JSON (as the encoder gets rid of nil values, too) and then somehow get the keys from a deserialized Dictionary of AnyType (?), but there's got to be a better way.
If this approach is not feasible, please provide your answers with helpful examples.
https://imdb-api.com/en/API/BoxOffice/k_92uqzcls
i cast data like this :
let output = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! Dictionary<String,Array<Dictionary<String, Any>>>//Array
error: Could not cast value of type '__NSCFConstantString' (0x7fff869ca888) to 'NSArray' (0x7fff869ca8e8).
We are now developing an online APP exam function,But students can cheat with keyboard custom phrases,How to turn off keyboard custom phrase hints?
Post not yet marked as solved
recently my app published on app store facing some issue after i have implemented cloudflare and mtls to enhance security feature. Before that, when the API failed, i can receive http error code such as 403, 401 and etc.
but after mtls is activated, all those failed http call is block by AppTransportSecurity layer and i can only receive 999 and error message as "URLSessionTask failed with error: The erver "***.***.com" requires a client certificate."
i have read through Apple document, it says Apple introduce this security layer by default to ensure network security without known weakness https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35
does anyone have come across similar issue like this before?
Post not yet marked as solved
I'm getting errors when I use NSKeyedArchiver and NSKeyedUnarchiver that works with iOS 15.5 but not with iOS 12.4 nor iOS 12.5.5. I have tried combinations of using devices and simulators. The error message appears in the Xcode debug window when the catch scope handles an error that occurs when the following statement executes:
try NSKeyedUnarchiver.unarchivedObject(ofClass: CNGroup.self, from: dataToUnarchive)
Here is what prints in the Xcode debug window for Error.localizedDescription:
The data couldn’t be read because it isn’t in the correct format.
Here is what prints in the Xcode debug window when only the Error object is put in the print statement parentheses:
Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x62, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4)" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x62, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4)}
I found an answer to a similar question like this in Apple Developer Forums which had to do with NSCoder that indicated that the older iOS expects the Data object not to use secure coding, my code as this post concerns is not using secure coding. There are stackoverflow questions that deal with similar questions to mine, but they are very old and they deal with different facets of NSCoder.
The following are the respective function definitions for archive(cnGroup:completionHandler:) and unarchive(dataOfCNGroup:completionHandler) that I use.
Definition for unarchive(dataOfCNGroup:completionHandler)
func archive(cnGroup: CNGroup, completionHandler: @escaping (Result<Data, Error>)->Void) {
do {
if #available(iOS 11.0, *) {
let data: Data = try NSKeyedArchiver.archivedData(withRootObject: cnGroup, requiringSecureCoding: false)
completionHandler(.success(data))
} else {
let data: Data = NSKeyedArchiver.archivedData(withRootObject: cnGroup)
completionHandler(.success(data))
}
} catch {
completionHandler(.failure(error))
}
} // func archive(...) {...}
Definition for archive(cnGroup:completionHandler:)
func unarchive(dataOfCNGroup dataToUnarchive: Data, completionHandler: @escaping (Result<CNGroup, Error>)->Void) {
print("func unarchive(dataOfCNGroup dataToUnarchive: Data, completionHandler: @escaping (Result<CNGroup, Error>)->Void)")
do {
if let unwrappedUnarchivedCNGroup: CNGroup = try NSKeyedUnarchiver.unarchivedObject(ofClass: CNGroup.self, from: dataToUnarchive) {
completionHandler(.success(unwrappedUnarchivedCNGroup))
} else {
let nsError = NSError(domain: "func unarchive(dataOfCNGroup dataToUnarchive: Data, completionHandler: @escaping (Result<CNGroup, Error>?)->Void)", code: #line, userInfo: nil)
let error: Error = nsError
completionHandler(.failure(error))
return
}
} catch {
print("catch error in unarchive(dataOfCNGroup:_:) on line \(#line)")
print("\(error.localizedDescription)")
completionHandler(.failure(error))
}
} // func unarchive(...) {...}
Post not yet marked as solved
Hi,
I'm trying to display a string containing the number of the largest given time unit for the time since as given date - i.e. "2 Months Ago" or "1 Week Ago".
DateComponentsFormatter appears to be a useful tool for this (the app targets iOS 10.2), however it doesn't seem to be formatting the number of weeks consistently.
This is how I'm setting up the formatter:
import Foundation
let day = 60*60*24
let formatter = DateComponentsFormatter()
formatter.calendar = Calendar.current
formatter.allowedUnits = [.hour, .day, .weekOfMonth, .month]
formatter.unitsStyle = .full
formatter.maximumUnitCount = 1
formatter.allowsFractionalUnits = false
formatter.zeroFormattingBehavior = .dropAll
For the given range, I would expect 8-13 to use "1 week", but this doesn't seem to be the case:
(0..40).forEach {
print("\($0): \(formatter.string(from: TimeInterval(day * $0))!)")
}
The actual output of this is:
0: 0 hours
1: 1 day
2: 2 days
3: 3 days
4: 4 days
5: 5 days
6: 6 days
7: 1 week
8: 2 weeks
9: 2 weeks
10: 2 weeks
11: 2 weeks
12: 2 weeks
13: 1 week
14: 2 weeks
15: 2 weeks
16: 2 weeks
17: 2 weeks
18: 2 weeks
19: 2 weeks
20: 2 weeks
21: 3 weeks
22: 3 weeks
23: 3 weeks
24: 3 weeks
25: 3 weeks
26: 3 weeks
27: 3 weeks
28: 4 weeks
29: 4 weeks
30: 4 weeks
31: 1 month
32: 1 month
33: 1 month
34: 1 month
35: 1 month
36: 1 month
37: 1 month
38: 1 month
39: 1 month
Could anyone point me in the right direction?
Post not yet marked as solved
Xcode version: 13.2.1 (13C100) plateform: iOS
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x99288 __exceptionPreprocess
1 libobjc.A.dylib 0x16744 objc_exception_throw
2 CoreFoundation 0x176fc4 +[NSObject(NSObject) _copyDescription]
3 CoreFoundation 0x2de98 forwarding
4 CoreFoundation 0x2cf70 _CF_forwarding_prep_0
5 QuartzCore 0xcb320 CA::Layer::run_animation_callbacks(void*)
6 libdispatch.dylib 0x3a30 _dispatch_client_callout
7 libdispatch.dylib 0x11f48 _dispatch_main_queue_drain
8 libdispatch.dylib 0x11b98 _dispatch_main_queue_callback_4CF
9 CoreFoundation 0x51800 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE
10 CoreFoundation 0xb704 __CFRunLoopRun
11 CoreFoundation 0x1ebc8 CFRunLoopRunSpecific
12 GraphicsServices 0x1374 GSEventRunModal
13 UIKitCore 0x514648 -[UIApplication _run]
14 UIKitCore 0x295d90 UIApplicationMain
15 TCPApp 0xa44bb8 main + 39 (AppDelegate.swift:39)
16 ??? 0x104f49ce4 (Missing)
Post not yet marked as solved
I have a Settings.bundle for my app Roughly, which tells the approximate time in words (e.g. it's about quarter to six) in a complication. It supports a number of languages, but I allow people to use a different language to their own, to help them learn how to tell the time in another language.
The preference switch works fine in the Watch app on the iPhone, but if a user downloads the app direct from the App Store to their watch, there is no way for them to access those preferences. The preferences do not appear in the Watch app without the iOS app present on the iPhone.
Does anyone have a good solution to this? Do I have to offer a preferences switch in the app itself?
Post not yet marked as solved
#define KdownloadsPath NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES).firstObject
_downloadedPath = [KdownloadsPath stringByAppendingPathComponent:fileName];
_downloadingPath = [_downloadedPath stringByAppendingString:@".download"];
NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
@"NSProgressFileOperationKindDownloading", @"NSProgressFileOperationKindKey",
[NSURL fileURLWithPath:_downloadingPath], @"NSProgressFileURLKey",
nil];
self.progress = [[NSProgress alloc] initWithParent:nil userInfo:info];
[self.progress setKind:@"NSProgressKindFile"];
[self.progress setPausable:NO];
[self.progress setCancellable:YES];
[self.progress setTotalUnitCount:_totalBytes];
[self.progress publish];
(updating the progress indicator happens elsewhere)
I'm creating an NSProgress object to show a progress indicator underneat a file in my Downloads directory. The entitlements includes com.apple.security.files.downloads.read-write.
The indicator does not show when NSProgressFileURLKey points to the sandboxed file path, e.g. /Users/mdbraber/Library/Containers/com.mdbraber.TestApp/Data/Downloads/Test.pptx.download. It does work when NSProgressFileURLKey points to the direct download location which the sandbox links to e.g. /Users/mdbraber/Downloads/Test.pptx.download
Is this a bug or should I use something else for NSProgressFileURLKey to make this work?
Post not yet marked as solved
As a follow-up to a Networking lab conversation I had on Tuesday I have the following question:
Is there a way to use nscurl to connect to a server that requires client authentication by providing a client certificate? None of the documented options seem to allow that, but maybe there is an undocumented one...