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.

Posts under Foundation tag

201 Posts

Post

Replies

Boosts

Views

Activity

Cmake build unable to 'find' Foundation framework
I'm trying to build llama.cpp, a popular tool for running LLMs locally on macos15.1.1 (24B91) Sonoma using cmake but am encountering errors. Here is the stack overflow post regarding the issue: https://stackoverflow.com/questions/79304015/cmake-unable-to-find-foundation-framework-on-macos-15-1-1-24b91?noredirect=1#comment139853319_79304015
0
0
536
Dec ’24
App Settings Not Appearing with Xcode 16.2
I recently encountered an issue with Xcode 16.2 while attempting to integrate Settings.bundle into a new app. I added Settings.bundle as a new file (using the provided template), but when I ran the app (the default "Hello World" project), the expected three default controls (Name, Enabled, Slider) did not appear in the app's settings. To troubleshoot, I downgraded my system to macOS Sonoma 14.7.2 and Xcode 15.4 (on a 2023 Mac Mini, M2). After this downgrade, everything worked as expected. With a new project, adding Settings.bundle, and running the app, the settings entry for the app appeared, including the three default fields. This behavior suggests a potential issue or incompatibility with Xcode 16.2.
3
3
1.3k
Dec ’24
FirstResponderView/FirstResponderIndexPath in TableView
I found when I put a webView on the screen and then remove it, several properties in TableView including firstResponderView, FirstResponderIndexPath, and FirstResponderViewType have changed. These properties are hidden and I cannot change them. firstResponderView strong holds my cell, resulting in my cell not being able to call didEndDisplayCell when it slides out of the screen as expected. What should I do to avoid firstResponderView from strong holding my cell, or what should I do to release it?
1
0
375
Dec ’24
How to learn Xcode as a beginner
Hi All, I am from a non tech background and always felt a need that I am missing on the most interesting skills in today's world. I wish to learn Xcode to build applications and much more. Could any of you kindly suggest how I can learn and engage online. Thank You Govind
1
0
434
Dec ’24
Interpreting received "Data" object in cpp
Hello Everyone, I have a use case where I wanted to interpret the "Data" object received as a part of my NWConnection's recv call. I have my interpretation logic in cpp so in swift I extract the pointer to the raw bytes from Data and pass it to cpp as a UnsafeMutableRawPointer. In cpp it is received as a void * where I typecast it to char * to read data byte by byte before framing a response. I am able to get the pointer of the bytes by using // Swift Code // pContent is the received Data if let content = pContent, !content.isEmpty { bytes = content.withUnsafeBytes { rawBufferPointer in guard let buffer = rawBufferPointer.baseAddress else { // return with null data. } // invoke cpp method to interpret data and trigger response. } // Cpp Code void InterpretResponse (void * pDataPointer, int pDataLength) { char * data = (char *) pDataPointer; for (int iterator = 0; iterator < pDataLength; ++iterator ) { std::cout << data<< std::endl; data++; } } When I pass this buffer to cpp, I am unable to interpret it properly. Can someone help me out here? Thanks :) Harshal
4
0
963
Dec ’24
Crash SIGABRT and no signs of app code in stack trace
Team, I am seeing following crash with no trace of evidence to reproduce the crash. Any ideas how to reproduce this/ do potential fixes? Application Specific Information: *** Terminating app due to uncaught exception 'b'MACH_EXCEPTION_TYPE: Unknown type:999'', reason: 'b'Unknown Type:999/code:999'' Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00001d9b951d4 0x1d9b89000 + 49620 1 libsystem_c.dylib 0x0000191587ad8 0x191510000 + 490200 2 libc++abi.dylib 0x0000211b0d5b8 0x211afa000 + 79288 3 libc++abi.dylib 0x0000211afbbac 0x211afa000 + 7084 4 libobjc.A.dylib 0x0000186ae6e14 0x186ab4000 + 208404 5 libc++abi.dylib 0x0000211b0c87c 0x211afa000 + 75900 6 libc++abi.dylib 0x0000211b100ac 0x211afa000 + 90284 7 libobjc.A.dylib 0x0000186ae2650 0x186ab4000 + 190032 8 CoreFoundation 0x00001897c8934 0x189776000 + 338228 9 GraphicsServices 0x00001d57a81c4 0x1d57a7000 + 4548 10 UIKitCore 0x000018c32eeb0 0x18bf5c000 + 4009648 11 UIKitCore 0x000018c3dd5b4 0x18bf5c000 + 4724148 12 Chase 0x00001032d98e0 main + 5789920 (main.swift:29) 13 ?-?-? 0x00001af1b6ec8 0x0 + 0
1
0
290
Dec ’24
I need some help, thank you
I ask apple , my identity,com.lgxsgj.xsgj is in company account (Loudi Hualing Yunchuang Shuzhi Technology Co., Ltd) but xcode shows error, xcode shows my profile doesn't incude signing certificate (Loudi Hualing Yunchuang Shuzhi Technology Co., Ltd). but I have other com.lgxsgj.xsgj1,com.lgxsgj.xsgj2, it's correct
1
0
232
Dec ’24
How to solve 0x7fc700000000 is not in any region?
I have been trying to open Minecraft on my mac, however my java keeps quitting expectedly. I am not sure how to solve that considering I've tried deleting and reinstalling both java and minecraft a few times. Translated Report (Full Report Below) Process: java [896] Path: /Users/USER/Library/Application Support/minecraft/*/jre.bundle/Contents/Home/bin/java Identifier: java Version: ??? Code Type: X86-64 (Native) Parent Process: launcher [836] Responsible: launcher [836] User ID: 501 Date/Time: 2024-12-02 22:17:03.1605 +0000 OS Version: macOS 12.7.6 (21H1320) Report Version: 12 Bridge OS Version: 3.0 (14Y910) Anonymous UUID: 63D094BB-378F-96E3-C961-AD71A2DDD236 Time Awake Since Boot: 370 seconds System Integrity Protection: enabled Crashed Thread: 0 Java: Render thread Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGABRT) Exception Codes: KERN_INVALID_ADDRESS at 0x00007fc700000000 Exception Codes: 0x0000000000000001, 0x00007fc700000000 Exception Note: EXC_CORPSE_NOTIFY VM Region Info: 0x7fc700000000 is not in any region. Bytes after previous region: 17347201724417 Bytes before following region: 2347761664 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL Stack 70000a243000-70000a341000 [ 1016K] rw-/rwx SM=COW thread 45 ---> GAP OF 0xfc781bbf000 BYTES MALLOC_TINY 7fc78bf00000-7fc78c000000 [ 1024K] rw-/rwx SM=PRV Application Specific Information: abort() called
1
0
293
Dec ’24
FileManager.copyItem Permission Bug in iOS 18.1.1 with iCloud Shared Folders
Hi there, I've encountered a file permission bug in iOS 18.1.1 when using FileManager.default.copyItem(at:to:) to copy files from an iCloud shared folder to the app sandbox. This issue occurs under the following conditions: The source file resides in an iCloud shared folder. The iCloud shared folder is owned by another iCloud user and shared with read-only permissions. The app copies the file to its sandbox using the copyItem(at:to:) method. Observed Behavior: After copying the file to the app sandbox, the original file's read-only permissions are propagated to the copied file. This results in an inability to delete the copied file from the app sandbox, with the following error message: NSCocoaErrorDomain, Code 513: "The file couldn’t be removed because you don’t have permission to access it." Steps to Reproduce: Access a shared iCloud folder owned by another user with read-only permissions. Copy a file from this folder to the app sandbox using FileManager.default.copyItem(at:to:). Attempt to delete the copied file within the app sandbox. Workaround: Until this issue is resolved, the bug can be avoided by initializing the UIDocumentPickerViewController with the asCopy: true parameter: UIDocumentPickerViewController(forOpeningContentTypes: contentTypes, asCopy: true) This ensures that the copied file does not inherit the original permissions from the shared source file. Example Project: To reproduce the issue and observe the error, I’ve created a sample project hosted on GitHub: https://github.com/giomurru/FileDeletePermissionBug This project provides step-by-step instructions for testing and reproducing the bug. Environment: iOS/iPadOS Version: 18.1.1 Devices: [iPhone 15, iPad 9th Gen] Development Tool: Xcode 16.1 I hope this helps Apple engineers and other developers experiencing the same issue. Feedback or additional insights would be appreciated. Giovanni
11
0
659
Dec ’24
Apple Air Pods Upgrade!
Good evening. I have come up with this amazing and revolutionary idea that is going to change the ent world for the better. I’m a 23 year old Design Engineer from Greece and I would like to come to direct contact with the Apple Design Team, in order to discuss this project and the best case scenario, sell it to you. The foldable iPhone is not a good idea. Its not revolutionary and it’s going to leave a big black mark in Apple history. With my idea, the whole world will see again the greatness of the biggest company in history.
2
0
503
Dec ’24
Common blocks in Swift?
I am porting an old app from ObjC. The app uses many defined constants such as: #define COM_OFFSET 12.5 and many variables that are read and/or written throughout the App, such as: PCDate* Dates[367]; @class PCMainView; PCMainView* MainView; in one file called "PCCommon.h" How do I duplicate this function in Swift? I have looked around and have found no help. Thanks in advance.
1
0
441
Dec ’24
WebGPU Enabled but WKWebView doesn't have GPU Access
We enabled WebGPU feature flag on Safari on iOS 18.2. This does give Safari an access to GPU but WKWebView still doesn't have GPU access. Can WKWebView not access GPU through Safari feature flag? Is there some other mechanism through which we can enable GPU access for WKWebView? We are testing gpu access by loading : https://webgpureport.org/ Regards Saalis Umer Microsoft Safari Feature Flag - webgpu = true Safari GPU Access: WKWebView GPU Access:
1
3
777
Dec ’24
Title: CoreFoundation CFRelease Crash on iOS 18
Hi everyone, I'm experiencing crashes that consistently occur on iOS 18 devices, which seem to share a common root cause. I'm hoping for some guidance. Here are the details of the crashes as received from Xcode Organizer: Crash Trace 1: 0 CoreFoundation 0x0000000192c50e54 CF_IS_OBJC + 76 (CFRuntime.c:461) 1 CoreFoundation 0x0000000192c4dd3c CFRelease + 60 (CFRuntime.c:1202) 2 CoreFoundation 0x0000000192d015e0 _signalEventSync + 252 (CFStream.c:636) 3 CoreFoundation 0x0000000192d53050 ___signalEventQueue_block_invoke + 28 (CFStream.c:646) 4 libdispatch.dylib 0x000000019a93c370 _dispatch_call_block_and_release + 32 (init.c:1549) 5 libdispatch.dylib 0x000000019a93e0d0 _dispatch_client_callout + 20 (object.m:576) 6 libdispatch.dylib 0x000000019a9456d8 _dispatch_lane_serial_drain + 744 (queue.c:3934) 7 libdispatch.dylib 0x000000019a9461e0 _dispatch_lane_invoke + 380 (queue.c:4025) 8 libdispatch.dylib 0x000000019a951258 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:7193) 9 libdispatch.dylib 0x000000019a950aa4 _dispatch_workloop_worker_thread + 540 (queue.c:6787) 10 libsystem_pthread.dylib 0x000000021a00fc7c _pthread_wqthread + 288 (pthread.c:2696) 11 libsystem_pthread.dylib 0x000000021a00c488 start_wqthread + 8 (:-1) Crash Trace 2: 0 libobjc.A.dylib 0x0000000186f33c20 objc_msgSend + 32 1 CoreFoundation 0x0000000189cb14b8 _inputStreamCallbackFunc + 36 (CFObject.m:1952) 2 CoreFoundation 0x0000000189cb0aa8 _signalEventSync + 216 (CFStream.c:626) 3 CoreFoundation 0x0000000189d01e30 ___signalEventQueue_block_invoke + 28 (CFStream.c:646) 4 libdispatch.dylib 0x0000000191948370 _dispatch_call_block_and_release + 32 (init.c:1549) 5 libdispatch.dylib 0x000000019194a0d0 _dispatch_client_callout + 20 (object.m:576) 6 libdispatch.dylib 0x00000001919516d8 _dispatch_lane_serial_drain + 744 (queue.c:3934) 7 libdispatch.dylib 0x00000001919521e0 _dispatch_lane_invoke + 380 (queue.c:4025) 8 libdispatch.dylib 0x000000019195d258 _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:7193) 9 libdispatch.dylib 0x000000019195caa4 _dispatch_workloop_worker_thread + 540 (queue.c:6787) 10 libsystem_pthread.dylib 0x000000021214bc7c _pthread_wqthread + 288 (pthread.c:2696) 11 libsystem_pthread.dylib 0x0000000212148488 start_wqthread + 8 Crash Trace 3: 0 libobjc.A.dylib 0x00000001941d9ce8 objc_loadWeakRetained + 156 (NSObject.mm:525) 1 CoreFoundation 0x0000000196d0a0f4 _outputStreamCallbackFunc + 36 (CFObject.m:1960) 2 CoreFoundation 0x0000000196d09724 _signalEventSync + 216 (CFStream.c:626) 3 CoreFoundation 0x0000000196d07948 ___signalEventQueue_block_invoke + 28 (CFStream.c:646) 4 libdispatch.dylib 0x000000019e9de248 _dispatch_call_block_and_release + 32 (init.c:1549) 5 libdispatch.dylib 0x000000019e9dffa8 _dispatch_client_callout + 20 (object.m:576) 6 libdispatch.dylib 0x000000019e9e75cc _dispatch_lane_serial_drain + 768 (queue.c:3934) 7 libdispatch.dylib 0x000000019e9e8124 _dispatch_lane_invoke + 380 (queue.c:4025) 8 libdispatch.dylib 0x000000019e9f338c _dispatch_root_queue_drain_deferred_wlh + 288 (queue.c:7193) 9 libdispatch.dylib 0x000000019e9f2bd8 _dispatch_workloop_worker_thread + 540 (queue.c:6787) 10 libsystem_pthread.dylib 0x00000002220f3680 _pthread_wqthread + 288 (pthread.c:2696) 11 libsystem_pthread.dylib 0x00000002220f1474 start_wqthread + 8 Notable Points: All crashes occur only on iOS 18 and newer versions. The crashes are independent of the Xcode version used to build the app (tested with both Xcode 15.4 and 16). All crash traces occur in CoreFoundation and seem to have nothing related to our app codebase. I've attempted to profile the app using Instruments to identify any zombie objects, but the crashes do not manifest on my own devices. I've referred to discussions, including this forum thread, but have not yet found a solution. Questions: Has anyone else encountered similar issues on iOS 18? Are there specific aspects of iOS 18 that might contribute to these CoreFoundation and libobjc-related crashes? Would appreciate any suggestions for further diagnostics or potential workarounds. Thank you for your help!
9
2
1.7k
Dec ’24
Adding a sandboxed v2ray precompiled binary to my application
Greetings! I want to add my pre-compiled binary of v2ray to my application so I can activate it in background as a proxy and run stuff through it. I've codesigned it via: codesign -s - -i production.myproject.v2ray -o runtime --entitlements v2ray.entitlements -f v2ray Contents of entitlements file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.files.downloads.read-write</key> <true/> <key>com.apple.security.files.user-selected.read-write</key> <true/> <key>com.apple.security.network.client</key> <true/> <key>com.apple.security.network.server</key> <true/> </dict> </plist> Originally I ran it like this without sandboxing from my main target app: guard let v2rayPath = Bundle.main.path(forResource: "v2ray", ofType: nil) else { throw NSError(domain: "ProxyController", code: 1, userInfo: [NSLocalizedDescriptionKey: "V2Ray binary not found in bundle"]) } let task = Process() task.executableURL = URL(fileURLWithPath: v2rayPath) task.arguments = ["-config", configURL.path] // Redirect output for debugging let pipe = Pipe() task.standardOutput = pipe task.standardError = pipe``` And it ran flawlessly. Now it refuses to start. Any help, pointers or examples of such usage will be greatly appreciated
2
0
618
Dec ’24
Is this right way to use NSString BytesNoCopy ?
In my project, i am initialising bytes with some character in cpp function, func CreateByteWithVal (), and passing to a function, func CreateNSStringFromCString(_ pPtr : UnsafeMutableRawPointer, _ pLength : Int), in swift using Swift-Cpp interop. CreateByteWithVal () allocates bytes on heap with value "AAAAAAAAAA", also calls swift function CreateNSStringFromCString. And func CreateNSStringFromCString (_ pPtr : UnsafeMutableRawPointer, _ pLength : Int) creates a NSString instance using NSString's BytesNoCopy initialiser using the bytes (pPtr) passed to it in parameter. Cpp code: void CppClass::CreateByteWithVal () { char * bytesForString = (char *) malloc (10); memset (bytesForString, 65, 10); Interop_Swift::CreateNSStringFromCString (bytesForString, 10); } Swift code: public func CreateNSStringFromCString (_ pPtr : UnsafeMutableRawPointer, _ pLength : Int) { let ns_string:NSString = NSString (bytesNoCopy: pPtr, length: pLength, encoding: String.Encoding.utf8.rawValue, freeWhenDone: false) } If we modify the byte values in memory from C++ directly, the NSString instance, which is supposed to be immutable by nature, reflects these changes. Is this approach appropriate, or is there something we're overlooking or need to address? In our project, we are mutating the byte values directly like this, and the changes are being reflected in the NSString instance : memset (bytesForString, 66, 5); Essentially, I want to confirm whether we can use this method to modify values through C++ without directly mutating the NSString instance. For the UI, we'll be reading the NSString instance by creating a native Swift String instance from it, like this: let str:String = ns_string as String Will the value of str remain consistent as long as we ensure that the correct bytes are provided by C++?
2
0
663
Dec ’24