Skip to content

Instantly share code, notes, and snippets.

@yannxou
Last active July 16, 2024 08:37
Show Gist options
  • Save yannxou/e5139d83c0fdb2f0f56289ade25b5eeb to your computer and use it in GitHub Desktop.
Save yannxou/e5139d83c0fdb2f0f56289ade25b5eeb to your computer and use it in GitHub Desktop.
Xcode build phase pre-action to copy File.app content for UI testing
# Ensure simulator is started before copying to grant access to folder (otherwise the target path remains read-only)
echo "Starting simulator (UUID=$TARGET_DEVICE_IDENTIFIER)..."
xcrun simctl boot $TARGET_DEVICE_IDENTIFIER; open -a Simulator
xcrun simctl bootstatus $TARGET_DEVICE_IDENTIFIER
FILES_PATH="$(xcrun simctl listapps $TARGET_DEVICE_IDENTIFIER | grep LocalStorage | awk -F'"' '{print $4}' | sed -e "s/^file:\/\///")/File Provider Storage"
INPUT_FOLDER="$SRCROOT/E2ETests/Resources/File Provider Storage";
echo "Copying File Provider Storage files to simulator...";
# Using rsync to skip copying hidden files
rsync -av --exclude=".*" "$INPUT_FOLDER/" "$FILES_PATH/"
# cp -R "$INPUT_FOLDER/" "$FILES_PATH/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment