|
1 | 1 | require 'json' |
| 2 | +require 'find' |
2 | 3 |
|
3 | 4 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) |
4 | 5 |
|
5 | 6 | fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' |
6 | 7 |
|
7 | 8 | # Detect if this is a Swift project by looking for user AppDelegate.swift files |
8 | | -dependency_paths = ['/node_modules/', '/Pods/', '/build/', '/Build/', '/DerivedData/'] |
9 | | -swift_project = Dir.glob('**/AppDelegate.swift') |
10 | | - .reject { |file| dependency_paths.any? { |path| file.include?(path) } } |
11 | | - .any? |
| 9 | +start_dir = File.expand_path('../../', __dir__) |
| 10 | +swift_delegate_path = nil |
| 11 | +Find.find(start_dir) do |path| |
| 12 | + if path =~ /AppDelegate\.swift$/ |
| 13 | + swift_delegate_path = path |
| 14 | + break |
| 15 | + end |
| 16 | +end |
| 17 | + |
| 18 | +swift_project = File.exist?(swift_delegate_path) |
12 | 19 |
|
13 | 20 | # Debug output |
14 | 21 | if swift_project |
15 | 22 | puts "ReactNativeNavigation: Swift AppDelegate detected - enabling Swift-compatible configuration" |
16 | | -else |
| 23 | +else |
17 | 24 | puts "ReactNativeNavigation: Objective-C AppDelegate detected - using standard configuration" |
18 | 25 | end |
19 | 26 |
|
@@ -43,19 +50,19 @@ Pod::Spec.new do |s| |
43 | 50 | end |
44 | 51 |
|
45 | 52 | folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DFOLLY_CFG_NO_COROUTINES=1' |
46 | | - |
| 53 | + |
47 | 54 | # Base xcconfig settings |
48 | 55 | xcconfig_settings = { |
49 | 56 | 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly" "$(PODS_ROOT)/Headers/Private/React-Core" "$(PODS_ROOT)/Headers/Private/Yoga"', |
50 | 57 | "CLANG_CXX_LANGUAGE_STANDARD" => "c++20", |
51 | 58 | "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", |
52 | 59 | } |
53 | | - |
| 60 | + |
54 | 61 | # Only add DEFINES_MODULE for Swift projects |
55 | 62 | if swift_project |
56 | 63 | xcconfig_settings["DEFINES_MODULE"] = "YES" |
57 | 64 | end |
58 | | - |
| 65 | + |
59 | 66 | s.pod_target_xcconfig = xcconfig_settings |
60 | 67 |
|
61 | 68 | if fabric_enabled |
|
0 commit comments