[ios] Only add HERMES_ENABLE_DEBUGGER flag to debug builds#5383
Conversation
7a59bfa to
cda52ed
Compare
cda52ed to
a401321
Compare
tomekzaw
left a comment
There was a problem hiding this comment.
Thanks for this PR! Left one minor suggestion, let me know what you think.
cc @piaskowyk we'll need to include it in 3.6.0 for RN 0.73 support
|
@gabrieldonadel Thanks for this PR, it helped us a great deal with some other problem we had. I'm a bit worried about doing |
Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
Hi @tjzel, if the user had a custom debug config that could indeed be a problem but |
## Summary This PR aims to fix the issue when Release builds would fail on Paper on iOS. The reason this regression happened is #5113. XCode ships by default to new projects `DEBUG` macro for Debug Configuration. Due to some issues (#4902) we decided to switch over to `NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of the box. Incidentally, it's provided by React Native which puts its install script into project's Podfile - however, [only in Fabric](facebook/react-native@421df9f). What is more, some time ago React Native made it so `PRODUCTION=1 pod install` is [no longer a necessary step](facebook/react-native@93fdcba) to make a release build, therefore we cannot rely on it. Until React Native defines `NDEBUG` for Paper too we have to detect, based on available options, whether we potentially have a Release build and this pull request does this. Thanks to #5383 we finally figures out how to do it the most agreeable way. We hardcode that for a build config named `Release` NDEBUG=1 will be set. If the user uses some custom release build config e.g. "MyRelease", NDEBUG=1 will not be set - in this situation we'll require the user to use `PRODUCTION=1`. ## Test plan Run all example apps (except TVOS cause I couldn't make it cooperate with me, and Web) on both iOS and Android in both Release and Debug and see if they work properly (e.g. add a throw in #ifndef fragment).
|
I see. In other ruby scripts RN tends to regex 'Debug' but here where you pointed they just go straight for the literal. |
|
@gabrieldonadel I took a look into backwards compatibility and on 0.72 and lower we still have to rely on For consistency - could you add a conditional here that for 0.72 and below we set this flag only when |
Sure @tjzel, updated |
## Summary This PR fixes error: ```bash [!] Invalid `Podfile` file: [!] Invalid `RNReanimated.podspec` file: undefined local variable or method `config' for Pod:Module Did you mean? concerning. # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/node_modules/react-native-reanimated/RNReanimated.podspec:90 # ------------------------------------------- # gcc_debug_definitions = "$(inherited)" > if config[:react_native_minor_version] >= 73 || !is_release # gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1" # ------------------------------------------- . # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/ios/Podfile:31 # ------------------------------------------- # target 'ReanimatedExample' do > config = use_native_modules! # # ------------------------------------------- ``` Related to PRs: #5383 and #5334 It is because we renamed `config` to global variable `$config` ## Test plan Build Example app --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
## Summary This PR aims to fix the issue when Release builds would fail on Paper on iOS. The reason this regression happened is #5113. XCode ships by default to new projects `DEBUG` macro for Debug Configuration. Due to some issues (#4902) we decided to switch over to `NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of the box. Incidentally, it's provided by React Native which puts its install script into project's Podfile - however, [only in Fabric](facebook/react-native@421df9f). What is more, some time ago React Native made it so `PRODUCTION=1 pod install` is [no longer a necessary step](facebook/react-native@93fdcba) to make a release build, therefore we cannot rely on it. Until React Native defines `NDEBUG` for Paper too we have to detect, based on available options, whether we potentially have a Release build and this pull request does this. Thanks to #5383 we finally figures out how to do it the most agreeable way. We hardcode that for a build config named `Release` NDEBUG=1 will be set. If the user uses some custom release build config e.g. "MyRelease", NDEBUG=1 will not be set - in this situation we'll require the user to use `PRODUCTION=1`. ## Test plan Run all example apps (except TVOS cause I couldn't make it cooperate with me, and Web) on both iOS and Android in both Release and Debug and see if they work properly (e.g. add a throw in #ifndef fragment).
## Summary Building on release mode using react-native 0.73.0-rc.4 results in a build error due to undefined symbols > Undefined symbols for architecture x86_64: "facebook::hermes::inspector_modern::chrome::enableDebugging(std::__1::unique_ptr<facebook::hermes::inspector_modern::RuntimeAdapter, std::__1::default_delete<facebook::hermes::inspector_modern::RuntimeAdapter>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from: reanimated::ReanimatedHermesRuntime::ReanimatedHermesRuntime(std::__1::unique_ptr<facebook::hermes::HermesRuntime, std::__1::default_delete<facebook::hermes::HermesRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libRNReanimated.a(ReanimatedHermesRuntime.o) "facebook::hermes::inspector_modern::chrome::disableDebugging(int)", referenced from: reanimated::ReanimatedHermesRuntime::~ReanimatedHermesRuntime() in libRNReanimated.a(ReanimatedHermesRuntime.o) This happens because react native only sets `HERMES_ENABLE_DEBUGGER` in debug mode https://github.com/facebook/react-native/blob/23cf10428eb58cfcbf614b8b0728f2535f2d252f/packages/react-native/scripts/cocoapods/utils.rb#L44-L47 So in order to fix this I believe that instead of always adding the `HERMES_ENABLE_DEBUGGER` flag we should only it on debug mode as well, using `GCC_PREPROCESSOR_DEFINITIONS[config=Debug]` ## Test plan Build using react-native 0.73.0-rc.4 on release mode --------- Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
## Summary This PR fixes error: ```bash [!] Invalid `Podfile` file: [!] Invalid `RNReanimated.podspec` file: undefined local variable or method `config' for Pod:Module Did you mean? concerning. # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/node_modules/react-native-reanimated/RNReanimated.podspec:90 # ------------------------------------------- # gcc_debug_definitions = "$(inherited)" > if config[:react_native_minor_version] >= 73 || !is_release # gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1" # ------------------------------------------- . # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/ios/Podfile:31 # ------------------------------------------- # target 'ReanimatedExample' do > config = use_native_modules! # # ------------------------------------------- ``` Related to PRs: #5383 and #5334 It is because we renamed `config` to global variable `$config` ## Test plan Build Example app --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
## Summary This PR aims to fix the issue when Release builds would fail on Paper on iOS. The reason this regression happened is #5113. XCode ships by default to new projects `DEBUG` macro for Debug Configuration. Due to some issues (#4902) we decided to switch over to `NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of the box. Incidentally, it's provided by React Native which puts its install script into project's Podfile - however, [only in Fabric](facebook/react-native@421df9f). What is more, some time ago React Native made it so `PRODUCTION=1 pod install` is [no longer a necessary step](facebook/react-native@93fdcba) to make a release build, therefore we cannot rely on it. Until React Native defines `NDEBUG` for Paper too we have to detect, based on available options, whether we potentially have a Release build and this pull request does this. Thanks to #5383 we finally figures out how to do it the most agreeable way. We hardcode that for a build config named `Release` NDEBUG=1 will be set. If the user uses some custom release build config e.g. "MyRelease", NDEBUG=1 will not be set - in this situation we'll require the user to use `PRODUCTION=1`. ## Test plan Run all example apps (except TVOS cause I couldn't make it cooperate with me, and Web) on both iOS and Android in both Release and Debug and see if they work properly (e.g. add a throw in #ifndef fragment).
## Summary Building on release mode using react-native 0.73.0-rc.4 results in a build error due to undefined symbols > Undefined symbols for architecture x86_64: "facebook::hermes::inspector_modern::chrome::enableDebugging(std::__1::unique_ptr<facebook::hermes::inspector_modern::RuntimeAdapter, std::__1::default_delete<facebook::hermes::inspector_modern::RuntimeAdapter>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from: reanimated::ReanimatedHermesRuntime::ReanimatedHermesRuntime(std::__1::unique_ptr<facebook::hermes::HermesRuntime, std::__1::default_delete<facebook::hermes::HermesRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libRNReanimated.a(ReanimatedHermesRuntime.o) "facebook::hermes::inspector_modern::chrome::disableDebugging(int)", referenced from: reanimated::ReanimatedHermesRuntime::~ReanimatedHermesRuntime() in libRNReanimated.a(ReanimatedHermesRuntime.o) This happens because react native only sets `HERMES_ENABLE_DEBUGGER` in debug mode https://github.com/facebook/react-native/blob/23cf10428eb58cfcbf614b8b0728f2535f2d252f/packages/react-native/scripts/cocoapods/utils.rb#L44-L47 So in order to fix this I believe that instead of always adding the `HERMES_ENABLE_DEBUGGER` flag we should only it on debug mode as well, using `GCC_PREPROCESSOR_DEFINITIONS[config=Debug]` ## Test plan Build using react-native 0.73.0-rc.4 on release mode --------- Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
## Summary This PR fixes error: ```bash [!] Invalid `Podfile` file: [!] Invalid `RNReanimated.podspec` file: undefined local variable or method `config' for Pod:Module Did you mean? concerning. # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/node_modules/react-native-reanimated/RNReanimated.podspec:90 # ------------------------------------------- # gcc_debug_definitions = "$(inherited)" > if config[:react_native_minor_version] >= 73 || !is_release # gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1" # ------------------------------------------- . # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/ios/Podfile:31 # ------------------------------------------- # target 'ReanimatedExample' do > config = use_native_modules! # # ------------------------------------------- ``` Related to PRs: #5383 and #5334 It is because we renamed `config` to global variable `$config` ## Test plan Build Example app --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
This PR aims to fix the issue when Release builds would fail on Paper on iOS. The reason this regression happened is #5113. XCode ships by default to new projects `DEBUG` macro for Debug Configuration. Due to some issues (#4902) we decided to switch over to `NDEBUG` macro. However, the `NDEBUG` is not provided by XCode out of the box. Incidentally, it's provided by React Native which puts its install script into project's Podfile - however, [only in Fabric](facebook/react-native@421df9f). What is more, some time ago React Native made it so `PRODUCTION=1 pod install` is [no longer a necessary step](facebook/react-native@93fdcba) to make a release build, therefore we cannot rely on it. Until React Native defines `NDEBUG` for Paper too we have to detect, based on available options, whether we potentially have a Release build and this pull request does this. Thanks to #5383 we finally figures out how to do it the most agreeable way. We hardcode that for a build config named `Release` NDEBUG=1 will be set. If the user uses some custom release build config e.g. "MyRelease", NDEBUG=1 will not be set - in this situation we'll require the user to use `PRODUCTION=1`. Run all example apps (except TVOS cause I couldn't make it cooperate with me, and Web) on both iOS and Android in both Release and Debug and see if they work properly (e.g. add a throw in #ifndef fragment).
Building on release mode using react-native 0.73.0-rc.4 results in a build error due to undefined symbols > Undefined symbols for architecture x86_64: "facebook::hermes::inspector_modern::chrome::enableDebugging(std::__1::unique_ptr<facebook::hermes::inspector_modern::RuntimeAdapter, std::__1::default_delete<facebook::hermes::inspector_modern::RuntimeAdapter>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)", referenced from: reanimated::ReanimatedHermesRuntime::ReanimatedHermesRuntime(std::__1::unique_ptr<facebook::hermes::HermesRuntime, std::__1::default_delete<facebook::hermes::HermesRuntime>>, std::__1::shared_ptr<facebook::react::MessageQueueThread> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) in libRNReanimated.a(ReanimatedHermesRuntime.o) "facebook::hermes::inspector_modern::chrome::disableDebugging(int)", referenced from: reanimated::ReanimatedHermesRuntime::~ReanimatedHermesRuntime() in libRNReanimated.a(ReanimatedHermesRuntime.o) This happens because react native only sets `HERMES_ENABLE_DEBUGGER` in debug mode https://github.com/facebook/react-native/blob/23cf10428eb58cfcbf614b8b0728f2535f2d252f/packages/react-native/scripts/cocoapods/utils.rb#L44-L47 So in order to fix this I believe that instead of always adding the `HERMES_ENABLE_DEBUGGER` flag we should only it on debug mode as well, using `GCC_PREPROCESSOR_DEFINITIONS[config=Debug]` Build using react-native 0.73.0-rc.4 on release mode --------- Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
This PR fixes error: ```bash [!] Invalid `Podfile` file: [!] Invalid `RNReanimated.podspec` file: undefined local variable or method `config' for Pod:Module Did you mean? concerning. # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/node_modules/react-native-reanimated/RNReanimated.podspec:90 # ------------------------------------------- # gcc_debug_definitions = "$(inherited)" > if config[:react_native_minor_version] >= 73 || !is_release # gcc_debug_definitions << " HERMES_ENABLE_DEBUGGER=1" # ------------------------------------------- . # from /Users/runner/work/react-native-reanimated/react-native-reanimated/Example/ios/Podfile:31 # ------------------------------------------- # target 'ReanimatedExample' do > config = use_native_modules! # # ------------------------------------------- ``` Related to PRs: #5383 and #5334 It is because we renamed `config` to global variable `$config` Build Example app --------- Co-authored-by: Tomek Zawadzki <tomasz.zawadzki@swmansion.com>
Summary
Building on release mode using react-native 0.73.0-rc.4 results in a build error due to undefined symbols
This happens because react native only sets
HERMES_ENABLE_DEBUGGERin debug mode https://github.com/facebook/react-native/blob/23cf10428eb58cfcbf614b8b0728f2535f2d252f/packages/react-native/scripts/cocoapods/utils.rb#L44-L47So in order to fix this I believe that instead of always adding the
HERMES_ENABLE_DEBUGGERflag we should only it on debug mode as well, usingGCC_PREPROCESSOR_DEFINITIONS[config=Debug]Test plan
Build using react-native 0.73.0-rc.4 on release mode