Objective-C Runtime

RSS for tag

The Objective-C runtime is a runtime library that supports the dynamic properties of the Objective-C language.

Objective-C Runtime Documentation

Posts under Objective-C Runtime tag

20 Posts
Sort by:
Post not yet marked as solved
8 Replies
3.9k Views
I'm unable to run my app with ASAN enabled when targeting a physical iOS device. Simulator targets do work. With Xcode 12 and an iPad mini 4 running iOS 14 beta 1 I get the following error during app launch ==750==ERROR: AddressSanitizer failed to allocate 0xffffffffff9fc000 (-6307840) bytes at address 2db624000 (errno: 22) ==750==ReserveShadowMemoryRange failed while trying to map 0xffffffffff9fc000 bytes. Perhaps you're using ulimit -v With Xcode 11.5 and an iPad Air 2 running OS 12.4.1 the error is ==2177==Unable to find a memory range after restricting VM. ==2177==AddressSanitizer CHECK failed: /BuildRoot/Library/Caches/com.apple.xbs/Sources/clangcompilerrt/clang-1103.0.32.62/compiler-rt/lib/asan/asanmac.cc:92 "((0 && "cannot place shadow after restricting vm")) != (0)" (0x0, 0x0) <empty stack>==2177==AddressSanitizer CHECK failed: /BuildRoot/Library/Caches/com.apple.xbs/Sources/clangcompilerrt/clang-1103.0.32.62/compiler-rt/lib/asan/../sanitizercommon/sanitizermallocmac.inc:143 "((!asaninitisrunning)) != (0)" (0x0, 0x0) warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available. AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report. (lldb) thread info -s thread #1: tid = 0x1076c2, 0x000000011531e984 libclangrt.asaniosdynamic.dylib`__asan::AsanDie() My coworker is able to use ASAN with the same App using iPad Pro 10.5, iPadOS 13.5.1, Xcode 11.5 Are there any configuration changes I need to make to be able to use ASAN on my devices?
Posted
by
Post not yet marked as solved
9 Replies
1.6k Views
my app is newsstand app. it is success download issue in my app with iOS14 & iOS15 simulate. when i try on real device, it fail to download. log Error Domain=NSCocoaErrorDomain Code=513 "“1318303744724624100” couldn’t be moved because you don’t have permission to access “Caches”." UserInfo={NSSourceFilePathErrorKey=/var/mobile/Media/Downloads/7803184277104936561/1318303744724624100, NSUserStringVariant=(   Move ), NSDestinationFilePath=/private/var/mobile/Containers/Data/Application/1C6FE6AF-1670-48ED-BE04-2806C8AECC65/Library/Caches/bgdl-4119-6c4a7ac1c9c0c671.xzip, NSFilePath=/var/mobile/Media/Downloads/7803184277104936561/1318303744724624100, NSUnderlyingError=0x282aa3d80 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} i have set Privacy - Downloads Folder Usage Description in info.plist please help
Posted
by
Post not yet marked as solved
2 Replies
4k Views
objc[2247]: Class _PathPoint is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x11a0e8a78) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI (0x130fb08b0). One of the two will be used. Which one is undefined. objc[2247]: Class _PointQueue is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x11a0e8a50) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI (0x130fb08d8). One of the two will be used. Which one is undefined.
Posted
by
Post not yet marked as solved
2 Replies
353 Views
Hi all, I am experiencing crash issue when my app is trying to register the device for notification function. It runs well on a iphone 6 device with ios 11, but this line of code crashes on a newer iphone model with latest ios 15. self.hub registerTemplateWithDeviceToken:sharedManager.pushTokenData name:@"myTemplate" jsonBodyTemplate:template expiryTemplate:nil tags:tagSet completion:^(NSError *error) Have anyone of you encountered similar issue before? Or is it possible that there is some configuration settings I may left out in XCode? Thanks a lot in advance.
Posted
by
Post not yet marked as solved
0 Replies
396 Views
Hello, I'm trying to address the following crash from an old Objective-C code. Crashed: com.apple.main-thread 0 libobjc.A.dylib 0x88e8 object_isClass + 16 1 Foundation 0x1d748 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 48 2 Foundation 0x2be10 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 284 3 Foundation 0x21c5c -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 72 4 Foundation 0x2daf8 _NSSetBoolValueAndNotify + 316 5 SDKCore 0x47854 __45-[CameraSession processPhoto:orientation:]_block_invoke_3 + 239 (CameraSession.m:239) 6 libdispatch.dylib 0x2914 _dispatch_call_block_and_release + 32 7 libdispatch.dylib 0x4660 _dispatch_client_callout + 20 8 libdispatch.dylib 0x12b60 _dispatch_main_queue_callback_4CF + 944 9 CoreFoundation 0x51cd4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 10 CoreFoundation 0xbeac __CFRunLoopRun + 2540 11 CoreFoundation 0x1f3b8 CFRunLoopRunSpecific + 600 12 GraphicsServices 0x138c GSEventRunModal + 164 13 UIKitCore 0x5196a8 -[UIApplication _run] + 1100 14 UIKitCore 0x2987f4 UIApplicationMain + 2092 15 MyApp 0x79bc main + 11 (main.swift:11) 16 ??? 0x102161a24 (Missing) The crash is due to setting takingPhoto to NO in - (void)processPhoto:(AVCapturePhoto *)photo orientation:(UIDeviceOrientation)orientation. From what I understand, the crash would be caused by a released observer receiving the notification, but I don't see how it's possible given the following code (this is an excerpt with relevant parts). @implementation CameraSession @synthesize takingPhoto = _takingPhoto; - (void)dealloc { [self _cleanupObservers]; } - (instancetype)init { self = [super init]; if (self) { [self _setupObservers]; } return self; } - (void)setTakingPhoto:(BOOL)takingPhoto { if (!takingPhoto) { [self.triggerDecider reset]; } _takingPhoto = takingPhoto; } - (BOOL)isTakingPhoto { return _takingPhoto; } - (void)takePhoto { if (self.isTakingPhoto) { return; } self.takingPhoto = YES; // … [self.capturePhotoOutput capturePhotoWithSettings:[self buildCapturePhotoSettings] delegate:self]; } - (void)processPhoto:(AVCapturePhoto *)photo orientation:(UIDeviceOrientation)orientation { dispatch_async(self.captureSessionQueue, ^{ [self.delegate cameraSessionDidSnapPhoto:self]; [self.cameraCaptureHandler processPhoto:photo orientation:orientation onSuccess:^(Scan *scan) { dispatch_async(dispatch_get_main_queue(), ^{ self.takingPhoto = NO; [self.delegate cameraSession:self didGenerateScan:scan]; }); } failure:^(NSError *error) { self.takingPhoto = NO; [self.delegate cameraSession:self didFailToSnapPhotoWithError:error]; }]; }); } #pragma mark - KVO - (void)_setupObservers { [self addObserver:self forKeyPath:@"takingPhoto" options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew context:CameraSessionKVOContext]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionRuntimeError:) name:AVCaptureSessionRuntimeErrorNotification object:self.captureSession]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionDidStartRunning:) name:AVCaptureSessionDidStartRunningNotification object:self.captureSession]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionDidStopRunning:) name:AVCaptureSessionDidStopRunningNotification object:self.captureSession]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionWasInterrupted:) name:AVCaptureSessionWasInterruptedNotification object:self.captureSession]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionInterruptionEnded:) name:AVCaptureSessionInterruptionEndedNotification object:self.captureSession]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil]; } - (void)_cleanupObservers { [self removeObserver:self forKeyPath:@"takingPhoto" context:CameraSessionKVOContext]; [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context { if (context == CameraSessionKVOContext) { if (object == self && [keyPath isEqualToString:@"takingPhoto"]) { // While taking the photo, stop processing video frames // ... } } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } @end Am I missing something here? Thanks! Bruno
Posted
by
Post not yet marked as solved
1 Replies
404 Views
Hi. I am working on Xcode 13.1 When I am building my code and running it on my iPhone (Not on the simulator), the code is crashing. Below is the error message. Please help me out anyone..... *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument' *** First throw call stack: (0x1827e9cac 0x199858758 0x183f3c0e0 0x183f12d64 0x103288590 0x1032884b4 0x103288d30 0x102d87544 0x102d86000 0x184c59804 0x184c5c178 0x184d57360 0x184d53a04 0x184f6c928 0x184e4be78 0x184d7a73c 0x1dc3649d4 0x184c3ab28 0x1862a4c4c 0x186297d40 0x1862ab4a4 0x1862b408c 0x184c14b50 0x182795f34 0x182767578 0x182762b0c 0x182775d8c 0x19c8829a0 0x184faafa8 0x184d3f22c 0x102d5bbb0 0x104288190) libc++abi: terminating with uncaught exception of type NSException dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument' terminating with uncaught exception of type NSException
Posted
by
Post not yet marked as solved
0 Replies
341 Views
we got the following crash from one of our customers: crash log this is happening once they initialize our SDK, with the following command: public static func initialize() { SDKManager.shared().setup(AppKey) } the shared() call doesn't seem to have the crash error since it uses a dispatch_once which in that case would have been displayed in the crash log. the setup method is just a facade method that calls another method which acts as facade as well. after this, in the 3rd method there is bunch of things happening. the issue is that if we look into the crash log, we see only 2 calls to the SDK framework, which like i said are only 2 facades. - (void)setup:(NSString *)appKey {   [self initSDK:appKey]; } - (void)initSDK:(NSString *)appKey {   [self initSDK:appKey withParams:nil]; } its also not clear, what does the mention of objc-runtime-new.mm have to do with this crash since the SDK does not import or access any runtime objects. also, unfortunately we do not have a valid dsym to decrypt the 2 calls pointing to the SDK.
Posted
by
Post not yet marked as solved
4 Replies
428 Views
Hi, For some of my use cases, I'm extending an interface using a category. I am overriding some of the methods in the base Interface, but want to call the base interface method after I'm done with the workflow inside the category method. Essentially, doing something similar to a "super" call. While I was looking into how to achieve this, have found something called Method Swizzling( https://nshipster.com/method-swizzling/ , https://newrelic.com/blog/best-practices/right-way-to-swizzle), but this looks too 'hacky'. Is there a better way to achieve this?
Posted
by
Post not yet marked as solved
3 Replies
406 Views
How to deduce from NSMethodSignature that a struct argument is passed by pointer? Specifically on ARM. For example if I have: @protocol TestProtocol <NSObject> - (void)time:(CMTime)time; - (void)rect:(CGRect)point; @end And then I do: struct objc_method_description methodDescription1 = protocol_getMethodDescription(@protocol(TestProtocol), @selector(time:), YES, YES); struct objc_method_description methodDescription2 = protocol_getMethodDescription(@protocol(TestProtocol), @selector(rect:), YES, YES); NSMethodSignature *sig1 = [NSMethodSignature signatureWithObjCTypes:methodDescription1.types]; NSMethodSignature *sig2 = [NSMethodSignature signatureWithObjCTypes:methodDescription2.types]; const char *arg1 = [sig1 getArgumentTypeAtIndex:2]; const char *arg2 = [sig2 getArgumentTypeAtIndex:2]; NSLog(@"%s %s", methodDescription1.types, arg1); NSLog(@"%s %s", methodDescription2.types, arg2); The output is: v40@0:8{?=qiIq}16 {?=qiIq} v48@0:8{CGRect={CGPoint=dd}{CGSize=dd}}16 {CGRect={CGPoint=dd}{CGSize=dd}} Both look similar, no indication that CMTime will be actually passed as a pointer. But when I print the debug description: NSLog(@"%@", [sig1 debugDescription]); NSLog(@"%@", [sig2 debugDescription]); The first prints: ... argument 2: -------- -------- -------- -------- type encoding (^) '^{?=qiIq}' flags {isPointer} ... While the second prints: ... argument 2: -------- -------- -------- -------- type encoding ({) '{CGRect={CGPoint=dd}{CGSize=dd}}' flags {isStruct} ... So this information is indeed stored in the method signature, but how do I retrieve it without parsing the debug description? Are there rules I can use to deduce this myself? I tried to experiment with different structs but it is hard to spot a pattern.
Posted
by
Post marked as solved
3 Replies
292 Views
This is a derivative of this and this. On iOS 15(.3.1), if I just try to fetch and enumerate the classes of the objc runtime, waiting until viewDidAppear() to make sure there wasn't some initialization issue: var count = UInt32(0) var classList = objc_copyClassList(&count)! print("COUNT \(count)") print("CLASS LIST \(classList)") for i in 0..<Int(count) { print("\(i)") classList[i] } produces the following before a Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1820e0cdc) COUNT 28353 CLASS LIST 0x000000010bf24000 0 1 2 2022-02-17 16:24:02.977904-0800 TWiG V[2504:705046] *** NSForwarding: warning: object 0x1dbd32148 of class '__NSGenericDeallocHandler' does not implement methodSignatureForSelector: -- trouble ahead 2022-02-17 16:24:02.978001-0800 TWiG V[2504:705046] *** NSForwarding: warning: object 0x1dbd32148 of class '__NSGenericDeallocHandler' does not implement doesNotRecognizeSelector: -- abort I don't know how to do any less with it than just fetching the value. I'm not trying to print it or anything, and yet it still fails. Is there some magic I'm missing? Why have the API if the results crash your program? If the issue is legit, it would be nice of the docs pointed out a workaround, or at least the proper way to cope with the result. (I do not have hardened runtime turned on, XCode 13.2.1)
Posted
by
Post not yet marked as solved
2 Replies
358 Views
I understand what the *.tbd files are doing however what I don't understand is why when I look at the install-name: key there is a path for the actual *.dylib library however I cannot see these, they don't exist with ls. For example below is the head of the MacOSX11.3.sdk/usr/lib/libblas.tbd yaml file: --- !tapi-tbd tbd-version: 4 targets: [ x86_64-macos, x86_64-maccatalyst, x86_64h-macos, x86_64h-maccatalyst, arm64-macos, arm64-maccatalyst, arm64e-macos, arm64e-maccatalyst ] uuids: - target: x86_64-macos value: 86F0C2E1-6A2D-34E8-AA84-D4224BB49B33 - target: x86_64-maccatalyst value: 86F0C2E1-6A2D-34E8-AA84-D4224BB49B33 - target: x86_64h-macos value: 8151F97D-CE36-3B38-AEF0-AAC55E9F537B - target: x86_64h-maccatalyst value: 8151F97D-CE36-3B38-AEF0-AAC55E9F537B - target: arm64-macos value: 00000000-0000-0000-0000-000000000000 - target: arm64-maccatalyst value: 00000000-0000-0000-0000-000000000000 - target: arm64e-macos value: 46295B04-B6A4-36A1-A4F7-C9B606CF75A5 - target: arm64e-maccatalyst value: 46295B04-B6A4-36A1-A4F7-C9B606CF75A5 install-name: '/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib' exports: - targets: [ arm64e-macos, x86_64-macos, x86_64h-macos, x86_64-maccatalyst, It says the install-name is /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib But I cannot see this file and I am afraid neither can the projects I am trying to compile with cmake/make. $ ls /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib ls: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib: No such file or directory
Posted
by
Post marked as solved
1 Replies
412 Views
The metal-cpp wrapper released end of last year wraps the Metal 2 API, and by extension the basic NS foundation, in C++ code. From looking through the code, metal-cpp uses the objc/runtime.h header and uses objc_msgSend and sel_registerName to fetch pointers and call methods as if it were Objective-C code. This mostly works, however I've come across an issue where the renderCommandEncoderWithDescriptor: selector fails to load through sel_registerName. My application creates the default metal device, a command queue, a CAMetalLayer and I can present the drawable through a command buffer and all of it works. However, if I want to start actually rasterising any geometry, I need a MTLRenderCommandEncoder. To create one, I need to call renderCommandEncoderWithDescriptor: on a MTLCommandBuffer, which causes a segfault because the selector is 0x0 and the Objective-C runtime code tries to read from it. This short snippet is where the segfault occurs. Calling MTL::CommandBuffer::renderCommandEncoder will call the objc_msgSend with a 0x0 selector. auto buffer = queue->commandBuffer(); auto encoder = buffer->renderCommandEncoder(renderPass); MTLCommandBuffer buffer = [queue commandBuffer]; MTLRenderCommandEncoder encoder = [buffer renderCommmandEncoderWithDescriptor:renderPass]; And this would be the equivalent in raw Objective-C code, which does in fact work. I have uploaded a small test example to GitHub: https://github.com/spnda/metal-cpp-bug. This example uses GLFW to create the window and I use a small Objective-C++ file to modify the NSWindow and CAMetalLayer, as the metal-cpp wrapper curiously does not provide wrappers for these classes. I am personally on macOS Monterey 12.3 with a M1 iMac 24", it would be interesting to see if this is an issue with everybody, or just specific to my setup. Not being able to create a MTL::RenderCommandEncoder makes Apple's official Metal C++ wrappers absolutely useless for any rendering, and I would much appreciate any help to fix this issue.
Posted
by
Post not yet marked as solved
1 Replies
248 Views
Hi everyone, How should I find the root cause of this type of crash with 0x08fd4dbfade2dead? Some file descriptor which is protected but my code closed it, is it correct? But Here's the crash log and from top is close + 8, stack num.1 is a CFRelease(a) function, we do check if a is null before call CFRelease on it. And the for next a few lines are (number 2-6), we don't see any of those function calls open or close a file, no socket network call at all. No sqlite, coredata or even dup and etc... Is there a memory management issue which makes the a point to somewhere else which is the file descriptor?
Posted
by
Post not yet marked as solved
1 Replies
344 Views
My application is currently crashing in production in iPhone devices running iOS 15.x. The app will work as normal while running developer mode, enterprise builds and Test Flight builds. Unfortunately, I am unable to reproduce this issue even app is downloaded from the app store. I observed crash is happening at main.m. Can someone help me to reproduce this issue? How to read this crash log file? Please find the crash log details attached. 2022-03-04_14-15-23.6227_+0900-a1899fd803a4ed683466702be71b9d224b4cd5bc.crash
Posted
by
Post not yet marked as solved
2 Replies
359 Views
We have noticed recently that when our app is installed from the App Store, it is automatically launched into the background. After the App Store installs our app, it is started into the background (no UI) without the user pressing ‘Open’ from the App Store or tapping the app icon in the home screen. Testing with iOS 15. I assume this is not the correct behavior, an app automatically being launched after being installed. I submitted a bug report (FB9971657), but wanted to know if anyone else was seeing this behavior.
Posted
by
Post marked as solved
1 Replies
242 Views
I'm developing an app using CoreNFC but it crashes when running on iPhone 6 with iOS 12.5 . Trying to search for an answer I didn't find any solution. When launching the app, this is the error I read in the console: dyld: Library not loaded: /System/Library/Frameworks/CoreNFC.framework/CoreNFC Referenced from: /var/containers/Bundle/Application/327CB0C3-4B7F-4B72-8F70-EEE985F688CD/myAppName.app/myAppName Reason: image not found I've already added CoreNFC.Framework in Targets -> General -> Frameworks, Libraries, and Embedded Content and set it to "Do Not Embed" but it doesn't work. Is there any solution for this? Or is it a bug of Xcode? Please help. Thanks
Posted
by
Post not yet marked as solved
0 Replies
121 Views
Hi, I have an application Unity that uses the iOS static library. Then this application Unity is build in XCode. I found several utilities that allow you to obfuscate the library in the application. for example this -PPiOS-Rename. I carefully read their documentation "Obfuscate Static Libraries", but at the time of building, the iOS static library are already "hidden in the root" of the Unity app, and XCode cannot obfuscate this. so I need to first obfuscate the library and then add it to the application. Maybe you can suggest another tool(or workaround)? I'll be very grateful.
Posted
by
Post not yet marked as solved
1 Replies
133 Views
Hi I have an objective project and when I'm extending the project to Swift It works fine when locally testing it and also when testing it over testflight. But after submitting the app to the appstore and when users download it and use I see crash reports coming from the Sentry related with the swift extensions created over the objective-c class. I'm unable to reproduce this locally. Any Help would be appreciated. Attached the crash report. 605534285f8e4c96af32cf25bb283439-symbolicated.crash
Posted
by