In swift you make an interface / protocol that represents your filesystem API and then make an adapter that implements that API to the actual filesystem and swap with a mock when necessary. If the library you are using uses the filesystem directly, then you might need to make a similar interface adapter for the library.