Skip to content

Commit 4bfd885

Browse files
Chore/msdk 3145 fix ios react native new arch (#173)
* [MSDK-3145] try to fix MSDK-3145 * modify cmakeLists, and add 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited)', * revert sample Info.plist and project.pbxproj to match master --------- Co-authored-by: bruno.silva <bruno.silva@usercentrics-ext.com>
1 parent aaf8f80 commit 4bfd885

File tree

2 files changed

+67
-42
lines changed

2 files changed

+67
-42
lines changed
Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
cmake_minimum_required(VERSION 3.13)
2+
project(rn_usercentrics)
23
set(CMAKE_VERBOSE_MAKEFILE ON)
34

45
# Set library name
5-
set(LIB_TARGET_NAME react_codegen_RNUsercentricsModule)
6+
set(LIB_TARGET_NAME rn_usercentrics)
67

78
# Add compile options
89
add_compile_options(
@@ -32,54 +33,44 @@ target_include_directories(
3233
.
3334
)
3435

36+
# Find ReactAndroid package first (required for version detection)
37+
find_package(ReactAndroid REQUIRED CONFIG)
38+
3539
# Link libraries based on React Native version
36-
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
40+
if(DEFINED ReactAndroid_VERSION_MINOR AND ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
3741
target_link_libraries(
3842
${LIB_TARGET_NAME}
3943
ReactAndroid::reactnative
4044
ReactAndroid::jsi
41-
fbjni::fbjni
45+
ReactAndroid::fbjni
46+
android
47+
log
4248
)
4349
else()
50+
# Fallback for older RN versions or when version is not available
4451
target_link_libraries(
4552
${LIB_TARGET_NAME}
46-
fbjni
47-
folly_runtime
48-
glog
49-
jsi
50-
react_codegen_rncore
51-
react_debug
52-
react_nativemodule_core
53-
react_render_core
54-
react_render_debug
55-
react_render_graphics
56-
react_render_mapbuffer
57-
react_render_componentregistry
58-
react_utils
59-
rrc_view
60-
turbomodulejsijni
61-
yoga
53+
ReactAndroid::reactnative
54+
ReactAndroid::jsi
55+
android
56+
log
6257
)
6358
endif()
6459

65-
# Compile options based on React Native version
66-
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
67-
target_compile_reactnative_options(${LIB_TARGET_NAME} PRIVATE)
68-
else()
69-
target_compile_options(
70-
${LIB_TARGET_NAME}
71-
PRIVATE
72-
-DLOG_TAG=\"ReactNative\"
73-
-fexceptions
74-
-frtti
75-
-std=c++20
76-
-Wall
77-
)
78-
endif()
60+
# Compile options - use standard approach for compatibility
61+
target_compile_options(
62+
${LIB_TARGET_NAME}
63+
PRIVATE
64+
-DLOG_TAG=\"ReactNative\"
65+
-fexceptions
66+
-frtti
67+
-std=c++20
68+
-Wall
69+
)
7970

8071
# Additional include directories
8172
target_include_directories(
82-
${CMAKE_PROJECT_NAME}
83-
PUBLIC
73+
${LIB_TARGET_NAME}
74+
PRIVATE
8475
${CMAKE_CURRENT_SOURCE_DIR}
8576
)

react-native-usercentrics.podspec

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,56 @@ Pod::Spec.new do |s|
2121
s.dependency 'React-NativeModulesApple'
2222
s.dependency 'UsercentricsUI', "#{package['iosPackageVersion']}"
2323

24-
s.pod_target_xcconfig = {
24+
# Base C++ configuration
25+
# Note: RCT_NEW_ARCH_ENABLED is inherited from parent project build settings
26+
# This ensures compatibility with Expo's prebuild process
27+
base_cpp_flags = {
2528
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
2629
'CLANG_CXX_LIBRARY' => 'libc++',
27-
'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++',
28-
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/React-Core" "$(PODS_ROOT)/React-NativeModulesApple" "$(PODS_ROOT)/ReactCommon" "$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon"',
29-
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) RCT_NEW_ARCH_ENABLED=0',
30+
'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++ $(inherited)',
3031
'CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER' => 'NO',
3132
'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
32-
'GCC_WARN_INHIBIT_ALL_WARNINGS' => 'YES'
33+
'GCC_WARN_INHIBIT_ALL_WARNINGS' => 'YES',
34+
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
35+
'DEFINES_MODULE' => 'YES',
36+
# Ensure C++ standard library headers are accessible
37+
'USE_HEADERMAP' => 'YES',
38+
'ALWAYS_SEARCH_USER_PATHS' => 'NO'
3339
}
3440

41+
# Header search paths - include React Native and C++ standard library paths
42+
header_search_paths = [
43+
'$(PODS_ROOT)/React-Core',
44+
'$(PODS_ROOT)/React-NativeModulesApple',
45+
'$(PODS_ROOT)/ReactCommon',
46+
'$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon',
47+
'$(PODS_TARGET_SRCROOT)',
48+
'$(PODS_ROOT)/Headers/Public',
49+
'$(PODS_ROOT)/Headers/Public/React-Core',
50+
'$(PODS_ROOT)/Headers/Public/ReactCommon'
51+
]
52+
53+
# Add new architecture paths if available (will be resolved at build time)
54+
header_search_paths += [
55+
'$(PODS_ROOT)/Headers/Public/React-Fabric',
56+
'$(PODS_ROOT)/Headers/Public/React-Codegen',
57+
'$(PODS_CONFIGURATION_BUILD_DIR)/React-Codegen/React_Codegen.framework/Headers',
58+
'$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers'
59+
]
60+
61+
base_cpp_flags['HEADER_SEARCH_PATHS'] = header_search_paths.map { |path| "\"#{path}\"" }.join(' ')
62+
63+
# Preprocessor definitions - inherit RCT_NEW_ARCH_ENABLED from parent project
64+
# This allows Expo/React Native to control the new architecture flag
65+
base_cpp_flags['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited)'
66+
67+
s.pod_target_xcconfig = base_cpp_flags
68+
3569
s.user_target_xcconfig = {
3670
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
3771
'CLANG_CXX_LIBRARY' => 'libc++',
38-
'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++',
39-
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) RCT_NEW_ARCH_ENABLED=0',
72+
'OTHER_CPLUSPLUSFLAGS' => '-std=c++20 -stdlib=libc++ $(inherited)',
73+
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited)',
4074
'CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER' => 'NO',
4175
'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
4276
'GCC_WARN_INHIBIT_ALL_WARNINGS' => 'YES'

0 commit comments

Comments
 (0)