Emulator file scan problem

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 contents of my account on the macbook.)

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

So, I presume by “emulator” you mean the iOS Simulator.

Keep in mind that the simulator is not an emulator. It does not emulate the low-level details of iOS. An obvious, but still significant, example of its limitation is that code destined for the simulatore is built with the Mac’s CPU architecture, not the iOS device’s one.


Beyond that, I’m struggling to understand your issue. Is the code snippet you posted running inside an iOS app inside the simulator? If so, then, yes, the path /Users/macAccount is going to lead to the corresponding directory on your Mac. That’s a consequence of the simulator’s architecture.

The simulator is (more-or-less) an app running on macOS, which means it uses the macOS kernel for accessing the file system. There’s no mapping between simulated paths and macOS paths; they are one and the same.

This works because iOS apps are not allowed to hard code paths like this. Rather, an iOS app finds its container directory using APIs like homeDirectoryForCurrentUser, and the simulator ensures that this returns a value within the simulated app’s container.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Emulator file scan problem
 
 
Q