Skip to content

Commit 29538bd

Browse files
committed
Fixing podspec file to exclude Swift logic when dealing with Obj-c
1 parent 133a20c commit 29538bd

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

ReactNativeNavigation.podspec

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
44

55
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
66

7+
# 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?
12+
13+
# Debug output
14+
if swift_project
15+
puts "ReactNativeNavigation: Swift AppDelegate detected - enabling Swift-compatible configuration"
16+
else
17+
puts "ReactNativeNavigation: Objective-C AppDelegate detected - using standard configuration"
18+
end
19+
720
Pod::Spec.new do |s|
821
s.name = "ReactNativeNavigation"
922
s.version = package['version']
@@ -21,18 +34,29 @@ Pod::Spec.new do |s|
2134
s.source = { :git => "https://github.com/wix/react-native-navigation.git", :tag => "#{s.version}" }
2235
s.source_files = 'lib/ios/**/*.{h,m,mm,cpp}'
2336
s.exclude_files = "lib/ios/ReactNativeNavigationTests/**/*.*", "lib/ios/OCMock/**/*.*"
24-
s.public_header_files = [
37+
# Only expose headers for Swift projects
38+
if swift_project
39+
s.public_header_files = [
2540
'lib/ios/RNNAppDelegate.h'
2641
]
42+
end
2743
end
2844

2945
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'
30-
s.pod_target_xcconfig = {
46+
47+
# Base xcconfig settings
48+
xcconfig_settings = {
3149
'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"',
3250
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
3351
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
34-
"DEFINES_MODULE" => "YES"
3552
}
53+
54+
# Only add DEFINES_MODULE for Swift projects
55+
if swift_project
56+
xcconfig_settings["DEFINES_MODULE"] = "YES"
57+
end
58+
59+
s.pod_target_xcconfig = xcconfig_settings
3660

3761
if fabric_enabled
3862
install_modules_dependencies(s)

0 commit comments

Comments
 (0)