18

I'm trying to create a music player for iPhone and iPad. I get it working perfectly on my iPhone and iPad because those actually have a music library. However I want to use fastlane and some other tools with tests so I need to be able to see/add a music library to my simulator as well.

I've navigated to my emulator folder. /Users/x/Library/Developer/CoreSimulator/Devices/8A14CCDB../Data
However I have no clue where to look and if I even should look here to add the music.

I hope someone can help me out here on how to do this. I've searched this but it seems like nobody asked this question for quite some time. So that means either everyone has given up on it or it is possible and I just can't seem to figure out how to do this.

NoSixties
  • 2,443
  • 2
  • 28
  • 65

2 Answers2

23

Although the regular believe is that this can't be done I figured out how to do it thanks to the link @BaSha mentioned.

I wrote a little How To on it so everyone who faces the same problem or thinks it isn't possible will be able to get it working.

To give the gist of it you will need a few things.

  1. A iOS device that actually has music on it
  2. iFunBox or something similar
  3. The id of the simulator you want to use

To get the id of the device you want to test on you can run

xcrun simctl list

This will give you a list of all the available simulators, pick the one you want to use and copy the id, you will need this.

Now navigate to the directory of the simulator you just chose.

[yourHD] -> Users -> [yourusername] -> Library -> Developer -> CoreSimulator -> Devices -> [the ID you obtained in the previous step] -> data -> Media -> iTunes_Control -> iTunes

Now you have to open iFunBox (connect your phone with music library to your pc). In iFunBox, select Raw File System. In this you will find a directory called iTunes_Control from that directory you need to copy some files and directories to the simulator directory you opened before. namely:

Music
iTunes/Artwork
iTunes/MediaLibrary.sqlitedb
iTunes/MediaLibrary.sqlitedb-shm
iTunes/MediaLibrary.sqlitedb-wal

If you ever bought music you should also grab the following directory Raw File System/Purchases

Dov
  • 15,530
  • 13
  • 76
  • 177
NoSixties
  • 2,443
  • 2
  • 28
  • 65
  • 3
    The above How To is incredibly useful! It worked well, and now I can access a Music Library for testing. It doesn't allow the sync/unsync process from iTunes unfortunately, but still very helpful. – Jim Leask Dec 15 '17 at 15:59
  • 2
    Thank you, thank you, thank you so much! Holy crap! This has changed my whole development experience. – Edwin Finch Dec 17 '17 at 05:14
  • 1
    When I start iFunbox ESET throws this warning: `HTTP filter file http://ww1.ifunboxmac.com JS/Redirector.NDR trojan connection terminated` the url looks shady, as I downloaded the app from http://www.i-funbox.com/ – tuexss May 14 '18 at 12:57
  • I did everything like the tutorial, but, it still doesn't show up any songs on simulator – Karanveer Singh Apr 04 '19 at 07:05
  • 1
    excellent work. Just to update this, iFunBox doesn't look to have been updated in a while, so instead of that tool, I used SynciosManager to get the data off my device. – horseshoe7 Oct 26 '20 at 10:52
  • Also, make sure you copy the Artwork folder before you launch the app on the simulator. I think a db is constructed, so if you add it later, the artwork won't appear unless you erase all contents and settings, and copy it all over again, this time with Artwork. – horseshoe7 Oct 26 '20 at 10:53
3

so I need to be able to see/add a music library to my simulator as well

You cannot do so. MPMediaLibrary APIs do not work on the simulator.

You can test your interface on the simulator by writing stub methods that stand between your code and the MPMediaLibrary APIs, but actual access to the user's music library is possible only on a device.

matt
  • 515,959
  • 87
  • 875
  • 1,141