MLMediaLibrary, cannot connect / path not allowed in target domain

Hi, I am trying to create a plugin to get photos/album information for macOSX, and I first tried using the photokit framework, but then realized it was missing stuff in the osx version. So I tried using the MLMediaLibrary, but cannot find a lot of information about it. I followed the instruction from

http://stackoverflow.com/questions/30144547/programmatic-access-to-the-photos-library-on-mac-os-x-photokit-photos-framewo

but when I run my app, it shows me this first error : Path not allowed in target domain : type = pid, path = /Library/frameworks/iTunesLibrary.framework/Versions/A/XPCServices/com.apple.iTunesLibraryService.xpc error = 147: The specified service did not ship in the requestors bundle, origin = /System/Library/Frameworks/MediaLibrary.framework/Versions/A/XPCServices/com.apple.MediaLibraryService.xpc


And then later on i get : unrecognized selector sent to instance 0x608000007950, and under it I can see it is trying to call setMediaLibrary:.


And lastly : Terminating app due to uncaught exception NSInvalidArgumentException, reson: -[MLMediaLibrary copyWithZone:] unrecognized selector sent.


So if anyone could help with that. Or show me a sample project that show how that framework works.


Here is the output :




2016-01-26 09:47:14.079 TestPhoto[75390:4288239] __38-[MLMediaLibraryImpl connectToService]_block_invoke connection interrupted

2016-01-26 09:47:14.080 TestPhoto[75390:4288201] -[MLMediaLibrary copyWithZone:]: unrecognized selector sent to instance 0x608000007950

2016-01-26 09:47:14.080 TestPhoto[75390:4288239] MLMediaLibrary error obtaining remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn’t communicate with a helper application." (connection to service named com.apple.MediaLibraryService) UserInfo=0x61800007b780 {NSDebugDescription=connection to service named com.apple.MediaLibraryService}

2016-01-26 09:47:14.082 TestPhoto[75390:4288201] An uncaught exception was raised

2016-01-26 09:47:14.082 TestPhoto[75390:4288201] -[MLMediaLibrary copyWithZone:]: unrecognized selector sent to instance 0x608000007950

2016-01-26 09:47:14.082 TestPhoto[75390:4288201] (

0 CoreFoundation 0x00007fff9468d03c __exceptionPreprocess + 172

1 libobjc.A.dylib 0x00007fff949a776e objc_exception_throw + 43

2 CoreFoundation 0x00007fff946900ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205

3 CoreFoundation 0x00007fff945d5e24 ___forwarding___ + 1028

4 CoreFoundation 0x00007fff945d5998 _CF_forwarding_prep_0 + 120

5 libobjc.A.dylib 0x00007fff949a8005 objc_setProperty_nonatomic_copy + 39

6 XcodePlugin 0x000000010e902627 -[XcodePlugin setMediaLibrary:] + 55

7 XcodePlugin 0x000000010e901e9c -[XcodePlugin Initialize] + 492

8 XcodePlugin 0x000000010e902511 _Initialize + 65

9 ??? 0x0000000110ed420f 0x0 + 4578951695

10 libmono.0.dylib 0x0000000101bfd10c mono_jit_runtime_invoke + 1753

11 libmono.0.dylib 0x0000000101d2b3f6 mono_runtime_invoke + 117

12 TestPhoto 0x0000000100b143ef _ZN19ScriptingInvocation6InvokeEPP13MonoExceptionb + 47

13 TestPhoto 0x0000000100b02111 _ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE19ScriptingMethodMonoP10MonoObjectPP13MonoException + 1585

14 TestPhoto 0x0000000100b02373 _ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE19ScriptingMethodMonoP10MonoObject + 51

15 TestPhoto 0x00000001008e017e _ZN18DelayedCallManager6UpdateEi + 766

16 TestPhoto 0x0000000100aa72a4 _Z10PlayerLoopbbP10IHookEvent + 996

17 TestPhoto 0x000000010106c6b1 -[PlayerAppDelegate UpdatePlayer] + 241

18 Foundation 0x00007fff96f89a23 __NSFireTimer + 95

19 CoreFoundation 0x00007fff945e02e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20

20 CoreFoundation 0x00007fff945dff73 __CFRunLoopDoTimer + 1059

21 CoreFoundation 0x00007fff9465353d __CFRunLoopDoTimers + 301

22 CoreFoundation 0x00007fff9459b608 __CFRunLoopRun + 2024

23 CoreFoundation 0x00007fff9459abd8 CFRunLoopRunSpecific + 296

24 HIToolbox 0x00007fff950c856f RunCurrentEventLoopInMode + 235

25 HIToolbox 0x00007fff950c82ea ReceiveNextEventCommon + 431

26 HIToolbox 0x00007fff950c812b _BlockUntilNextEventMatchingListInModeWithFilter + 71

27 AppKit 0x00007fff91ef98ab _DPSNextEvent + 978

28 AppKit 0x00007fff91ef8e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346

29 AppKit 0x00007fff91eeeaf3 -[NSApplication run] + 594

30 AppKit 0x00007fff91e6b244 NSApplicationMain + 1832

31 TestPhoto 0x000000010106b1b2 _Z10PlayerMainiPPKc + 626

32 TestPhoto 0x0000000100002334 start + 52

)

