|
1 | 1 | require 'json' |
2 | | -require 'find' |
3 | 2 |
|
4 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) |
5 | 4 |
|
6 | 5 | fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' |
7 | 6 |
|
8 | | -# Detect if this is a Swift project by looking for user AppDelegate.swift files |
9 | | -start_dir = File.expand_path('../../', __dir__) |
10 | | -swift_delegate_path = nil |
11 | | -begin |
12 | | - Find.find(start_dir) do |path| |
13 | | - # Skip hidden directories and common directories that shouldn't be searched |
14 | | - Find.prune if path =~ /\/(\.git|\.Trash|node_modules|Pods|DerivedData|build)\b/ |
| 7 | +# Detect if this is a Swift project by checking common iOS project locations |
| 8 | +# This avoids the slow recursive Find.find() that can take minutes in CI |
| 9 | +def check_for_swift_app_delegate(base_dir) |
| 10 | + # Common project directory names to check |
| 11 | + ['ios', 'example/ios', 'playground/ios', 'app/ios', 'demo/ios'].each do |ios_dir| |
| 12 | + ios_path = File.join(base_dir, ios_dir) |
| 13 | + next unless Dir.exist?(ios_path) |
15 | 14 |
|
16 | | - if path =~ /AppDelegate\.swift$/ |
17 | | - swift_delegate_path = path |
18 | | - break |
| 15 | + # Check common AppDelegate.swift locations within ios directory |
| 16 | + Dir.glob(File.join(ios_path, '**/AppDelegate.swift'), File::FNM_DOTMATCH).each do |path| |
| 17 | + # Exclude Pods, build, and DerivedData directories |
| 18 | + next if path =~ /\/(Pods|build|DerivedData)\// |
| 19 | + return path if File.exist?(path) |
19 | 20 | end |
20 | 21 | end |
21 | | -rescue Errno::EACCES, Errno::EPERM |
22 | | - # Ignore permission errors |
| 22 | + nil |
23 | 23 | end |
24 | 24 |
|
| 25 | +start_dir = File.expand_path('../../', __dir__) |
| 26 | +swift_delegate_path = check_for_swift_app_delegate(start_dir) |
25 | 27 | swift_project = swift_delegate_path && File.exist?(swift_delegate_path) |
26 | 28 |
|
27 | 29 | # Debug output |
|
0 commit comments