def pull(udid, device_path, local_path, bundle_id=None, timeout=None):
        """
        Pulls a file or directory from the iOS device to the local machine.

        Args:
            udid (str): The UDID of the iOS device.
            device_path (str): The path of the file or directory on the iOS device.
                               Remote devices can only be file paths.
            local_path (str): The destination path on the local machine.
                              Remote devices can only be file paths.
            bundle_id (str, optional): The bundle ID of the app. If provided, the file or directory will be pulled from the app's sandbox. Defaults to None.
            timeout (int, optional): The timeout in seconds for the remote device operation. Defaults to None.

            Examples:

                    Pull a file from the DCIM directory::

                        >>> TIDevice.pull("00008020-001270842E88002E", "/DCIM/photo.jpg", "C:/Users/username/Pictures/photo.jpg")
                        >>> TIDevice.pull("00008020-001270842E88002E", "/DCIM/photo.jpg", "C:/Users/username/Pictures")

                    Pull a directory from the Documents directory of the Keynote app::

                        >>> TIDevice.pull("00008020-001270842E88002E", "/Documents", "C:/Users/username/Documents", "com.apple.Keynote")
                        >>> TIDevice.pull("00008020-001270842E88002E", "/Documents", "C:/Users/username/Documents", "com.apple.Keynote")

        """
        try:
            if bundle_id:
                sync = BaseDevice(udid, Usbmux()).app_sync(bundle_id)
            else:
                sync = BaseDevice(udid, Usbmux()).sync

            if TIDevice.is_dir(udid, device_path, bundle_id):
                os.makedirs(local_path, exist_ok=True)

            src = pathlib.Path(device_path)
            dst = pathlib.Path(local_path)
            if dst.is_dir() and src.name and sync.stat(src).is_dir():
                dst = dst.joinpath(src.name)

            sync.pull(src, dst)
            print("pulled", src, "->", dst)
        except Exception as e:
            raise AirtestError(f"Failed to pull {device_path} to {local_path}.")

        Pulls a file or directory from the iOS device to the local machine.

        Args:
            udid (str): The UDID of the iOS device.
            device_path (str): The path of the file or directory on the iOS device.
                               Remote devices can only be file paths.
            local_path (str): The destination path on the local machine.
                              Remote devices can only be file paths.
            bundle_id (str, optional): The bundle ID of the app. If provided, the file or directory will be pulled from the app's sandbox. Defaults to None.
            timeout (int, optional): The timeout in seconds for the remote device operation. Defaults to None.

            Examples:

                    Pull a file from the DCIM directory::

                        >>> TIDevice.pull("00008020-001270842E88002E", "/DCIM/photo.jpg", "C:/Users/username/Pictures/photo.jpg")
                        >>> TIDevice.pull("00008020-001270842E88002E", "/DCIM/photo.jpg", "C:/Users/username/Pictures")

                    Pull a directory from the Documents directory of the Keynote app::

                        >>> TIDevice.pull("00008020-001270842E88002E", "/Documents", "C:/Users/username/Documents", "com.apple.Keynote")
                        >>> TIDevice.pull("00008020-001270842E88002E", "/Documents", "C:/Users/username/Documents", "com.apple.Keynote")

        
airtest/core/ios/ios.py