Foundation

RSS for tag

Access essential data types, collections, and operating-system services to define the base layer of functionality for your app using Foundation.

Pinned Posts

Posts under Foundation tag

337 Posts
Sort by:
Post not yet marked as solved
1 Replies
26 Views
My app is crashing in CoreGraphics. As per the observations, it started crashing for Mac OS 14.4 and 14.4.1 on Arm machines. It is observed on multiple machines. Can someone please help on this? Following is the backtrace: Process: MyApp [1300] Path: /Applications/MyApp.app/Contents/MacOS/MyApp Identifier: com.MyCompany.MyApp Version: 7.2.3 (???) Code Type: ARM-64 (Native) Parent Process: launchd [1] User ID: 502 Date/Time: 2024-04-23 20:48:08.7647 +0530 OS Version: macOS 14.4.1 (23E224) Report Version: 12 Anonymous UUID: 6DAE9C94-37AC-96D0-7221-3AAA99D9E5F6 Sleep/Wake UUID: 03812728-62F0-45A4-86FC-07E151462C11 Time Awake Since Boot: 11000 seconds Time Since Wake: 1385 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008 Exception Codes: 0x0000000000000001, 0x0000000000000008 Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [1300] VM Region Info: 0x8 is not in any region. Bytes before following region: 4338843640 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 1029d8000-1029e4000 [ 48K] r-x/r-x SM=COW /Applications/MyApp.app/Contents/MacOS/MyApp Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 CoreGraphics 0x186aabdac shape_union + 656 1 CoreGraphics 0x186aababc shape_union_with_bounds + 128 2 CoreGraphics 0x186aab9f4 CGRegionCreateUnionWithRect + 240 3 AppKit 0x184b439dc 0x18473e000 + 4217308 4 AppKit 0x184b2ad4c 0x18473e000 + 4115788 5 AppKit 0x184dc358c -[NSViewBackingLayer setNeedsDisplayInRect:] + 176 6 AppKit 0x184790874 -[NSView setNeedsDisplayInRect:] + 396 7 Foundation 0x182070914 __NSThreadPerformPerform + 264 8 CoreFoundation 0x180f21eb0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 9 CoreFoundation 0x180f21e44 __CFRunLoopDoSource0 + 176 10 CoreFoundation 0x180f21bb4 __CFRunLoopDoSources0 + 244 11 CoreFoundation 0x180f207a0 __CFRunLoopRun + 828 12 CoreFoundation 0x180f1fe0c CFRunLoopRunSpecific + 608 13 HIToolbox 0x18b6bb000 RunCurrentEventLoopInMode + 292 14 HIToolbox 0x18b6bae3c ReceiveNextEventCommon + 648 15 HIToolbox 0x18b6bab94 _BlockUntilNextEventMatchingListInModeWithFilter + 76 16 AppKit 0x184778970 _DPSNextEvent + 660 17 AppKit 0x184f6adec -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700 18 AppKit 0x18476bcb8 -[NSApplication run] + 476 19 libffi.dylib 0x191df8050 ffi_call_SYSV + 80 20 libffi.dylib 0x191e00ae0 ffi_call_int + 1212 21 _objc.cpython-39-darwin.so 0x10700a47c PyObjCFFI_Caller_SimpleSEL + 1204 22 _objc.cpython-39-darwin.so 0x107034e94 objcsel_vectorcall_simple + 768 23 Python 0x104312ddc call_function + 124 24 Python 0x104311ac0 _PyEval_EvalFrameDefault + 29288 25 Python 0x10427a720 _PyFunction_Vectorcall + 628 26 Python 0x104312ddc call_function + 124 27 Python 0x104311ac0 _PyEval_EvalFrameDefault + 29288 28 Python 0x10427a57c _PyFunction_Vectorcall + 208 29 Python 0x104312ddc call_function + 124 30 Python 0x104311a4c _PyEval_EvalFrameDefault + 29172 31 Python 0x10427a57c _PyFunction_Vectorcall + 208 32 Python 0x104312ddc call_function + 124 33 Python 0x104311ac0 _PyEval_EvalFrameDefault + 29288 34 Python 0x10427a57c _PyFunction_Vectorcall + 208 35 Python 0x104312ddc call_function + 124 36 Python 0x104311aec _PyEval_EvalFrameDefault + 29332 37 Python 0x10427a57c _PyFunction_Vectorcall + 208 38 Python 0x104312ddc call_function + 124 39 Python 0x104311aec _PyEval_EvalFrameDefault + 29332 40 Python 0x1043131a0 _PyEval_EvalCode + 620 41 Python 0x10430a7d0 PyEval_EvalCode + 80 42 MyApp 0x1029dd440 0x1029d8000 + 21568 43 MyApp 0x1029dd7c0 0x1029d8000 + 22464 44 dyld 0x180aba0e0 start + 2360
Posted
by rksinghal.
Last updated
.
Post not yet marked as solved
1 Replies
118 Views
Is the timeout for session-level authentication challenge handling documented somewhere? For example, if I get the urlSession(_:didReceive:) callback for server trust authentication, how long do I have to invoke the completion handler (or return from the callback if using Swift Concurrency)? Or is this completely dependent on the server's settings?
Posted
by Aqua_Geek.
Last updated
.
Post not yet marked as solved
26 Replies
9.0k Views
Hi, I am facing a strange issue in my app with iOS14 there is a intermittent crash, i am using NetServiceBrowser for MDNS discovery not sure if that is causing the problem crash log has below information: Crashed: com.apple.main-thread 0 CoreFoundation 0x1a906c4c4 CFAssertMismatchedTypeID + 108 1 CoreFoundation 0x1a8f7db0c CFRunLoopSourceRemoveFromRunLoop + 298 2 CFNetwork 0x1a96255b0 CFNetServiceBrowserStopSearch + 460 3 CoreFoundation 0x1a8f81240 CFRUNLOOPISCALLINGOUTTOASOURCE0PERFORMFUNCTION + 24 4 CoreFoundation 0x1a8f81140 CFRunLoopDoSource0 + 204 5 CoreFoundation 0x1a8f80488 CFRunLoopDoSources0 + 256 6 CoreFoundation 0x1a8f7aa40 CFRunLoopRun + 776 7 CoreFoundation 0x1a8f7a200 CFRunLoopRunSpecific + 572 8 GraphicsServices 0x1bf075598 GSEventRunModal + 160 9 UIKitCore 0x1ab840004 -[UIApplication run] + 1052 10 UIKitCore 0x1ab8455d8 UIApplicationMain + 164
Posted Last updated
.
Post not yet marked as solved
1 Replies
84 Views
Hello! Recently, the following crash issue began to occur. 0 libswiftCore.dylib 0x000000019ffaa3c8 closure #1 in closure #1 in closure #1 in _assertionFailure+ 238536 (_:_:file:line:flags:) + 228 1 libswiftCore.dylib 0x000000019ffaa2a0 closure #1 in closure #1 in _assertionFailure+ 238240 (_:_:file:line:flags:) + 332 2 libswiftCore.dylib 0x000000019ffa9c2c _assertionFailure+ 236588 (_:_:file:line:flags:) + 184 3 libswiftCore.dylib 0x000000019ffac4fc specialized BidirectionalCollection._index+ 247036 (_:offsetBy:) + 1280 4 libswiftCore.dylib 0x00000001a016d630 String.UTF16View._indexRange+ 2086448 (for:from:) + 184 5 libswiftCore.dylib 0x00000001a018561c __StringStorage.getCharacters+ 2184732 (_:range:) + 112 6 libswiftCore.dylib 0x00000001a0185720 @objc __StringStorage.getCharacters+ 2184992 (_:range:) + 36 7 CoreFoundation 0x00000001a16893e0 __CFStringEncodeByteStream + 1864 8 Foundation 0x00000001a0527c94 -[NSString+ 208020 (NSStringOtherEncodings) getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 260 ... It seems like assert is being called. Can you tell me a case that could be the cause? Also, this is a code I have been using for a long time, but recently it started crashing. Have there been any internal changes recently? Please understand that the entire crash log cannot be attached for security reasons. Any help would be greatly appreciated!
Posted
by eunjeong2.
Last updated
.
Post not yet marked as solved
1 Replies
155 Views
I have a customer who wants to protect the REST API of their app with a private certificate. They would then distribute the client certificate to the authorized users. Their app would not work unless the client certificate is already installed on the user's phone before they run the app. I have never done this before. Is it possible to install a client certificate on an iPhone without running an app, for example if it were sent in an email message? And if it is possible, is App Review going to let such an app into the app store? Thanks, Frank
Posted
by flarosa.
Last updated
.
Post not yet marked as solved
2 Replies
137 Views
I have tried to insert 1L key-values into the user defaults. It is working fine until 50k key-values. After some time, am getting Not updating lastKnownShmemState in CFPrefsPlistSource<0x2825b0c60> (Domain: peformance_validator, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No) also, key-values are not updating in the plist as well. peformance_validator is my user defaults group name. How can I solve this ?
Posted
by r@anjith.
Last updated
.
Post not yet marked as solved
1 Replies
91 Views
Hi, I am having this rare issues, where a handful of my users are crashing when trying to access their realm file. This is the error I'm seeing: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=3 "Failed to open file at path '/var/mobile/Containers/Data/Application/BCA5E4BC-5923-4D7E-8142-AB49B32A7E59/Documents/default.realm.lock': Operation not permitted" UserInfo={Error Code=3, NSFilePath=/var/mobile/Containers/Data/Application/BCA5E4BC-5923-4D7E-8142-AB49B32A7E59/Documents/default.realm.lock, Error Name=PermissionDenied, NSLocalizedDescription=Failed to open file at path '/var/mobile/Containers/Data/Application/BCA5E4BC-5923-4D7E-8142-AB49B32A7E59/Documents/default.realm.lock': Operation not permitted} and I can report that for all for those users, it seems that identiferForVendor has returned nil. So it looks like that's the common denominator. Any idea on what other data I can log or what's the issue here? Thanks..!
Posted
by wotson.
Last updated
.
Post not yet marked as solved
1 Replies
107 Views
NSString *jsonString = @"{\"key1\":\"value1\",\"key2\":\"value2\",\"key3\":\"value3\",\"key4\":\"value4\"}"; NSString *jsonString2 = @"{\"key2\":\"value2\",\"key1\":\"value1\",\"key4\":\"value4\",\"key3\":\"value3\"}"; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; NSData *jsonData2 = [jsonString2 dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *dict1 = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil]; NSDictionary *dict2 = [NSJSONSerialization JSONObjectWithData:jsonData2 options:NSJSONReadingMutableContainers error:nil]; The expected results are: dict1:key1,key2,key3,key4 dict2:key2,key1,key4,key3 Is there any way to make that happen?
Posted
by JuiceLv.
Last updated
.
Post not yet marked as solved
1 Replies
140 Views
Hi I Download my app from test flight, when i click submit button to a backend call. App expects to get back with the response from the backend, to take to next pages. But the app seems to be stuck waiting for the backend response. No error messages seen. i am sure the backend call is blocked from the test flight version. Same code works well from emulator and the physical device from local and from Google PlayStore. Only the test flight is the problem. I am sure i messed up some settings , My Info.plist has as in below, can anyone please help. NSAppTransportSecurity NSPinnedNetworkSecurityItems MyBundleName NSIncludesSubdomains NSAllowsArbitraryLoads NSPinnedCAIdentities SPKI-SHA256-BASE64 THEKEY
Posted
by PriyaRaj.
Last updated
.
Post marked as solved
3 Replies
126 Views
I have used [[NSDistributedNotificationCenter defaultCenter] addObserver in process AA to listen notification from other process BB, It works fine. But when make the observer process AA as a launch daemon (which is started by launchd), It found below difference. If run process BB as root privilege, AA can not receive notification posted by BB. If make process BB as a launch daemon, AA can receive notification posted by BB. What was happened in above difference, It can not find any document about this, Thanks.
Posted Last updated
.
Post not yet marked as solved
2 Replies
129 Views
Xcode Version 15.0.1 (15A507) Crash log Hardware Model: iPhone14,7 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] OS Version: iPhone OS 16.6 (20G75) Release Type: User Baseband Version: 1.80.02 Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Triggered by Thread: 26 Application Specific Information: abort() called Last Exception Backtrace: 0 CoreFoundation 0x1b3c54cb4 __exceptionPreprocess + 164 1 libobjc.A.dylib 0x1accf03d0 objc_exception_throw + 60 2 Foundation 0x1adf6950c -[NSData(NSData) _base64EncodingAsString:withOptions:] + 1072 3 Foundation 0x1ae2cf8bc Data.base64EncodedString(options:) + 640 ... 6 libdispatch.dylib 0x1bb11a320 _dispatch_call_block_and_release + 32 7 libdispatch.dylib 0x1bb11beac _dispatch_client_callout + 20 8 libdispatch.dylib 0x1bb11ef8c _dispatch_queue_override_invoke + 788 9 libdispatch.dylib 0x1bb12d944 _dispatch_root_queue_drain + 396 10 libdispatch.dylib 0x1bb12e158 _dispatch_worker_thread2 + 164 11 libsystem_pthread.dylib 0x213a85da0 _pthread_wqthread + 228 Thread 26 name: Dispatch queue: com.apple.root.default-qos Thread 26 Crashed: 0 libsystem_kernel.dylib 0x1f2c11578 __pthread_kill + 8 1 libsystem_pthread.dylib 0x213a8c118 pthread_kill + 268 2 libsystem_c.dylib 0x1bb17c178 abort + 180 3 libc++abi.dylib 0x2139cabf8 abort_message + 132 4 libc++abi.dylib 0x2139ba444 demangling_terminate_handler() + 348 5 libobjc.A.dylib 0x1accf5ea4 _objc_terminate() + 144 6 libc++abi.dylib 0x2139c9fbc std::__terminate(void (*)()) + 16 7 libc++abi.dylib 0x2139c9f60 std::terminate() + 56 8 libdispatch.dylib 0x1bb11bec0 _dispatch_client_callout + 40 9 libdispatch.dylib 0x1bb11ef8c _dispatch_queue_override_invoke + 788 10 libdispatch.dylib 0x1bb12d944 _dispatch_root_queue_drain + 396 11 libdispatch.dylib 0x1bb12e158 _dispatch_worker_thread2 + 164 12 libsystem_pthread.dylib 0x213a85da0 _pthread_wqthread + 228 13 libsystem_pthread.dylib 0x213a85b7c start_wqthread + 8 12 libsystem_pthread.dylib 0x213a85b7c start_wqthread + 8 My code private func encodeStringTo64(fromString: String) -> String? { let plainData = fromString.data(using: .utf8) return plainData?.base64EncodedString(options: []) } Call foundation method extension Data { ... /// Returns a Base-64 encoded string. /// /// - parameter options: The options to use for the encoding. Default value is `[]`. /// - returns: The Base-64 encoded string. @inlinable public func base64EncodedString(options: Data.Base64EncodingOptions = []) -> String } Description This foundation method don't have throws, but it throw an exception. It will cause a crash.
Posted Last updated
.
Post marked as solved
9 Replies
416 Views
I'm getting the following error @main: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1886cdcf8). It occurs about every other time someone attempts to log in to the app. Also I cannot replicate this issue on the simulator -- only on physical devices.
Posted Last updated
.
Post not yet marked as solved
1 Replies
157 Views
Im using Notions API to print out some data from one of my own pages in notion and im using URLSession to make the request then parsing the unwrapped data but nothing is being returned to my console and I know my endpoint and API key is correct. I've gone through the notion API documentation can't can't seem to find anything in it that I am not doing or doing wrong. Ill provide my code as well as the documentation I've been consulting: https://developers.notion.com/reference/intro import Foundation struct Page: Codable { let id: String let title: String } let endpoint = URL(string: "https://api.notion.com/v1/pages/8efc0ca3d9cc44fbb1f34383b794b817") let apiKey = "… redacted …" let session = URLSession.shared func makeRequest() { if let endpoint = endpoint { let task = URLSession.shared.dataTask(with: endpoint) { data, response, error in if let taskError = error { print("could not establish url request:\(taskError)") return } if let unwrapData = data { //safely unwrapping the data value using if let do { let decoder = JSONDecoder() //JSONDecoder method to decode api data, let codeUnwrappedData = try decoder.decode(Page.self,from: unwrapData) //type: specifies its a struct, from: passes the data parmeter that contains the api data to be decoded } catch { print("could not parse json data") } } if let httpResponse = response as? HTTPURLResponse { if httpResponse.statusCode == 200 { if let apiData = data { print(String(data: apiData, encoding: .utf8)!) } } else { print("unsuccessful http response:\(httpResponse)") } makeRequest() } } task.resume() } }
Posted
by Aor1105.
Last updated
.
Post marked as solved
2 Replies
217 Views
My app always crash when I trying to assign an enum to a value of[String: Any] only on iOS14.6, tested on iOS15, iOS16, iOS17, never saw this issue. The function would pass an ConnectState enum and a serial number string to a userInfo of notification, received class may perform some UI updates when connect state changed. func post(state: ConnectState, serial: Int) { var userInfo: [String: Any] = [:] userInfo["state"] = state userInfo["serial"] = serial print(userInfo) NotificationCenter.default.post(name: NSNotification.Name("PostName"), object: nil, userInfo: userInfo) } @objc enum ConnectState: UInt8 { case connected = 0x00 case disConnected = 0x01 var description: String { switch self { case .connected: return "connected" case .disConnected: return "disConnected" } } } Classes received this notification, may perform some task based on connect state changed. class AClass { init() { NotificationCenter.default.addObserver(self, selector: #selector(handleNotification(_:)), name: NSNotification.Name("PostName"), object: nil) } @objc func handleNotification(_ notification :Notification) { let state = notification.userInfo?["state"] as! ConnectState print("AClass handleNotification: \(state.description)") } } let a = AClass() post(state: .disConnected, serial: 123456) post(state: .connected, serial: 123456) //["serial": 123456, "state": __lldb_expr_3.ConnectState] //AClass handleNotification: disConnected //["serial": 123456, "state": __lldb_expr_3.ConnectState] //AClass handleNotification: connected The crashes always happened in the line that assigning the ConnectState enum to dictionary [String: Any] value, both connect state and serialNumber are not nil or optional. I'm not sure why would this related to a allocate issue, is my code wrong? AppName(645,0x16f61f000) malloc: can't allocate region :*** mach_vm_map(size=1152921504606863360, flags: 100) failed (error code=3) AppName(645,0x16f61f000) malloc: *** set a breakpoint in malloc_error_break to debug ```Since we only have one iOS14.6 device, it will be a challenge to test on other same iOS version device, nor test on simulator.
Posted
by Rimbaud.
Last updated
.
Post marked as solved
6 Replies
197 Views
Hi together, i have truble to parse an json with an array like following: "data": [ [ 0000000000, [ { "count": 0 } ] ], [ 0000000000, [ { "count": 0 } ] ] ], Can someone help me to parse that with the this? Thanks
Posted
by clemens68.
Last updated
.
Post not yet marked as solved
14 Replies
373 Views
I recently re-read Performing manual server trust authentication and noticed that it does not mention having to call SecTrustEvaluate (or its replacements) in client code (anymore). Is that implicitly taken care of by ATS?
Posted
by jzilske.
Last updated
.
Post not yet marked as solved
2 Replies
170 Views
It seems that the first time I open my app after the phone is restarted, the app does not properly access UserDefaults. When my app is launched, I pull relevant user settings / preferences from UserDefaults. I recently noticed (after some users reached out about issues) that the first time the app is opened after a restart, the app appears as though all user settings / preferences have been erased. If the app is force quit and reopened, the user data seems to come back normally. If the user takes action in the app before force quitting, though, UserDefaults will be written to with these new, empty values (essentially erasing what used to be in UserDefaults). This makes it seem as though right after the phone is restarted, the app is unable to pull data from UserDefaults for some reason. Has anyone else seen this issue? It could also be due to the lifecycle of my app and how I access UserDefaults, so if others don't have this issue it would be great to hear how you handle this.
Posted Last updated
.
Post marked as solved
2 Replies
204 Views
I have a repeating timer installed like this: _cmdTimer = [NSTimer timerWithTimeInterval: 0.5 target: self selector: @selector(timedTask:) userInfo: nil repeats: YES]; [NSRunLoop.mainRunLoop addTimer: _cmdTimer forMode: NSModalPanelRunLoopMode]; [NSRunLoop.mainRunLoop addTimer: _cmdTimer forMode: NSDefaultRunLoopMode]; The first time the timer fires, it opens a modal dialog. But then the timer does not fire again until the dialog is closed. I don't get that, since I scheduled the timer in NSModalPanelRunLoopMode. To verify that the dialog was running in that mode, just before opening the dialog I said [self performSelector: @selector(testMe) withObject: nil afterDelay: 0.7 inModes: @[NSModalPanelRunLoopMode] ]; and the testMe method did get executed while the dialog was open.
Posted
by JWWalker.
Last updated
.
Post not yet marked as solved
6 Replies
257 Views
I have a file named ä.txt (with German umlaut) on my FTP server. I select it like this: let openPanel = NSOpenPanel() openPanel.runModal() let source = openPanel.urls[0] Running this code unexpectedly throws an error: do { print(try source.checkResourceIsReachable()) } catch { print(error) // Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory” } Manipulating the URL also seems to change the underlying characters: print(source) // file:///Volumes/abc.com/httpdocs/%C3%A4.txt print(URL(fileURLWithPath: source.path)) // file:///Volumes/abc.com/httpdocs/a%CC%88.txt Note that both variants of the URL above also throw the same error when running URL.checkResourceIsReachable(). If I download the file to my Mac, then both variants print file:///Users/me/Downloads/a%CC%88.txt and neither of them throws an error when running URL.checkResourceIsReachable(). What is the problem? How can I correctly access this file on the FTP server?
Posted
by Nickkk.
Last updated
.