2016-01-26 09:47:14.083 TestPhoto[75390:4288201] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MLMediaLibrary copyWithZone:]: unrecognized selector sent to instance 0x608000007950'

*** First throw call stack:

(

0 CoreFoundation 0x00007fff9468d03c __exceptionPreprocess + 172

1 libobjc.A.dylib 0x00007fff949a776e objc_exception_throw + 43

2 CoreFoundation 0x00007fff946900ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205

3 CoreFoundation 0x00007fff945d5e24 ___forwarding___ + 1028

4 CoreFoundation 0x00007fff945d5998 _CF_forwarding_prep_0 + 120

5 libobjc.A.dylib 0x00007fff949a8005 objc_setProperty_nonatomic_copy + 39

6 XcodePlugin 0x000000010e902627 -[XcodePlugin setMediaLibrary:] + 55

7 XcodePlugin 0x000000010e901e9c -[XcodePlugin Initialize] + 492

8 XcodePlugin 0x000000010e902511 _Initialize + 65

9 ??? 0x0000000110ed420f 0x0 + 4578951695

10 libmono.0.dylib 0x0000000101bfd10c mono_jit_runtime_invoke + 1753

11 libmono.0.dylib 0x0000000101d2b3f6 mono_runtime_invoke + 117

12 TestPhoto 0x0000000100b143ef _ZN19ScriptingInvocation6InvokeEPP13MonoExceptionb + 47

13 TestPhoto 0x0000000100b02111 _ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE19ScriptingMethodMonoP10MonoObjectPP13MonoException + 1585

14 TestPhoto 0x0000000100b02373 _ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE19ScriptingMethodMonoP10MonoObject + 51

15 TestPhoto 0x00000001008e017e _ZN18DelayedCallManager6UpdateEi + 766

16 TestPhoto 0x0000000100aa72a4 _Z10PlayerLoopbbP10IHookEvent + 996

17 TestPhoto 0x000000010106c6b1 -[PlayerAppDelegate UpdatePlayer] + 241

18 Foundation 0x00007fff96f89a23 __NSFireTimer + 95

19 CoreFoundation 0x00007fff945e02e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20

20 CoreFoundation 0x00007fff945dff73 __CFRunLoopDoTimer + 1059

21 CoreFoundation 0x00007fff9465353d __CFRunLoopDoTimers + 301

22 CoreFoundation 0x00007fff9459b608 __CFRunLoopRun + 2024

23 CoreFoundation 0x00007fff9459abd8 CFRunLoopRunSpecific + 296

24 HIToolbox 0x00007fff950c856f RunCurrentEventLoopInMode + 235

25 HIToolbox 0x00007fff950c82ea ReceiveNextEventCommon + 431

26 HIToolbox 0x00007fff950c812b _BlockUntilNextEventMatchingListInModeWithFilter + 71

27 AppKit 0x00007fff91ef98ab _DPSNextEvent + 978

28 AppKit 0x00007fff91ef8e58 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346

29 AppKit 0x00007fff91eeeaf3 -[NSApplication run] + 594

30 AppKit 0x00007fff91e6b244 NSApplicationMain + 1832

31 TestPhoto 0x000000010106b1b2 _Z10PlayerMainiPPKc + 626

32 TestPhoto 0x0000000100002334 start + 52

)

libc++abi.dylib: terminating with uncaught exception of type NSException

Accepted Reply

So to fix "unrecognized selector sent to instance", I only had to change my variable property from copy to retain.


@property(nonatomic, retain) MLMediaLibrary *mediaLibrary;

Replies

So to fix "unrecognized selector sent to instance", I only had to change my variable property from copy to retain.


@property(nonatomic, retain) MLMediaLibrary *mediaLibrary;

HI Denise,


I am still stuck with the issue -


MLMediaLibrary error obtaining remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.MediaLibraryService" UserInfo={NSDebugDescription=connection to service named com.apple.MediaLibraryService}

The same code works if I create a test App, but does not work from within my Application. Do you have any clues if I could be missing out something obvious.


Thanks,

Priya