Skip to content

Commit abf0db9

Browse files
authored
Fix swift delegate detection (#8056)
* Fix swift delegate detection * Update podspec * missing file exists check
1 parent c4c4656 commit abf0db9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

ReactNativeNavigation.podspec

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
require 'json'
2+
require 'find'
23

34
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
45

56
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
67

78
# 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)
1219

1320
# Debug output
1421
if swift_project
1522
puts "ReactNativeNavigation: Swift AppDelegate detected - enabling Swift-compatible configuration"
16-
else
23+
else
1724
puts "ReactNativeNavigation: Objective-C AppDelegate detected - using standard configuration"
1825
end
1926

@@ -43,19 +50,19 @@ Pod::Spec.new do |s|
4350
end
4451

4552
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+
4754
# Base xcconfig settings
4855
xcconfig_settings = {
4956
'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"',
5057
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
5158
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
5259
}
53-
60+
5461
# Only add DEFINES_MODULE for Swift projects
5562
if swift_project
5663
xcconfig_settings["DEFINES_MODULE"] = "YES"
5764
end
58-
65+
5966
s.pod_target_xcconfig = xcconfig_settings
6067

6168
if fabric_enabled

0 commit comments

Comments
 (0)