Objective-C Runtime

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

31 results found
Post marked as unsolved
173 Views

KVO observation info is lost causing a crash when removing observers

Hi everyone. When iOS 14 beta 5 was released we started getting a crash on our app, the classic "Cannot remove an observer <XYZBinding 0x600000d6b750> for the key path "state" from <XYZEntryChat 0x7f960a77a900> because it is not registered as an observer.". However, nothing had changed in our code base to justify that, indeed the code that was crashing hadn't been changed in several months. The crash persists even in the official iOS 14 release. We investigated and, by chance, found that the observationInfo object in XYZEntryChat, that should hold the information about the registered observers, is being deallocated after being created, without any intervention from our part. Also by chance, we found that overriding either the - (void)setObservationInfo:(void *)observationInfo method or the observationInfo getter in the XYZEntryChat class the issue no longer occurs. In many other classes that use the same base code to handle bindings the issue does not occur. We have no further leads on why this is happening, it may be an iOS 14 bug or some behaviour change on iOS 14 that uncovered a wrong usage flow in our app. We also investigated if it was related to Objective-C / Swift interoperability, but other classes that also use / are used by Swift don't have the issue. Has anyone ever came across this behaviour or has any idea of what the root cause may be? Thanks in advance.
Asked
by rmendes22.
Last updated .
Post marked as unsolved
366 Views

[Big Sur] /usr/lib/libobjc.A.dylib: Cannot load Swift type information

We are having a problem when we try to assign a nil value to a @objc dynamic lazy property ... The log shows this: /usr/lib/libobjc.A.dylib: Cannot load Swift type information; failed to initialize ClangImporter: error: invalid Darwin version number: macosx11.0.0 error: invalid version number in '--target = x86_64-apple-macosx11.0.0' It usually occurs when we try to assign a nil value to a @objc dynamic lazy property. (only in Big Sur beta 5 or higher) In our tearDown() logic, we manually clear references. ... // Clear strong references to objects in other MOC's result = nil // declared property that stores some coredata objects. @objc dynamic lazy var result: Result? = {[weak self] in I found this observation in the release notes: https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11-beta-release-notes Known Issues ... New in macOS Big Sur 11 beta, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen () the path, which will correctly check for the library in the cache. (62986286) ... This problem causes an application crash. Is this a mistake? Will it be available in future versions? Will it get replaced by an alternative? Thx in advance! P.s. Out of curiosity, I didn't find the /usr/lib/libobjc.A.dylib library available in Big Sur anymore, but it is present in Catalina.
Asked
Last updated .
Post marked as unsolved
144 Views

How to call functions in c++ library from swift

Hi, I have one c\+\+ library in Macbook Pro. I am trying to call one of the API of c\+\+ lib in my swift file using Bridge-Header. I have included header & library path and included my c++ library. I have fixed all compilation errors and but facing with below linking errors. How to link C\+\+ library to swift program language? Please help me. Undefined symbols for architecture x86_64:  "std::terminate()", referenced from:    ___clang_call_terminate in libNetopsFilterLib.dylib(NetopsControl.o)  "operator delete(void*)", referenced from:    _NetopsFilterCommsInit in libNetopsFilterLib.dylib(NetopsFilterInterface.o)    _NetopsFilterCommsExit in libNetopsFilterLib.dylib(NetopsFilterInterface.o)    NetopsControl::NetopsControl() in libNetopsFilterLib.dylib(NetopsControl.o)  "operator new(unsigned long)", referenced from:    _NetopsFilterCommsInit in libNetopsFilterLib.dylib(NetopsFilterInterface.o)    NetopsControl::NetopsControl() in libNetopsFilterLib.dylib(NetopsControl.o)  "___cxa_begin_catch", referenced from:    ___clang_call_terminate in libNetopsFilterLib.dylib(NetopsControl.o)  "___gxx_personality_v0", referenced from:    _NetopsFilterCommsInit in libNetopsFilterLib.dylib(NetopsFilterInterface.o)    Dwarf Exception Unwind Info (__eh_frame) in libNetopsFilterLib.dylib(NetopsFilterInterface.o)    NetopsControl::NetopsControl() in libNetopsFilterLib.dylib(NetopsControl.o)    NetopsControl::~NetopsControl() in libNetopsFilterLib.dylib(NetopsControl.o)    Dwarf Exception Unwind Info (__eh_frame) in libNetopsFilterLib.dylib(NetopsControl.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Asked
by nagendrar.
Last updated .
Post marked as unsolved
125 Views

Memory Leak NSInvocationOperation

What is possible reason of memory leak in following code snippet, is it forming some kind of Cycles NSInvocationOperation* theOp = [[NSInvocationOperation alloc] 																initWithTarget:self 																selector:@selector(methodCall:) object:Nil]; [operationQueue addOperation:theOp]; [theOp release];
Asked
Last updated .
Post marked as unsolved
606 Views

React native won't run on device but does on simulator via xcode

When using Xcode, My app is building as expected but it is failing when it starts running with the following error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x800000002) The app doesn't crash, it continues running but it just pauses on the launch screen. However, it works as expected when running on the simulator via xcode. Also, the app was working perfectly on device just a few hours ago. Do you have any idea why it might be failing when running on a physical device? I have tried cleaning the build folder but it did not do any good.
Asked
by mrdan.
Last updated .
Post marked as unsolved
1.2k Views

