From cf1b8db01ce061c0f0b2c85ed9bd4b4c1fdbca15 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Wed, 15 Jan 2025 16:49:23 +0100 Subject: [PATCH] fix: Fix namespace --- .../src/views/swift/SwiftHybridViewManager.ts | 41 ++++++++++--------- .../ios/c++/views/TestViewComponent.mm | 38 ++++++++--------- .../cpp/utils/NitroDefines.hpp | 3 ++ 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts b/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts index 403dc1e33..2bdcba233 100644 --- a/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts +++ b/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts @@ -12,7 +12,8 @@ export function createSwiftHybridViewManager( ): SourceFile[] { const cppFiles = createViewComponentShadowNodeFiles(spec) const namespace = NitroConfig.getCxxNamespace('c++', 'views') - const { component, descriptorClassName } = getViewComponentNames(spec) + const { component, descriptorClassName, propsClassName } = + getViewComponentNames(spec) const mmFile = ` ${createFileMetadataString(`${component}.mm`)} @@ -20,34 +21,34 @@ ${createFileMetadataString(`${component}.mm`)} #if REACT_NATIVE_VERSION >= 78 #import "${component}.hpp" +#import +#import #import #import #import -namespace ${namespace} { +using namespace facebook; - @interface ${component}: RCTViewComponentView - @end +@interface ${component}: RCTViewComponentView +@end - @implementation ${component} - + (void) load { - [super load]; - // TODO: Register it! - } - - + (ComponentDescriptorProvider)componentDescriptorProvider { - return concreteComponentDescriptorProvider<${descriptorClassName}>(); - } +@implementation ${component} ++ (void) load { + [super load]; + // TODO: Register it! +} - - (void)updateProps:(const facebook::react::Props::Shared&)props - oldProps:(const facebook::react::Props::Shared&)oldProps { - // TODO: const auto& newViewProps = *std::static_pointer_cast(props); ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { + return react::concreteComponentDescriptorProvider<${namespace}::${descriptorClassName}>(); +} - [super updateProps:props oldProps:oldProps]; - } - @end +- (void)updateProps:(const facebook::react::Props::Shared&)props + oldProps:(const facebook::react::Props::Shared&)oldProps { + // TODO: const auto& newViewProps = *std::static_pointer_cast<${namespace}::${propsClassName} const>(props); -} // namespace ${namespace} + [super updateProps:props oldProps:oldProps]; +} +@end #endif ` diff --git a/packages/react-native-nitro-image/nitrogen/generated/ios/c++/views/TestViewComponent.mm b/packages/react-native-nitro-image/nitrogen/generated/ios/c++/views/TestViewComponent.mm index 03bcc1dc3..3a8abe455 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/ios/c++/views/TestViewComponent.mm +++ b/packages/react-native-nitro-image/nitrogen/generated/ios/c++/views/TestViewComponent.mm @@ -8,33 +8,33 @@ #if REACT_NATIVE_VERSION >= 78 #import "TestViewComponent.hpp" +#import +#import #import #import #import -namespace margelo::nitro::image::views { +using namespace facebook; - @interface TestViewComponent: RCTViewComponentView - @end +@interface TestViewComponent: RCTViewComponentView +@end - @implementation TestViewComponent - + (void) load { - [super load]; - // TODO: Register it! - } +@implementation TestViewComponent ++ (void) load { + [super load]; + // TODO: Register it! +} - + (ComponentDescriptorProvider)componentDescriptorProvider { - return concreteComponentDescriptorProvider(); - } ++ (react::ComponentDescriptorProvider)componentDescriptorProvider { + return react::concreteComponentDescriptorProvider(); +} - - (void)updateProps:(const facebook::react::Props::Shared&)props - oldProps:(const facebook::react::Props::Shared&)oldProps { - // TODO: const auto& newViewProps = *std::static_pointer_cast(props); +- (void)updateProps:(const facebook::react::Props::Shared&)props + oldProps:(const facebook::react::Props::Shared&)oldProps { + // TODO: const auto& newViewProps = *std::static_pointer_cast(props); - [super updateProps:props oldProps:oldProps]; - } - @end - -} // namespace margelo::nitro::image::views + [super updateProps:props oldProps:oldProps]; +} +@end #endif diff --git a/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp b/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp index d1a947488..3740ee5d9 100644 --- a/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp +++ b/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp @@ -8,6 +8,9 @@ #ifndef NitroDefines_h #define NitroDefines_h +#undef REACT_NATIVE_VERSION +#define REACT_NATIVE_VERSION 78 + // Sets the version of the native Nitro core library #define NITRO_VERSION "0.21.0"