diff --git a/.github/workflows/validate-cpp.yml b/.github/workflows/validate-cpp.yml index 504ce126dc25..dd8641e66b43 100644 --- a/.github/workflows/validate-cpp.yml +++ b/.github/workflows/validate-cpp.yml @@ -46,3 +46,7 @@ jobs: - name: Run cpplint run: | scripts/cpplint.sh + + - name: Disallow DEBUG macros + run: | + ! egrep -r '(#if DEBUG|#ifdef DEBUG)' Common/cpp apple android/src/main/cpp diff --git a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp index 7d0e0ee17fa8..b3d536b38162 100644 --- a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +++ b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp @@ -2,7 +2,7 @@ #include "CollectionUtils.h" #include "Shareables.h" -#ifdef DEBUG +#ifndef NDEBUG #include #include "JSLogger.h" #endif @@ -59,11 +59,11 @@ void LayoutAnimationsManager::clearLayoutAnimationConfig(int tag) { exitingAnimations_.erase(tag); layoutAnimations_.erase(tag); shouldAnimateExitingForTag_.erase(tag); -#ifdef DEBUG +#ifndef NDEBUG const auto &pair = viewsScreenSharedTagMap_[tag]; screenSharedTagSet_.erase(pair); viewsScreenSharedTagMap_.erase(tag); -#endif // DEBUG +#endif // NDEBUG sharedTransitionAnimations_.erase(tag); auto const &groupName = viewTagToSharedTag_[tag]; @@ -136,7 +136,7 @@ int LayoutAnimationsManager::findPrecedingViewTagForTransition(int tag) { return -1; } -#ifdef DEBUG +#ifndef NDEBUG std::string LayoutAnimationsManager::getScreenSharedTagPairString( const int screenTag, const std::string &sharedTag) const { @@ -160,7 +160,7 @@ void LayoutAnimationsManager::checkDuplicateSharedTag( viewsScreenSharedTagMap_[viewTag] = pair; screenSharedTagSet_.insert(pair); } -#endif // DEBUG +#endif // NDEBUG std::unordered_map> &LayoutAnimationsManager::getConfigsForType(LayoutAnimationType type) { diff --git a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h index b13440a77025..acfbcaabb1bc 100644 --- a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +++ b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h @@ -3,7 +3,7 @@ #include "LayoutAnimationType.h" #include "Shareables.h" -#ifdef DEBUG +#ifndef NDEBUG #include "JSLogger.h" #endif @@ -23,7 +23,7 @@ using namespace facebook; class LayoutAnimationsManager { public: -#ifdef DEBUG +#ifndef NDEBUG explicit LayoutAnimationsManager(const std::shared_ptr &jsLogger) : jsLogger_(jsLogger) {} #endif @@ -43,7 +43,7 @@ class LayoutAnimationsManager { void clearLayoutAnimationConfig(int tag); void cancelLayoutAnimation(jsi::Runtime &rt, int tag); int findPrecedingViewTagForTransition(int tag); -#ifdef DEBUG +#ifndef NDEBUG std::string getScreenSharedTagPairString( const int screenTag, const std::string &sharedTag) const; @@ -54,7 +54,7 @@ class LayoutAnimationsManager { std::unordered_map> &getConfigsForType( LayoutAnimationType type); -#ifdef DEBUG +#ifndef NDEBUG std::shared_ptr jsLogger_; // This set's function is to detect duplicate sharedTags on a single screen // it contains strings in form: "reactScreenTag:sharedTag" diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 396b657dafab..dd83446eaca5 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -31,7 +31,7 @@ #include #endif -#ifdef DEBUG +#ifndef NDEBUG #include "JSLogger.h" #endif @@ -61,7 +61,7 @@ NativeReanimatedModule::NativeReanimatedModule( onRender(timestampMs); }), animatedSensorModule_(platformDepMethodsHolder), -#ifdef DEBUG +#ifndef NDEBUG layoutAnimationsManager_(std::make_shared(jsScheduler_)), #endif #ifdef RCT_NEW_ARCH_ENABLED diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.h b/Common/cpp/NativeModules/NativeReanimatedModule.h index 67ef933df84d..17b2adafab20 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.h +++ b/Common/cpp/NativeModules/NativeReanimatedModule.h @@ -210,7 +210,7 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec { const KeyboardEventSubscribeFunction subscribeForKeyboardEventsFunction_; const KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction_; -#ifdef DEBUG +#ifndef NDEBUG SingleInstanceChecker singleInstanceChecker_; #endif }; diff --git a/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp b/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp index c1e03b3afd8b..d2d2b0e86c7e 100644 --- a/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp +++ b/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp @@ -1,7 +1,7 @@ #include "RNRuntimeDecorator.h" -#ifdef DEBUG +#ifndef NDEBUG #include "ReanimatedVersion.h" -#endif // DEBUG +#endif // NDEBUG namespace reanimated { @@ -31,9 +31,9 @@ void RNRuntimeDecorator::decorate( #endif // RCT_NEW_ARCH_ENABLED rnRuntime.global().setProperty(rnRuntime, "_IS_FABRIC", isFabric); -#ifdef DEBUG +#ifndef NDEBUG checkJSVersion(rnRuntime); -#endif // DEBUG +#endif // NDEBUG rnRuntime.global().setProperty( rnRuntime, "_REANIMATED_IS_REDUCED_MOTION", isReducedMotion); diff --git a/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp b/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp index de55bacf841d..f02aadad6c24 100644 --- a/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +++ b/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp @@ -93,7 +93,7 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime( jsQueue->quitSynchronous(); #endif // HERMES_ENABLE_DEBUGGER -#ifdef DEBUG +#ifndef NDEBUG facebook::hermes::HermesRuntime *wrappedRuntime = runtime_.get(); jsi::Value evalWithSourceMap = jsi::Function::createFromHostFunction( *runtime_, @@ -120,7 +120,7 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime( }); runtime_->global().setProperty( *runtime_, "evalWithSourceMap", evalWithSourceMap); -#endif // DEBUG +#endif // NDEBUG } ReanimatedHermesRuntime::~ReanimatedHermesRuntime() { diff --git a/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp b/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp index 79d8e2e30a7d..751039c1f24b 100644 --- a/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +++ b/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp @@ -29,7 +29,7 @@ void WorkletRuntimeDecorator::decorate( #endif // RCT_NEW_ARCH_ENABLED rt.global().setProperty(rt, "_IS_FABRIC", isFabric); -#ifdef DEBUG +#ifndef NDEBUG auto evalWithSourceUrl = [](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, diff --git a/Common/cpp/SharedItems/Shareables.cpp b/Common/cpp/SharedItems/Shareables.cpp index 46dae5b6b0be..a2d28072e1c2 100644 --- a/Common/cpp/SharedItems/Shareables.cpp +++ b/Common/cpp/SharedItems/Shareables.cpp @@ -10,7 +10,7 @@ jsi::Function getValueUnpacker(jsi::Runtime &rt) { return valueUnpacker.asObject(rt).asFunction(rt); } -#ifdef DEBUG +#ifndef NDEBUG static const auto callGuardLambda = [](facebook::jsi::Runtime &rt, const facebook::jsi::Value &thisVal, @@ -36,7 +36,7 @@ jsi::Function getCallGuard(jsi::Runtime &rt) { rt, jsi::PropNameID::forAscii(rt, "callGuard"), 1, callGuardLambda); } -#endif // DEBUG +#endif // NDEBUG jsi::Value makeShareableClone( jsi::Runtime &rt, @@ -224,7 +224,7 @@ jsi::Value ShareableRemoteFunction::toJSValue(jsi::Runtime &rt) { if (&rt == runtime_) { return jsi::Value(rt, *function_); } else { -#ifdef DEBUG +#ifndef NDEBUG return getValueUnpacker(rt).call( rt, ShareableJSRef::newHostObject(rt, shared_from_this()), diff --git a/Common/cpp/SharedItems/Shareables.h b/Common/cpp/SharedItems/Shareables.h index 719451436a37..0f6f0ab903c6 100644 --- a/Common/cpp/SharedItems/Shareables.h +++ b/Common/cpp/SharedItems/Shareables.h @@ -14,9 +14,9 @@ namespace reanimated { jsi::Function getValueUnpacker(jsi::Runtime &rt); -#ifdef DEBUG +#ifndef NDEBUG jsi::Function getCallGuard(jsi::Runtime &rt); -#endif // DEBUG +#endif // NDEBUG // If possible, please use `WorkletRuntime::runGuarded` instead. template @@ -28,7 +28,7 @@ inline void runOnRuntimeGuarded( // function directly. CallGuard provides a way of capturing exceptions in // JavaScript and propagating them to the main React Native thread such that // they can be presented using RN's LogBox. -#ifdef DEBUG +#ifndef NDEBUG getCallGuard(rt).call(rt, function, args...); #else function.asObject(rt).asFunction(rt).call(rt, args...); diff --git a/Common/cpp/Tools/JSLogger.cpp b/Common/cpp/Tools/JSLogger.cpp index 3d173f2b8072..3c9d923eb2ba 100644 --- a/Common/cpp/Tools/JSLogger.cpp +++ b/Common/cpp/Tools/JSLogger.cpp @@ -1,4 +1,4 @@ -#ifdef DEBUG +#ifndef NDEBUG #include "JSLogger.h" #include @@ -15,4 +15,4 @@ void JSLogger::warnOnJS(const std::string &warning) const { } // namespace reanimated -#endif // DEBUG +#endif // NDEBUG diff --git a/Common/cpp/Tools/JSLogger.h b/Common/cpp/Tools/JSLogger.h index d88560c98d5b..aab9b8d58ca5 100644 --- a/Common/cpp/Tools/JSLogger.h +++ b/Common/cpp/Tools/JSLogger.h @@ -1,4 +1,4 @@ -#ifdef DEBUG +#ifndef NDEBUG #pragma once @@ -21,4 +21,4 @@ class JSLogger { } // namespace reanimated -#endif // DEBUG +#endif // NDEBUG diff --git a/Common/cpp/Tools/ReanimatedVersion.cpp b/Common/cpp/Tools/ReanimatedVersion.cpp index b7bab62493ea..b0f5a6f83acc 100644 --- a/Common/cpp/Tools/ReanimatedVersion.cpp +++ b/Common/cpp/Tools/ReanimatedVersion.cpp @@ -18,7 +18,7 @@ std::string getReanimatedCppVersion() { // This function is pretty much a copy of // `src/reanimated2/platform-specific/checkVersion.ts`. -#ifdef DEBUG +#ifndef NDEBUG bool matchVersion(const std::string &version1, const std::string &version2) { std::regex pattern("^\\d+\\.\\d+\\.\\d+$"); if (std::regex_match(version1, pattern) && @@ -68,6 +68,6 @@ void checkJSVersion(jsi::Runtime &rnRuntime) { "_REANIMATED_VERSION_CPP", jsi::String::createFromUtf8(rnRuntime, cppVersion)); } -#endif // DEBUG +#endif // NDEBUG }; // namespace reanimated diff --git a/Common/cpp/Tools/ReanimatedVersion.h b/Common/cpp/Tools/ReanimatedVersion.h index 5953ccca9151..b4f4092e0c63 100644 --- a/Common/cpp/Tools/ReanimatedVersion.h +++ b/Common/cpp/Tools/ReanimatedVersion.h @@ -9,9 +9,9 @@ namespace reanimated { std::string getReanimatedCppVersion(); -#ifdef DEBUG +#ifndef NDEBUG bool matchVersion(const std::string &, const std::string &); void checkJSVersion(jsi::Runtime &); -#endif // DEBUG +#endif // NDEBUG }; // namespace reanimated diff --git a/Common/cpp/Tools/SingleInstanceChecker.h b/Common/cpp/Tools/SingleInstanceChecker.h index 672c061358e1..7474a6764f1c 100644 --- a/Common/cpp/Tools/SingleInstanceChecker.h +++ b/Common/cpp/Tools/SingleInstanceChecker.h @@ -1,6 +1,6 @@ #pragma once -#ifdef DEBUG +#ifndef NDEBUG #include @@ -67,4 +67,4 @@ SingleInstanceChecker::~SingleInstanceChecker() { } // namespace reanimated -#endif // DEBUG +#endif // NDEBUG diff --git a/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj b/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj index 112da7dfdf66..0f0b5bbb9a89 100644 --- a/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj +++ b/Example/ios/ReanimatedExample.xcodeproj/project.pbxproj @@ -488,7 +488,6 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = ReanimatedExampleTests/Info.plist; @@ -624,7 +623,6 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; diff --git a/Example/ios/ReanimatedExample/AppDelegate.mm b/Example/ios/ReanimatedExample/AppDelegate.mm index 9aad30f56146..d573152564b7 100644 --- a/Example/ios/ReanimatedExample/AppDelegate.mm +++ b/Example/ios/ReanimatedExample/AppDelegate.mm @@ -16,7 +16,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { -#if DEBUG +#ifndef NDEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/Example/ios/ReanimatedExampleTests/ReanimatedExampleTests.m b/Example/ios/ReanimatedExampleTests/ReanimatedExampleTests.m index 7aa4f2a53335..35a90c231c1e 100644 --- a/Example/ios/ReanimatedExampleTests/ReanimatedExampleTests.m +++ b/Example/ios/ReanimatedExampleTests/ReanimatedExampleTests.m @@ -33,7 +33,7 @@ - (void)testRendersWelcomeScreen BOOL foundElement = NO; __block NSString *redboxError = nil; -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction( ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { @@ -55,7 +55,7 @@ - (void)testRendersWelcomeScreen }]; } -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction(RCTDefaultLogFunction); #endif diff --git a/FabricExample/ios/FabricExample.xcodeproj/project.pbxproj b/FabricExample/ios/FabricExample.xcodeproj/project.pbxproj index c3dba7f05e35..404ac4aca6eb 100644 --- a/FabricExample/ios/FabricExample.xcodeproj/project.pbxproj +++ b/FabricExample/ios/FabricExample.xcodeproj/project.pbxproj @@ -483,7 +483,6 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = FabricExampleTests/Info.plist; @@ -619,7 +618,6 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; diff --git a/FabricExample/ios/FabricExample/AppDelegate.mm b/FabricExample/ios/FabricExample/AppDelegate.mm index 7cfe873e105f..edf5cf12ed61 100644 --- a/FabricExample/ios/FabricExample/AppDelegate.mm +++ b/FabricExample/ios/FabricExample/AppDelegate.mm @@ -16,7 +16,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { -#if DEBUG +#ifndef NDEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/FabricExample/ios/FabricExampleTests/FabricExampleTests.m b/FabricExample/ios/FabricExampleTests/FabricExampleTests.m index f023368a4e70..33e5c1ec7580 100644 --- a/FabricExample/ios/FabricExampleTests/FabricExampleTests.m +++ b/FabricExample/ios/FabricExampleTests/FabricExampleTests.m @@ -33,7 +33,7 @@ - (void)testRendersWelcomeScreen BOOL foundElement = NO; __block NSString *redboxError = nil; -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction( ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { @@ -55,7 +55,7 @@ - (void)testRendersWelcomeScreen }]; } -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction(RCTDefaultLogFunction); #endif diff --git a/MacOSExample/ios/MacOSExample.xcodeproj/project.pbxproj b/MacOSExample/ios/MacOSExample.xcodeproj/project.pbxproj index 0a624531147e..18bab0fbf201 100644 --- a/MacOSExample/ios/MacOSExample.xcodeproj/project.pbxproj +++ b/MacOSExample/ios/MacOSExample.xcodeproj/project.pbxproj @@ -434,7 +434,6 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = MacOSExampleTests/Info.plist; @@ -570,7 +569,6 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; diff --git a/MacOSExample/ios/MacOSExample/AppDelegate.mm b/MacOSExample/ios/MacOSExample/AppDelegate.mm index 087182219cc8..3b50a45bf562 100644 --- a/MacOSExample/ios/MacOSExample/AppDelegate.mm +++ b/MacOSExample/ios/MacOSExample/AppDelegate.mm @@ -16,7 +16,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { -#if DEBUG +#ifndef NDEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/MacOSExample/ios/MacOSExampleTests/MacOSExampleTests.m b/MacOSExample/ios/MacOSExampleTests/MacOSExampleTests.m index 3abc5509c5d8..4d0f2fa1a7e2 100644 --- a/MacOSExample/ios/MacOSExampleTests/MacOSExampleTests.m +++ b/MacOSExample/ios/MacOSExampleTests/MacOSExampleTests.m @@ -33,7 +33,7 @@ - (void)testRendersWelcomeScreen BOOL foundElement = NO; __block NSString *redboxError = nil; -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction( ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { @@ -55,7 +55,7 @@ - (void)testRendersWelcomeScreen }]; } -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction(RCTDefaultLogFunction); #endif diff --git a/MacOSExample/macos/MacOSExample-macOS/AppDelegate.mm b/MacOSExample/macos/MacOSExample-macOS/AppDelegate.mm index 1f66841abf05..b7bb2660ddf4 100644 --- a/MacOSExample/macos/MacOSExample-macOS/AppDelegate.mm +++ b/MacOSExample/macos/MacOSExample-macOS/AppDelegate.mm @@ -16,7 +16,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { -#if DEBUG +#ifndef NDEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/MacOSExample/macos/MacOSExample.xcodeproj/project.pbxproj b/MacOSExample/macos/MacOSExample.xcodeproj/project.pbxproj index 90c0b980e4ec..73c50fe3e5f1 100644 --- a/MacOSExample/macos/MacOSExample.xcodeproj/project.pbxproj +++ b/MacOSExample/macos/MacOSExample.xcodeproj/project.pbxproj @@ -474,7 +474,6 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; diff --git a/TVOSExample/ios/TVOSExample.xcodeproj/project.pbxproj b/TVOSExample/ios/TVOSExample.xcodeproj/project.pbxproj index a7200b1bb072..bc37ec70d512 100644 --- a/TVOSExample/ios/TVOSExample.xcodeproj/project.pbxproj +++ b/TVOSExample/ios/TVOSExample.xcodeproj/project.pbxproj @@ -681,7 +681,6 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = TVOSExampleTests/Info.plist; @@ -916,7 +915,6 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; diff --git a/TVOSExample/ios/TVOSExample/AppDelegate.mm b/TVOSExample/ios/TVOSExample/AppDelegate.mm index 9ec85147bec6..4bb7bc2e63d8 100644 --- a/TVOSExample/ios/TVOSExample/AppDelegate.mm +++ b/TVOSExample/ios/TVOSExample/AppDelegate.mm @@ -87,7 +87,7 @@ - (NSDictionary *)prepareInitialProps - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { -#if DEBUG +#ifndef NDEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/TVOSExample/ios/TVOSExampleTests/TVOSExampleTests.m b/TVOSExample/ios/TVOSExampleTests/TVOSExampleTests.m index 5a2466ad5d21..2774895c0a10 100644 --- a/TVOSExample/ios/TVOSExampleTests/TVOSExampleTests.m +++ b/TVOSExample/ios/TVOSExampleTests/TVOSExampleTests.m @@ -33,7 +33,7 @@ - (void)testRendersWelcomeScreen BOOL foundElement = NO; __block NSString *redboxError = nil; -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction( ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { @@ -55,7 +55,7 @@ - (void)testRendersWelcomeScreen }]; } -#ifdef DEBUG +#ifndef NDEBUG RCTSetLogFunction(RCTDefaultLogFunction); #endif diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index ce92879fb560..8526cefcee9d 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -26,9 +26,7 @@ if(${IS_REANIMATED_EXAMPLE_APP}) string(APPEND CMAKE_CXX_FLAGS " -DIS_REANIMATED_EXAMPLE_APP") endif() -if(${CMAKE_BUILD_TYPE} MATCHES "Debug") - string(APPEND CMAKE_CXX_FLAGS " -DDEBUG") -else() +if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug") string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG") endif() diff --git a/android/src/main/cpp/LayoutAnimations.cpp b/android/src/main/cpp/LayoutAnimations.cpp index 02e6bb760090..acd19f8a3849 100644 --- a/android/src/main/cpp/LayoutAnimations.cpp +++ b/android/src/main/cpp/LayoutAnimations.cpp @@ -52,7 +52,7 @@ void LayoutAnimations::setShouldAnimateExitingBlock( this->shouldAnimateExitingBlock_ = shouldAnimateExitingBlock; } -#ifdef DEBUG +#ifndef NDEBUG void LayoutAnimations::setCheckDuplicateSharedTag( CheckDuplicateSharedTag checkDuplicateSharedTag) { checkDuplicateSharedTag_ = checkDuplicateSharedTag; @@ -124,7 +124,7 @@ void LayoutAnimations::registerNatives() { makeNativeMethod( "findPrecedingViewTagForTransition", LayoutAnimations::findPrecedingViewTagForTransition), -#ifdef DEBUG +#ifndef NDEBUG makeNativeMethod( "checkDuplicateSharedTag", LayoutAnimations::checkDuplicateSharedTag), #endif diff --git a/android/src/main/cpp/LayoutAnimations.h b/android/src/main/cpp/LayoutAnimations.h index 692c3172ad8e..053c8948ea29 100644 --- a/android/src/main/cpp/LayoutAnimations.h +++ b/android/src/main/cpp/LayoutAnimations.h @@ -16,7 +16,7 @@ class LayoutAnimations : public jni::HybridClass { std::function>)>; using HasAnimationBlock = std::function; using ShouldAnimateExitingBlock = std::function; -#ifdef DEBUG +#ifndef NDEBUG using CheckDuplicateSharedTag = std::function; #endif using ClearAnimationConfigBlock = std::function; @@ -42,7 +42,7 @@ class LayoutAnimations : public jni::HybridClass { void setHasAnimationBlock(HasAnimationBlock hasAnimationBlock); void setShouldAnimateExitingBlock( ShouldAnimateExitingBlock shouldAnimateExitingBlock); -#ifdef DEBUG +#ifndef NDEBUG void setCheckDuplicateSharedTag( CheckDuplicateSharedTag checkDuplicateSharedTag); void checkDuplicateSharedTag(int viewTag, int screenTag); @@ -73,7 +73,7 @@ class LayoutAnimations : public jni::HybridClass { CancelAnimationBlock cancelAnimationBlock_; FindPrecedingViewTagForTransitionBlock findPrecedingViewTagForTransitionBlock_; -#ifdef DEBUG +#ifndef NDEBUG CheckDuplicateSharedTag checkDuplicateSharedTag_; #endif diff --git a/android/src/main/cpp/NativeProxy.cpp b/android/src/main/cpp/NativeProxy.cpp index 74030e87545e..a1baf1e10b71 100644 --- a/android/src/main/cpp/NativeProxy.cpp +++ b/android/src/main/cpp/NativeProxy.cpp @@ -16,9 +16,9 @@ #include "RNRuntimeDecorator.h" #include "ReanimatedJSIUtils.h" #include "ReanimatedRuntime.h" -#ifdef DEBUG +#ifndef NDEBUG #include "ReanimatedVersion.h" -#endif // DEBUG +#endif // NDEBUG #include "WorkletRuntime.h" #include "WorkletRuntimeCollector.h" @@ -104,7 +104,7 @@ jni::local_ref NativeProxy::initHybrid( /**/); } -#ifdef DEBUG +#ifndef NDEBUG void NativeProxy::checkJavaVersion(jsi::Runtime &rnRuntime) { std::string javaVersion; try { @@ -141,7 +141,7 @@ void NativeProxy::injectCppVersion() { "See `https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#c-side-failed-to-resolve-java-code-version` for more details."); } } -#endif // DEBUG +#endif // NDEBUG void NativeProxy::installJSIBindings() { jsi::Runtime &rnRuntime = *rnRuntime_; @@ -149,10 +149,10 @@ void NativeProxy::installJSIBindings() { auto isReducedMotion = getIsReducedMotion(); RNRuntimeDecorator::decorate( rnRuntime, nativeReanimatedModule_, isReducedMotion); -#ifdef DEBUG +#ifndef NDEBUG checkJavaVersion(rnRuntime); injectCppVersion(); -#endif // DEBUG +#endif // NDEBUG registerEventHandler(); setupLayoutAnimations(); @@ -553,7 +553,7 @@ void NativeProxy::setupLayoutAnimations() { return false; }); -#ifdef DEBUG +#ifndef NDEBUG layoutAnimations_->cthis()->setCheckDuplicateSharedTag( [weakNativeReanimatedModule](int viewTag, int screenTag) { if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) { diff --git a/android/src/main/cpp/NativeProxy.h b/android/src/main/cpp/NativeProxy.h index e73796625c17..2ce436ec7296 100644 --- a/android/src/main/cpp/NativeProxy.h +++ b/android/src/main/cpp/NativeProxy.h @@ -170,10 +170,10 @@ class NativeProxy : public jni::HybridClass { jsi::Runtime *rnRuntime_; std::shared_ptr nativeReanimatedModule_; jni::global_ref layoutAnimations_; -#ifdef DEBUG +#ifndef NDEBUG void checkJavaVersion(jsi::Runtime &); void injectCppVersion(); -#endif // DEBUG +#endif // NDEBUG #ifdef RCT_NEW_ARCH_ENABLED // removed temporarily, event listener mechanism needs to be fixed on RN side // std::shared_ptr reactScheduler_; diff --git a/apple/LayoutReanimation/REAAnimationsManager.h b/apple/LayoutReanimation/REAAnimationsManager.h index bbc11729c854..2c14a89a9b3d 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.h +++ b/apple/LayoutReanimation/REAAnimationsManager.h @@ -20,7 +20,7 @@ typedef BOOL (^REAShouldAnimateExitingBlock)(NSNumber *_Nonnull tag, BOOL should typedef void ( ^REAAnimationStartingBlock)(NSNumber *_Nonnull tag, LayoutAnimationType type, NSDictionary *_Nonnull yogaValues); typedef void (^REAAnimationRemovingBlock)(NSNumber *_Nonnull tag); -#ifdef DEBUG +#ifndef NDEBUG typedef void (^REACheckDuplicateSharedTagBlock)(REAUIView *view, NSNumber *_Nonnull viewTag); #endif typedef void (^REACancelAnimationBlock)(NSNumber *_Nonnull tag); @@ -35,7 +35,7 @@ BOOL REANodeFind(id view, int (^block)(id)); - (void)setHasAnimationBlock:(REAHasAnimationBlock)hasAnimation; - (void)setShouldAnimateExitingBlock:(REAShouldAnimateExitingBlock)shouldAnimateExiting; - (void)setAnimationRemovingBlock:(REAAnimationRemovingBlock)clearAnimation; -#ifdef DEBUG +#ifndef NDEBUG - (void)setCheckDuplicateSharedTagBlock:(REACheckDuplicateSharedTagBlock)checkDuplicateSharedTag; #endif - (void)progressLayoutAnimationWithStyle:(NSDictionary *_Nonnull)newStyle diff --git a/apple/LayoutReanimation/REAAnimationsManager.m b/apple/LayoutReanimation/REAAnimationsManager.m index 572af3b3df5b..19b85a99f09c 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.m +++ b/apple/LayoutReanimation/REAAnimationsManager.m @@ -44,7 +44,7 @@ @implementation REAAnimationsManager { REAShouldAnimateExitingBlock _shouldAnimateExiting; REAAnimationRemovingBlock _clearAnimationConfigForTag; REASharedTransitionManager *_sharedTransitionManager; -#ifdef DEBUG +#ifndef NDEBUG REACheckDuplicateSharedTagBlock _checkDuplicateSharedTag; #endif } @@ -93,7 +93,7 @@ - (instancetype)initWithUIManager:(RCTUIManager *)uiManager _clearAnimationConfigForTag = ^(NSNumber *tag) { // default implementation, this block will be replaced by a setter }; -#ifdef DEBUG +#ifndef NDEBUG _checkDuplicateSharedTag = ^(REAUIView *view, NSNumber *viewTag) { // default implementation, this block will be replaced by a setter }; @@ -132,7 +132,7 @@ - (void)setAnimationRemovingBlock:(REAAnimationRemovingBlock)clearAnimation _clearAnimationConfigForTag = clearAnimation; } -#ifdef DEBUG +#ifndef NDEBUG - (void)setCheckDuplicateSharedTagBlock:(REACheckDuplicateSharedTagBlock)checkDuplicateSharedTag { _checkDuplicateSharedTag = checkDuplicateSharedTag; @@ -567,7 +567,7 @@ - (void)viewDidMount:(REAUIView *)view withBeforeSnapshot:(nonnull REASnapshot * if (_hasAnimationForTag(viewTag, SHARED_ELEMENT_TRANSITION)) { if (type == ENTERING) { [_sharedTransitionManager notifyAboutNewView:view]; -#ifdef DEBUG +#ifndef NDEBUG _checkDuplicateSharedTag(view, viewTag); #endif } else { diff --git a/apple/REAModule.mm b/apple/REAModule.mm index 5234e655099e..4d9cb054d349 100644 --- a/apple/REAModule.mm +++ b/apple/REAModule.mm @@ -53,7 +53,7 @@ @implementation REAModule { #else NSMutableArray *_operations; #endif -#ifdef DEBUG +#ifndef NDEBUG SingleInstanceChecker singleInstanceChecker_; #endif bool hasListeners; @@ -162,7 +162,7 @@ - (void)setBridge:(RCTBridge *)bridge // only within the first loading `self.bridge.surfacePresenter` exists // during the reload `self.bridge.surfacePresenter` is null _surfacePresenter = self.bridge.surfacePresenter; -#ifdef DEBUG +#ifndef NDEBUG if (reaSurface == nil) { // we need only one instance because SurfacePresenter is the same during the application lifetime reaSurface = [[REAInitializerRCTFabricSurface alloc] init]; diff --git a/apple/RNReanimated.xcodeproj/project.pbxproj b/apple/RNReanimated.xcodeproj/project.pbxproj index df7566c2fb25..d55b9e3da185 100644 --- a/apple/RNReanimated.xcodeproj/project.pbxproj +++ b/apple/RNReanimated.xcodeproj/project.pbxproj @@ -429,7 +429,6 @@ GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; diff --git a/apple/native/NativeProxy.mm b/apple/native/NativeProxy.mm index 1ffd30806229..08843c48d4f8 100644 --- a/apple/native/NativeProxy.mm +++ b/apple/native/NativeProxy.mm @@ -13,7 +13,7 @@ #import #import -#ifdef DEBUG +#ifndef NDEBUG #import #endif @@ -371,7 +371,7 @@ static CFTimeInterval calculateTimestampWithSlowAnimations(CFTimeInterval curren } return nil; }]; -#ifdef DEBUG +#ifndef NDEBUG [animationsManager setCheckDuplicateSharedTagBlock:^(REAUIView *view, NSNumber *_Nonnull viewTag) { if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) { REAUIView *screen = [REAScreensHelper getScreenForView:(REAUIView *)view]; @@ -380,7 +380,7 @@ static CFTimeInterval calculateTimestampWithSlowAnimations(CFTimeInterval curren nativeReanimatedModule->layoutAnimationsManager().checkDuplicateSharedTag([viewTag intValue], screenTag); } }]; -#endif // DEBUG +#endif // NDEBUG #endif