coure2011
coure2011

Reputation: 42504

Can i access iPod Library on simulator?

I am trying some code to open the iPod Library using the simulator but the app crashes with this error:

MPMediaLibrary: Unable to launch iPod library server: application not found

Do I need an actual iPhone to test this code?

Upvotes: 11

Views: 5738

Answers (5)

NoSixties
NoSixties

Reputation: 2533

I was trying to figure this out as well and since you basically need to use all of the answers given here and it is somewhat outdated I figured I would write a little how to.

I will try to keep this up to date so everyone who wants to use this ability will be able to use it without to much trouble

Upvotes: 1

JosephH
JosephH

Reputation: 37505

I've had some success using MPMediaLibrary / MPMediaQuery on the simulator (not playing music, but at least able to query for items) and xcode 4.6.3

I used iFunBox to copy these files from my device:

'Raw File System'/iTunes_Control/iTunes/MediaLibrary.sqlitedb
'Raw File System'/iTunes_Control/iTunes/MediaLibrary.sqlitedb-shm
'Raw File System'/iTunes_Control/iTunes/MediaLibrary.sqlitedb-wal
'Raw File System'/iTunes_Control/iTunes/Artwork

onto my mac in the folder:

"~/Library/Application Support/iPhone Simulator/6.1/Media/iTunes_Control/iTunes/"

Upvotes: 22

newenglander
newenglander

Reputation: 2049

To add to @JosephH and @Rinat Abidullin's answers, I also found that it is possible to access the music files themselves from the Simulator (at least using the iOS 8 and 9 Simulators from Xcode 7.3). For this to work, I copied the following folders from my iPhone to the corresponding folder on my Mac (in addition to the files @JosephH mentioned):

  • /var/mobile/Media/iTunes_Control/Music
  • /var/mobile/Media/Purchases

The files can then be played by using an AVAudioSession to open the MPMediaItemPropertyAssetURL.

Update: There is also a very good sample project that can be used to easily test this out: GVMusicPlayerController.

Upvotes: 0

Rinat Abidullin
Rinat Abidullin

Reputation: 141

Clarification to answer JosephH:

it even works in Xcode 6 but the files should be placed in a folder:

"~/Library/Developer/CoreSimulator/Devices/########-####-####-####-############/data/Media/iTunes_Control/iTunes"

where ########-####-####-####-############ - will be different for different versions of the simulator phone

Upvotes: 5

prendio2
prendio2

Reputation: 1885

Yes you need to test on a device to access the media library.

Upvotes: 8

Related Questions