diff --git a/React/Base/RCTAssert.h b/React/Base/RCTAssert.h index 95b37cc785d..d4ec7fc40c2 100644 --- a/React/Base/RCTAssert.h +++ b/React/Base/RCTAssert.h @@ -169,3 +169,11 @@ RCT_EXTERN NSString *RCTFormatStackTrace(NSArray *> } while (0) #endif + +/** + * Controls for ensuring the new architecture runtime assumption holds. + * Note: this is work in progress. + */ +__attribute__((used)) RCT_EXTERN void RCTEnableNewArchitectureViolationReporting(BOOL enabled); +__attribute__((used)) RCT_EXTERN BOOL RCTNewArchitectureViolationReportingEnabled(void); +__attribute__((used)) RCT_EXTERN void RCTAssertAndTrackNewArchitectureViolation(NSString *violation); diff --git a/React/Base/RCTAssert.m b/React/Base/RCTAssert.m index 087900d1979..4f40bbfa01a 100644 --- a/React/Base/RCTAssert.m +++ b/React/Base/RCTAssert.m @@ -230,3 +230,29 @@ RCTFatalExceptionHandler RCTGetFatalExceptionHandler(void) { return RCTCurrentFatalExceptionHandler; } + +// New architecture section. +static BOOL newArchitectureViolationReporting = NO; + +void RCTEnableNewArchitectureViolationReporting(BOOL enabled) +{ + newArchitectureViolationReporting = enabled; +} + +BOOL RCTNewArchitectureViolationReportingEnabled(void) +{ + return newArchitectureViolationReporting; +} + +void RCTAssertAndTrackNewArchitectureViolation(NSString *violation) +{ + if (!RCTNewArchitectureViolationReportingEnabled()) { + return; + } + +#if RCT_NEW_ARCHITECTURE + RCTAssert(0, @"New architecture violation assertion: %@", violation); +#endif + + // TODO: Actually track violations in a global space (separate from assertion). +} diff --git a/React/Base/RCTDefines.h b/React/Base/RCTDefines.h index 23be65eb5c6..b416f71a635 100644 --- a/React/Base/RCTDefines.h +++ b/React/Base/RCTDefines.h @@ -142,3 +142,13 @@ @throw _RCTNotImplementedException(_cmd, [self class]); \ } \ _Pragma("clang diagnostic pop") + +/** + * Controls for activating the new architecture without the legacy system. + * Note: this is work in progress. + */ +#ifdef REACT_NATIVE_FORCE_NEW_ARCHITECTURE +#define RCT_NEW_ARCHITECTURE 1 +#else +#define RCT_NEW_ARCHITECTURE 0 +#endif