XPC error when using MLMediaLibrary from the command line daemon

I am writing a command line daemon to read images from iPhoto.

I can initialize and load the MLMediaLibrary tag from a full-blown Cocoa application created using the Xcode project creation tools. However, when I try to do the same from a command line tool (also created in Xcode), the following error appears in the Xcode console window:

 MLMediaLibrary error obtaining remote object proxy: Error Domain=NSCocoaErrorDomain Code=4097 "Couldn't communicate with a helper application." 

How can I access MLMediaLibrary from the command line tool?

+5
source share
2 answers

To access MLMediaLibrary your application must be isolated and encoded.

Update

It looks like you also need to add some read-only permissions to your .entitlements file.

If you want to access photos, iPhoto or Aperture libraries:

 <key>com.apple.security.assets.pictures.read-only</key> <true/> 

If you want to access iMovie and FinalCut:

 <key>com.apple.security.assets.movies.read-only</key> <true/> 

If you want to access iTunes or logic:

 <key>com.apple.security.assets.music.read-only</key> <true/> 

Here you can read about my poor experience in the MediaLibrary environment: https://devforums.apple.com/message/1125821

+6
source

I don't think Konstantin’s statement is true: In order to access MLMediaLibrary your application has to be sandboxed and codesigned.

In my test, I can use MediaLibrary.framework in my application, and my application is not signed with code, it does not have a rights file, so it is clearly not an isolated application.

-2
source

Source: https://habr.com/ru/post/1215234/


All Articles