Skip to content

Fix iOS build to respect cleanup_exclude_files config#2

Open
billythekid wants to merge 2 commits intoNativePHP:mainfrom
billythekid:fix/ios-cleanup-exclude-files-config
Open

Fix iOS build to respect cleanup_exclude_files config#2
billythekid wants to merge 2 commits intoNativePHP:mainfrom
billythekid:fix/ios-cleanup-exclude-files-config

Conversation

@billythekid
Copy link

@billythekid billythekid commented Feb 1, 2026

Summary

The iOS build's removeUnnecessaryFiles() method was using a hardcoded list of directories to remove, ignoring the user-configurable cleanup_exclude_files setting in config/nativephp.php.

Problem

This caused issues when users had large directories that should be excluded from the bundle, resulting in the zip process timing out during native:run ios.

Solution

This change:

  1. Adds support for the cleanup_exclude_files config option, bringing the iOS build in line with the Android build which already respects this config via PreparesBuild.
  2. Handles both files and directories from the config - using File::deleteDirectory() for directories and unlink() for files.
  3. Handles null config values gracefully with null coalescing (?? []).

Changes

  • src/Commands/BuildIosAppCommand.php: Updated removeUnnecessaryFiles() to read from config('nativephp.cleanup_exclude_files') and handle both files and directories
  • tests/Feature/IosBuildCleanupTest.php: Added 7 tests covering the cleanup behavior

Tests

All 7 new tests pass:

  • Removes default unnecessary directories
  • Removes user-configured directories from cleanup_exclude_files
  • Removes both default and user-configured directories
  • Handles empty cleanup_exclude_files config
  • Handles null cleanup_exclude_files config
  • Handles nested directory paths in config
  • Skips non-existent directories without error

The iOS build's removeUnnecessaryFiles() method was using a hardcoded
list of directories to remove, ignoring the user-configurable
'cleanup_exclude_files' setting in config/nativephp.php.
This caused issues when users had large directories that should be
excluded from the bundle, resulting in the zip process timing out.
This change brings the iOS build in line with the Android build, which
already respects the cleanup_exclude_files config via PreparesBuild.
Also handles null config values gracefully with null coalescing.
@billythekid billythekid marked this pull request as ready for review February 1, 2026 21:37
The cleanup_exclude_files config option is documented as supporting both
files and folders, but the previous implementation only processed them
as directories. This update properly checks each path and handles it
appropriately - using File::deleteDirectory() for directories and
unlink() for files.
@billythekid
Copy link
Author

I'd defer to the subsequent PRs you've linked here. I have a gut feeling there was another thing I missed in this I meant to return to and never did that bit me again.

Happy to have this closed as a wontfix/favoured other PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants