Cannot load iTunesLibrary on swift 4

I’m new on swift 4. I’m trying to develop a simple mac program to get all music songs from iTunesLibrary. I did sign my code and import iTunesLibrary.framework to the project. But I got an error about iTlib XPC connection error:

 

2018-05-29 19:51:16.277312+0700 KODE[2325:47137] ITLib received XPC_ERROR_CONNECTION_INTERRUPTED connection 
error (can be ignored). 
2018-05-29 19:51:16.277410+0700 KODE[2325:47137] ITLib xpc error: Connection interrupted 
2018-05-29 19:51:16.277441+0700 KODE[2325:47072] Assertion failure: status == noErr (100005)

 

Here is my code

override func viewDidLoad() {
  super.viewDidLoad()

  let library: ITLibrary

  do {
  library = try ITLibrary(apiVersion: "1.0")
  } catch {
  print("Error occured!")
  return
  }

  let tracks = library.allMediaItems

  for track in tracks {
  print(track.album.title!)
  }

  // Do any additional setup after loading the view.
}

 

I did googled the XPC error but got no luck

Powered by WPeMatico

You may also like...

Comments are closed.