Further to Shane’s good advice.
I thought I would post my findings on the iTunesLibrary.framework for others who may be interested.
You can indeed use and test in debug development mode with the iTunesLibrary.framework in an ASOC Xcode project.
But as Shane stated, you must code sign your compiled app before it will work with the framework.
to access the classes in the framework, you must first import it into your Xcode project, and to do this you must highlight the topmost project item in the left project file browser in Xcode, and then select the Apps TARGETS item, and not the App’s PROJECT item.
Next select the “General” tab at the top at the Xcode window, and scroll down to the “Linked Frameworks and Libraries” disclosure triangle, then click the triangle and then the displayed “+” symbol.
This will show a window where you can select and add Frameworks and Libraries to your project, but as you’ll notice the iTunesLibrary.framework is not listed, so you have to click the “Add Other…” button and navigate to /Library/Frameworks/iTunesLibrary.framework. and double click this file to add the framework to your project.
The first thing you have to do in order to work with the framework classes, is to create the ITLibrary parent class object, and I’ve posted a simple example below of creating this and then creating a ITLibArtwork class object, which you can then use to get the NSImage file icon of any media file.
try
-- Create the Parent ITLibrary class object
set theiTunesLibrary to current application's ITLibrary's libraryWithAPIVersion:("1.0" as text) |error|:(missing value)
-- Create the ITLibArtwork class object for a valid NSURL class object of a media file
set theAudioFileArtwork to theiTunesLibrary's artworkForMediaFile:(theAudioFileURL)
-- Create an NSImage class object from the ITLibArtwork's image() instance method
set theAudioFileImage to theAudioFileArtwork's image() <-- Returns an NSImage
on error
-- An Error Occurred
end try
In the first line in the above code you can set the APIVersion installed on your system, I have version “3.0” installed on my system, although any version from “1.0” to “3.0” works for me.
You can check the installed version by navigating to the iTunesLibrary.framework file in Finder, then double clicking the framework file to reveal it’s contents, and then double clicking the Resources folder to reveal the versions.plist file.
You can also call the apiMajorVersion() and apiMinorVersion() instance methods of the ITLibrary, to get the current installed version, although you have to create an instance of the ITLibrary first before being able to use these methods.
Here’s a link to the iTunesLibrary.framework’s documentation, as there’s a lot of other stuff in there worth checking out.
https://developer.apple.com/library/mac/documentation/iTunesLibrary/Reference/iTunesLibraryFrameworkReference/
Regards Mark