diff --git a/android/src/main/jni/CMakeLists.txt b/android/src/main/jni/CMakeLists.txt index 6940814..ae766c1 100644 --- a/android/src/main/jni/CMakeLists.txt +++ b/android/src/main/jni/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required(VERSION 3.13) +project(rn_usercentrics) set(CMAKE_VERBOSE_MAKEFILE ON) # Set library name -set(LIB_TARGET_NAME react_codegen_RNUsercentricsModule) +set(LIB_TARGET_NAME rn_usercentrics) # Add compile options add_compile_options( @@ -32,54 +33,44 @@ target_include_directories( . ) +# Find ReactAndroid package first (required for version detection) +find_package(ReactAndroid REQUIRED CONFIG) + # Link libraries based on React Native version -if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) +if(DEFINED ReactAndroid_VERSION_MINOR AND ReactAndroid_VERSION_MINOR GREATER_EQUAL 76) target_link_libraries( ${LIB_TARGET_NAME} ReactAndroid::reactnative ReactAndroid::jsi - fbjni::fbjni + ReactAndroid::fbjni + android + log ) else() + # Fallback for older RN versions or when version is not available target_link_libraries( ${LIB_TARGET_NAME} - fbjni - folly_runtime - glog - jsi - react_codegen_rncore - react_debug - react_nativemodule_core - react_render_core - react_render_debug - react_render_graphics - react_render_mapbuffer - react_render_componentregistry - react_utils - rrc_view - turbomodulejsijni - yoga + ReactAndroid::reactnative + ReactAndroid::jsi + android + log ) endif() -# Compile options based on React Native version -if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80) - target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE) -else() - target_compile_options( - ${LIB_TARGET_NAME} - PRIVATE - -DLOG_TAG=\"ReactNative\" - -fexceptions - -frtti - -std=c++20 - -Wall - ) -endif() +# Compile options - use standard approach for compatibility +target_compile_options( + ${LIB_TARGET_NAME} + PRIVATE + -DLOG_TAG=\"ReactNative\" + -fexceptions + -frtti + -std=c++20 + -Wall +) # Additional include directories target_include_directories( - ${CMAKE_PROJECT_NAME} - PUBLIC + ${LIB_TARGET_NAME} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) \ No newline at end of file diff --git a/react-native-usercentrics.podspec b/react-native-usercentrics.podspec index c8298a1..06c6de0 100644 --- a/react-native-usercentrics.podspec +++ b/react-native-usercentrics.podspec @@ -21,22 +21,56 @@ Pod::Spec.new do |s| s.dependency 'React-NativeModulesApple' s.dependency 'UsercentricsUI', "#{package['iosPackageVersion']}" - s.pod_target_xcconfig = { + # Base C++ configuration + # Note: RCT_NEW_ARCH_ENABLED is inherited from parent project build settings + # This ensures compatibility with Expo's prebuild process + base_cpp_flags = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20', 'CLANG_CXX_LIBRARY' => 'libc++', - 'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++', - 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/React-Core" "$(PODS_ROOT)/React-NativeModulesApple" "$(PODS_ROOT)/ReactCommon" "$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon"', - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) RCT_NEW_ARCH_ENABLED=0', + 'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++ $(inherited)', 'CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER' => 'NO', 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', - 'GCC_WARN_INHIBIT_ALL_WARNINGS' => 'YES' + 'GCC_WARN_INHIBIT_ALL_WARNINGS' => 'YES', + 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES', + 'DEFINES_MODULE' => 'YES', + # Ensure C++ standard library headers are accessible + 'USE_HEADERMAP' => 'YES', + 'ALWAYS_SEARCH_USER_PATHS' => 'NO' } + # Header search paths - include React Native and C++ standard library paths + header_search_paths = [ + '$(PODS_ROOT)/React-Core', + '$(PODS_ROOT)/React-NativeModulesApple', + '$(PODS_ROOT)/ReactCommon', + '$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon', + '$(PODS_TARGET_SRCROOT)', + '$(PODS_ROOT)/Headers/Public', + '$(PODS_ROOT)/Headers/Public/React-Core', + '$(PODS_ROOT)/Headers/Public/ReactCommon' + ] + + # Add new architecture paths if available (will be resolved at build time) + header_search_paths += [ + '$(PODS_ROOT)/Headers/Public/React-Fabric', + '$(PODS_ROOT)/Headers/Public/React-Codegen', + '$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers', + '$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers' + ] + + base_cpp_flags['HEADER_SEARCH_PATHS'] = header_search_paths.map { |path| "\"#{path}\"" }.join(' ') + + # Preprocessor definitions - inherit RCT_NEW_ARCH_ENABLED from parent project + # This allows Expo/React Native to control the new architecture flag + base_cpp_flags['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited)' + + s.pod_target_xcconfig = base_cpp_flags + s.user_target_xcconfig = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20', 'CLANG_CXX_LIBRARY' => 'libc++', - 'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++', - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) RCT_NEW_ARCH_ENABLED=0', + 'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++ $(inherited)', + 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited)', 'CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER' => 'NO', 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', 'GCC_WARN_INHIBIT_ALL_WARNINGS' => 'YES'