开发者

How can I copy a file to the iOS simulator using Xcode?

I need to know how to copy resources 开发者_JAVA百科(help files, images, pLists) to the iOS simulator and ultimately device. I recall this was done through Xcode but what is the exact procedure?


Just drag the file to your simulator


For iOS 6, the directory seems to be a bit different. I'm seeing: ~/Library/Application Support/iPhone Simulator/6.0/Applications/your app here/Documents, where 'your app here' is a long string. Fortunately, if you click on each directory, you'll see the name of the app you're building in the child directory. From there, it's straightforward to find the Documents folder.


You can drag your file to simulator or you can right click to file then send->Simulator. Both work for me.


Just drag your file to the project. It will be copied to your app bundle when the app is installed (on the simulator).

Alternatively, put the file into ~/Library/Application Support/iPhone Simulator/User/Applications/... (if you have the 3.2 SDK.)


From the XCode docs.

A Copy Files build phase allows you to copy files and resources of any type to specific locations as part of the build process. It complements the build phases that copy specific types of files. An example is the Copy Headers build phase, which deals only with header files. You can have as many Copy Files build phases as you need in a target.

For example, using a Copy Files build phase, you can copy fonts to/Library/Fonts. Or, if you’re developing a plug-in, a Copy Files build phase can copy the generated plug-in to the appropriate location. You can have as many Copy Files build phases in a target as you need.

To create a Copy Files build phase:

In the project window, open the target to which you want to add the build phase, and select the build phase after which to add the new build phase. Choose Project > New Build Phase > New Copy Files Build Phase. Xcode adds the new Copy Files build phase after the build phase selected in the Groups & Files list. Drag the files you want to copy from the Groups & Files list to the Copy Files build phase. To configure the new Copy Files build phase, select it and open the Copy Files build phase editor, shown in Figure 2-5.


Just copy files to iCloud Drive. Then open the files app on the simulator and sign into your iCloud account.


Get the folder in the Mac Finder and make an Alias

Yes getting the Path by Xcode, but using the Mac Finder and an Alias to get there, doing the file copy operations, is very smooth and solid.

I get my files into my Simulator units by:

  1. Getting the path by putting a breakpoint in Xcode at (anywhere you like in the app code):

    let FilePathName: String = NSTemporaryDirectory()
    
  2. Using the Mac Finder going to, the simulator unit disk and application location (yes, it is in the Mac). There you find all the local folders of the simulator unit.
    • The path to the the Device unit and to the Application is like a crypto string and not that easy to separate from many other such in the folders alike, but quickly made.
  3. Finding the folder of your choice, make an Alias, move the alias to the Mac Desktop.
    • Then you have a smooth way to the simulator units app storage
    • But an Alias must be made for each simulator unit and app.

The advantage is that you are dealing with the regular tool of Mac Finder folder/Alias and it is quite capable of handling large volumes of files, very smoothly.

  • You put the files exactly where you want them.
  • The Alias works like regular Alias works in a Mac.

By some upgrades of Xcode the simulator units are rest and the data has to be re-copied into the units.

The other suggestions are not that bad

  1. Just copy files to iCloud Drive, works very smooth, is a good alternative.
    • But need to login,
    • But then the files need to be copied from the iCloud Drive to the simulator units storage, unless you want to use data in the iCloud? (The topic of the question was How can I copy a file to the iOS simulator using Xcode?)
  2. Drag'n drop to the Simulator unit, should be the obviously most smooth way of doing it.
    • But I find it slow and not really reliable, I found it hanging copying volumes of files
    • I find also my suggested way giving much better control over the file storage, the desktop Mac is by far more easier to handle data than a phone or tablet?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