diff --git a/contrib/guide-testing-exclude-icloud-backup.md b/contrib/guide-testing-exclude-icloud-backup.md index fe57cddff1..a5d24c4ad2 100644 --- a/contrib/guide-testing-exclude-icloud-backup.md +++ b/contrib/guide-testing-exclude-icloud-backup.md @@ -1,5 +1,29 @@ # Guide: Testing Exclude iCloud Backup +## Prerequisites + +- macOS +- iOS Simulator + +## Testing + +Ensure you have booted a simulator and execute the integration tests on iOS: + +```sh +MOCHA_REMOTE_GREP='icloud' npm run test:ios --workspace @realm/react-native-test-app-tests +``` + +In the command above, we're explicitly grepping for the icloud backup tests. + +To verify if a file has been successfully excluded from iCloud backup, you need to check the file's attributes. +We provide an easy script to do so: + +```sh +./contrib/scripts/check-exclude-icloud-backup.sh +``` + +## Testing in your own app + Before starting the testing process, you need to configure your Realm database to either include or exclude files from iCloud backup. This is done by setting the `excludeFromIcloudBackup` property in your Realm configuration. Here is an example of how to set this property: ```javascript @@ -16,20 +40,7 @@ const realm = new Realm(realmConfig); Make sure to replace the schema and path with your actual Realm schema and desired file path. Once you have configured this property, you can proceed with the following steps to test if the exclusion from iCloud backup is working correctly. -## Prerequisites - -- macOS -- iOS Simulator - -## Testing - -To verify if a file has been successfully excluded from iCloud backup, you need to check the file's attributes. We provide an easy script to do so. Ensure you have booted a simulator with an app using Realm. From the root of the project, run: - -```sh -contrib/scripts/check-exclude-icloud-backup.sh -``` - -If the script doesn't work, you can also check it manually. First, get the path of the Realm files from the simulator's Documents folder by running: +First, get the path of the Realm files from the simulator's Documents folder by running: ```sh open `xcrun simctl get_app_container booted com.your.app.bundleId data`/Documents diff --git a/contrib/scripts/check-exclude-icloud-backup.sh b/contrib/scripts/check-exclude-icloud-backup.sh index 41d4127697..306a1af412 100755 --- a/contrib/scripts/check-exclude-icloud-backup.sh +++ b/contrib/scripts/check-exclude-icloud-backup.sh @@ -1,12 +1,6 @@ #!/bin/bash -# Check if appbundle parameter is provided -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -appbundle=$1 +TEST_APP_BUNDLE_ID=com.microsoft.ReactTestApp # Check if a simulator is booted booted_simulators=$(xcrun simctl list | grep "Booted") @@ -25,15 +19,15 @@ if [ "$booted_count" -gt 1 ]; then fi # Extract the name of the booted simulator -booted_simulator=$(echo "$booted_simulator" | xargs) +booted_simulator=$(echo "$booted_simulators" | xargs) echo -e "Running script on simulator: $booted_simulator\n" # Get the app container path -app_container_path=$(xcrun simctl get_app_container booted "$appbundle" data 2>/dev/null) +app_container_path=$(xcrun simctl get_app_container booted "$TEST_APP_BUNDLE_ID" data 2>/dev/null) # Check if the command was successful if [ $? -ne 0 ] || [ -z "$app_container_path" ]; then - echo "Failed to get app container path for $appbundle" + echo "Failed to get app container path for $TEST_APP_BUNDLE_ID" exit 1 fi @@ -47,7 +41,7 @@ if [ ! -d "$documents_path" ]; then fi # Run xattr on all files in the directory -for file in "$documents_path"/*; do +for file in "$documents_path"/icloud-backup-tests/*.realm; do if [ -e "$file" ]; then filename=$(basename "$file") attrs=$(xattr "$file" 2>/dev/null)