my app crash in second launch on iOS 13 and above

my app crash in second launch on iOS 13 and above Need help take a look the log : 2020-08-04 14:33:45.464576+0000 ExMessager[13501:1547907] CFURLSetResourcePropertyForKey failed because it was passed an URL which has no scheme 2020-08-04 14:33:45.695751+0000 ExMessager[13501:1548827] [CoreBluetooth] XPC connection invalid 2020-08-04 14:33:45.842033+0000 ExMessager[13501:1548811] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:45.842033+0000 ExMessager[13501:1548827] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:45.842313+0000 ExMessager[13501:1548811] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:45.844058+0000 ExMessager[13501:1548827] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:45.844129+0000 ExMessager[13501:1548811] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:45.845094+0000 ExMessager[13501:1548827] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:45.845355+0000 ExMessager[13501:1548811] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:46.068121+0000 ExMessager[13501:1547907] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600001900100> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2020-08-04 14:33:46.104115+0000 ExMessager[13501:1547907] viewWillAppear 2020-08-04 14:33:50.974105+0000 ExMessager[13501:1548687] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:50.977251+0000 ExMessager[13501:1548910] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:50.981911+0000 ExMessager[13501:1548687] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:50.989947+0000 ExMessager[13501:1548910] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:50.992180+0000 ExMessager[13501:1548687] [Client] Updating selectors failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.} 2020-08-04 14:33:50.993119+0000 ExMessager[13501:1548910] [Client] Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.commcenter.coretelephony.xpc was invalidated.}
Asked
Last updated .
Post marked as unsolved
160 Views

Crash after block release, but thread stack trace doesn't hint anything

We have a mysterious crash which is reported only on BugSnag StackTrace: EXC_BAD_ACCESS	·	Attempted to dereference garbage pointer 0x20. 0libobjc.A.dylib_objc_release 1libsystem_blocks.dylib__Block_release 2libdispatch.dylib__dispatch_client_callout 3libdispatch.dylib__dispatch_continuation_pop$VARIANT$armv81 4libdispatch.dylib__dispatch_source_invoke$VARIANT$armv81 5libdispatch.dylib__dispatch_lane_serial_drain$VARIANT$armv81 6libdispatch.dylib__dispatch_lane_invoke$VARIANT$armv81 7libdispatch.dylib__dispatch_workloop_worker_thread 8libsystem_pthread.dylib__pthread_wqthread I wonder what I should look for in Threads section? Do you have any generic clue?
Asked
Last updated .
Post marked as unsolved
258 Views

Can an Objective-C implementation be defined in a header file and also be imported by multiple source files?

I have a header file that defines the interface and implementation of an Objective-C class. Person.h #ifndef Person_h #define Person_h @interface Person : NSObject(void)speak; @end @implementation Person(void)speak { 		// Say something } @end #endif /* Person_h */ I also have two source files that both include the header file. Main.mm @import Foundation; #import "Person.h" int main(int argc, const char * argv[]) { 		// Do nothing } Test.mm @import Foundation; #import "Person.h" When the project is built, I get duplicate symbol errors. duplicate symbol '_OBJC_CLASS_$_Person' in: 		/Debug/TestBox.build/Objects-normal/x86_64/main.o 		/Debug/TestBox.build/Objects-normal/x86_64/test.o duplicate symbol '_OBJC_METACLASS_$_Person' in: 		/Debug/TestBox.build/Objects-normal/x86_64/main.o 		/Debug/TestBox.build/Objects-normal/x86_64/test.o ld: 2 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) I want to be able to include the same header file in multiple source files. In C++, I can inline the implementation into the header file like this: #ifndef Person_h #define Person_h class Person { public: 		void speak() { // Say something } }; #endif /* Person_h */ However, I haven't been able to find a way to do that with Objective-C. I'm using Objective-C so I can subclass events from NSWindowDelegate and NSResponder. I tried searching for solutions. Most of them said to separate the implementation into a source file, but that would break the single-header architecture. One suggestion is to use the Objective-C runtime library - https://developer.apple.com/documentation/objectivec/objective-c_runtime and create my classes at runtime. This appears to give me the results I'm looking for, but I'm wondering if there is a simpler way. Is there some way to implement an Objective-C class in a header file so that can be included by multiple source files? Or is dynamically creating the classes at runtime my best option?
Asked
by ahzeee.
Last updated .
Post marked as unsolved
174 Views

