Home > Software design >  ios emulator partition issue
ios emulator partition issue

Time:12-31

I tried to find the file inside the ios emulator.
When I scan the directory all the time, it finds my Mac Book local directory.
I don't know why the external folder is being read by the emulator. Turn it off or Is there any way to access the folder inside the emulator?

The code proceeds from a test application written in Objective-C. Here's the code:

   if ((dir = opendir("/Users/macAccount")) != nullptr) {
    while ((diread = readdir(dir)) != nullptr) {
      printf ("target : %s", diread->d_name);
    }
    closedir (dir);
  } 

==> result (This is the files of my account on the macbook.)

.android| DataGripProjects| Public| .ssh| Movies| .vimrc| Applications| .gradle| .Trash| Mon.tar.gz| .npm| ...

Is this normal?

CodePudding user response:

If you run your code within an iOS app, you should start from NSHomeDirectory() which points to the root of the app's data container (e.g. /Users/qwerty/Library/Developer/CoreSimulator/Devices/B14BE9CD-4977-4960-8833-6591B1DB5530/data/Containers/Data/Application/8F26289C-DA47-4A1A-A9FB-65BEA7623496 ). And traverse it using NSFileManager.

If you do it from a macOS app that is not sandboxed (e.g. a command line tool), you could start traversing simulator devices at [NSHomeDirectory() appendingPathComponent:@"Library/Developer/CoreSimulator/Devices"], and then for each device directory, traverse the apps inside data/Containers/Data/Application.

  • Related