Using the New iTunesLibrary Platform to Access iTunes Library on Mac OS-X

I am looking at how to add access to the iTunes library for the Mac application that I am developing.

I reviewed some of the existing open source implementations, such as EyeTunes and iMedia - but found that they were not quite what I was looking for. Overkill in general.

So, I tried using the Scripting Bridge and found that while the functionality was slow. And since I didn't need to control iTunes, slowness was not worth it. He also had the disadvantage of using iTunes to work. It is also a little annoying to make it work in an isolated application (although this is possible).

So, I finally started the roll myself by reading the iTunes Library.xml file. It seems to be working fine. But in the process of studying the value of the key / value of the Distinguished Kind, I came across a completely new one, Apple provided iTunesLibrary.framework !!!

Nice - iTunesLibrary documentation documents are here.

However, when I try to initialize the framework using code, as shown in the link link:

NSError * error = nil; ITLibrary* library = [ITLibrary libraryWithAPIVersion:@"1.0" error:&error]; 

It returns nil and provides a very useful error, for example (in my Sandboxed application):

Domain Error = NSPOSIXErrorDomain Code = 100001 "Failed to load." UserInfo = 0x1140025b0 {NSLocalizedDescription = Failed to load., NSUnderlyingError = 0x1026fbe20 "Operation could not be completed. (Error OSStatus -50.)"}

Thinking it might be a sandbox problem, I also created a quick command line utility that tries to initialize the library, and it returns an almost identical error:

Could not open library: Domain Error = NSPOSIXErrorDomain Code = 100001 "Could not load." UserInfo = 0x1018015b0 {NSLocalizedDescription = Could not load., NSUnderlyingError = 0x103a000e0 "The operation could not be completed. (OSStatus Error 100005.)"}

Has anyone else tried this new iTunes Library with more luck than mine?

// EDIT: The following is the correct answer. Code signing required. The sample code in the response is a convenient starting point for using the framework. In addition, in my case, the problem was also that the iTunesLibrary infrastructure code does not work when the iTunes library is located on a network drive. Make it a bit of a bargain if Apple doesn't solve it.

+7
source share
3 answers

You will need the code name of your application using the certificate from the Mac Developer Program.

This is not documented anywhere, but, in my suspicion, this requirement was added due to the fact that the iTunes cloud is a web service that requires access to user accounts.

// Change . In addition to setting CODE_SIGN_IDENTITY in the project settings, as discussed above, you also need to add /Library/Frameworks to FRAMEWORK_SEARCH_PATHS in the project settings so that Xcode knows where to look for # import.

// Change 2 . I wrote a small little sample application to show how iTunesLibrary is used, since the Apple code and documentation example is pretty meager: https://github.com/zadr/iTunesLibraryExample

+6
source

From iTunes Library Reference

  • You must sign your application to receive information from the iTunes Library Structure.
  • The iTunes library frame is available to users of iTunes v11.0 or higher.
+4
source

Not sure if this is true for all of you, but in my case I saved Code-Signing-Identity to - . Now I do not need to sign the application.

0
source

All Articles