Interactive dismissal aka. "Swipe down to dismiss" changed to "Tap to dismiss" in iOS 13.5?

We receive feedback from clients that are able to dismiss modal views by just tapping outside in iOS 13.5 and 13.5.1. Until iOS 13.5 it was ONLY possible by swiping modal down. Application has been built with XCode 10.2.1 so it was not compiled with iOS 13 SDK. Is it possible that behavior changed with a new runtime release? We have already incorporated new SDK and made all adjustments needed. Only that some clients will not upgrade yet and are asking for a patch release (for the previous version), which is tricky because there are more things to do than just adjust isModalInPresentation to make UI look good in our case. I assume for enterprise release, we can do it with XCode 10.2.1, but for AppStore, starting July, we have to use XCode 11+. Any advice?
Asked
by arturr.
Last updated .
Post marked as unsolved
204 Views

iOS14 Tagged Pointer Format

The wwdc20-10163 video indicates that in this year's release, tagged pointers in arm64 is using the highest bit to tag tagged/regular pointer, the lower 3bit to tell tagged pointer type. For type 7, which is the extended type, The pointer uses the 8 bits AFTER the highest bit to indicate which extended type is being used. However, isn't the 9th bit a part of the payload at the same time? Will there be a conflict?
Asked
Last updated .
Post marked as unsolved
135 Views

"Jump to Definition" not working consistently with target/action pattern

I've inherited a large project. Digging around the codebase has been tough because "Jump To Definition" isn't working consistently. The codebase is almost entirely in Objective-C, and I'm seeing usage of the target-action pattern like: // ViewController1.m (void)viewDidLoad { 	[super viewDidLoad]; 	UIButton *button = [UIButton new]; 	[button addTarget: self action:@selector(selected) forControlEvents: UIControlEventTouchUpInside]; } (void)selected { 		NSLog(@"selected in View Controller 1"); } When I command + control + click on the "selected" method name inside of the @selector attribute, it will jump to the definition of the wrong method. The incorrect method has the same signature: it is named "selected" and takes no arguments. But that implementation is in an unrelated class in a different source file. My first instinct was that this is a bug when using @selector, but I was not able to duplicate in a simple sample project - two source files that have a selector with the same name will behave as expected when trying to Jump to Definition. I thus believe this to be an issue due to the nature of the inherited project - it's very large, and there are over 200 existing warnings. It takes a very long time to index. I wonder if that has anything to do with it? Are there any tips for dealing with "Jump to Definition" not working in a legacy project? I plan on fixing the warnings at some point, but if there's another thing I can do in the meantime it would be helpful as I familiarize myself with the code.
Asked
by bpapa.
Last updated .
Post marked as unsolved
164 Views

Objective-C - Reflection - NSArray Generic Type

Hello, I'm trying to access the generic type of my NSArray property via reflection API. Here's my defined property: @property(nonatomic) NSArray&lt;CustomObject*&gt;* tabs; And here is my code how I access my the property via reflection: objc_property_t *properties = class_copyPropertyList(class, &amp;propertyCount); for (unsigned int i = 0; i < propertyCount; i++) { objc_property_t property = properties[i]; &#9;&#9;&#9;&#9;&#9;&#9;objc_property_t property = properties[i]; &#9;&#9;&#9;&#9;&#9;&#9;const char *propertyName = property_getName(property); &#9;&#9;&#9;&#9;&#9;&#9;const char *attrs = property_getAttributes(property); } propertyName = "tabs" is correct attrs = "T@"NSArray",&amp;,N,V_tabs" It seems like there is no information about the generic type. Also in the documentation I can't find any information about this case. https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html#//apple_ref/doc/uid/TP40008048-CH101-SW5 Isn't it possible to access the generic type of my NSArray property via reflection?
Asked
by OnlyMate.
Last updated .
Post marked as unsolved
108 Views

Setting javaScriptCanAccessClipboard breaks app for MacOS Sierra

I'm using WKWebView to display a local web app within a C application. To allow access to the clipboard without a gesture I set javaScriptCanAccessClipboard &amp; DOMPasteAllowed in WKWebViewConfiguration preferences to true. This works fine on MacOS Catalina, however I get the following error when trying to run my application on MacOS Sierra: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;WKPreferences 0x39819390&gt; setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key javaScriptCanAccessClipboard.' Not sure what I need to do to support older versions of MacOS... Any help would be greatly appreciated! Here's the code in question by the way: https://github.com/webview/webview/blob/479f58cfa815722155339527ecef997cf12a8a37/webview.h#L630-L637
Asked
Last updated .
Post marked as unsolved
97 Views

About the audio

It would be nice if the vocals were processed to soften those really high pitched SSS sounds.
Asked
Last updated .