Skip to content

Commit

Permalink
refactor: use macro for header fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsoftwaretyler committed Dec 15, 2024
1 parent 828bc0f commit 3161150
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 90 deletions.
96 changes: 96 additions & 0 deletions changes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
diff --git a/ios/RNIContextMenuButton/RNIContextMenuButton.mm b/ios/RNIContextMenuButton/RNIContextMenuButton.mm
index 3d91bae..0870791 100644
--- a/ios/RNIContextMenuButton/RNIContextMenuButton.mm
+++ b/ios/RNIContextMenuButton/RNIContextMenuButton.mm
@@ -23,8 +23,13 @@
#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuButtonComponentDescriptor.h"

+#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewState.h>
+#include <react-native-ios-utilities/RNIBaseViewProps.h>
+#endif

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
diff --git a/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h b/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h
index 0fe922b..7cf637e 100644
--- a/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h
+++ b/ios/RNIContextMenuButton/RNIContextMenuButtonComponentDescriptor.h
@@ -11,7 +11,11 @@
#include "RNIContextMenuButtonShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"

+#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewState.h>
+#endif

#include <react/renderer/core/ConcreteComponentDescriptor.h>

diff --git a/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h b/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
index ac1b293..d9ffbb6 100644
--- a/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
+++ b/ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
@@ -8,9 +8,15 @@
#if __cplusplus
#pragma once

+#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
+#include <react-native-ios-utilities/RNIBaseViewProps.h>
+#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
+#endif

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
diff --git a/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h b/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h
index 2e30bbb..5aa27cd 100644
--- a/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h
+++ b/ios/RNIContextMenuView/RNIContextMenuViewComponentDescriptor.h
@@ -8,11 +8,17 @@
#if __cplusplus
#pragma once

+
#include "RNIContextMenuViewShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"

+#if __has_include(<react_native_ios_utilities/RNIBaseViewComponentDescriptor.h>)
#include <react_native_ios_utilities/RNIBaseViewComponentDescriptor.h>
#include <react_native_ios_utilities/RNIBaseViewState.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewComponentDescriptor.h>
+#include <react-native-ios-utilities/RNIBaseViewState.h>
+#endif

#include <react/renderer/core/ConcreteComponentDescriptor.h>

diff --git a/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h b/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
index a72e1fc..d0a0106 100644
--- a/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
+++ b/ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
@@ -8,9 +8,15 @@
#if __cplusplus
#pragma once

+#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
+#else
+#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
+#include <react-native-ios-utilities/RNIBaseViewProps.h>
+#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
+#endif

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
8 changes: 3 additions & 5 deletions ios/RNIContextMenuButton/RNIContextMenuButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
// Created by Dominic Go on 8/24/24.
//

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#endif
#import "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseView.h)

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
Expand Down
25 changes: 6 additions & 19 deletions ios/RNIContextMenuButton/RNIContextMenuButton.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,16 @@

#import "RNIContextMenuButton.h"
#import "../Swift.h"
#import "../RNIHeaderUtils.h"

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#import <react_native_ios_utilities/RNIContentViewParentDelegate.h>
#import <react_native_ios_utilities/UIApplication+RNIHelpers.h>
#import <react_native_ios_utilities/RNIObjcUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#import <react-native-ios-utilities/RNIContentViewParentDelegate.h>
#import <react-native-ios-utilities/UIApplication+RNIHelpers.h>
#import <react-native-ios-utilities/RNIObjcUtils.h>
#endif
#import RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
#import RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
#import RNI_INCLUDE_HEADER(RNIObjcUtils.h)

#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuButtonComponentDescriptor.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#else
#include <react-native-ios-utilities/RNIBaseViewState.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#endif
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewProps.h)

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

#include "RNIContextMenuButtonShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"
#include "../RNIHeaderUtils.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#else
#include <react-native-ios-utilities/RNIBaseViewState.h>
#endif
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)

#include <react/renderer/core/ConcreteComponentDescriptor.h>

Expand Down
16 changes: 6 additions & 10 deletions ios/RNIContextMenuButton/RNIContextMenuButtonShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
#if __cplusplus
#pragma once

#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
#else
#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
#endif
#include "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseViewShadowNode.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewEventEmitter.h)

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
Expand All @@ -34,7 +30,7 @@ class JSI_EXPORT RNIContextMenuButtonShadowNode final :

public:
using RNIBaseViewShadowNode::RNIBaseViewShadowNode;

static RNIBaseViewState initialStateData(
const Props::Shared&r , // props
const ShadowNodeFamily::Shared&, // family
Expand Down
8 changes: 3 additions & 5 deletions ios/RNIContextMenuButton/RNIContextMenuButtonViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#import "RNIContextMenuButton.h"
#import <objc/runtime.h>

#if __has_include(<react_native_ios_utilities/RNIBaseViewUtils.h>)
#import <react_native_ios_utilities/RNIBaseViewUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseViewUtils.h>
#endif
#import "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)

#import "RCTBridge.h"
#import <React/RCTViewManager.h>
Expand Down
8 changes: 3 additions & 5 deletions ios/RNIContextMenuView/RNIContextMenuView.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
// Created by Dominic Go on 8/24/24.
//

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#endif
#import "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseView.h)

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
Expand Down
28 changes: 11 additions & 17 deletions ios/RNIContextMenuView/RNIContextMenuView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,22 @@
#import "RNIContextMenuView.h"
#import "../Swift.h"

#if __has_include(<react_native_ios_utilities/RNIBaseView.h>)
#import <react_native_ios_utilities/RNIBaseView.h>
#import <react_native_ios_utilities/RNIContentViewParentDelegate.h>
#import <react_native_ios_utilities/UIApplication+RNIHelpers.h>
#import <react_native_ios_utilities/RNIObjcUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseView.h>
#import <react-native-ios-utilities/RNIContentViewParentDelegate.h>
#import <react-native-ios-utilities/UIApplication+RNIHelpers.h>
#import <react-native-ios-utilities/RNIObjcUtils.h>
#import "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseView.h)
#import RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
#import RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
#import RNI_INCLUDE_HEADER(RNIObjcUtils.h)

#if RCT_NEW_ARCH_ENABLED
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#endif

#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuViewComponentDescriptor.h"

#if __has_include(<react_native_ios_utilities/RNIBaseViewState.h>)
#include <react_native_ios_utilities/RNIBaseViewState.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#else
#include <react-native-ios-utilities/RNIBaseViewState.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#endif
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewProps.h)

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RNIContextMenuViewComponentDescriptor final : public RNIBaseViewComponentD
RNIContextMenuViewShadowNode,
RNIContextMenuViewComponentName
> {

public:
using RNIBaseViewComponentDescriptor::RNIBaseViewComponentDescriptor;
};
Expand Down
8 changes: 3 additions & 5 deletions ios/RNIContextMenuView/RNIContextMenuViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#import "RNIContextMenuView.h"
#import <objc/runtime.h>

#if __has_include(<react_native_ios_utilities/RNIBaseViewUtils.h>)
#import <react_native_ios_utilities/RNIBaseViewUtils.h>
#else
#import <react-native-ios-utilities/RNIBaseViewUtils.h>
#endif
#import "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)

#import "RCTBridge.h"
#import <React/RCTViewManager.h>
Expand Down
16 changes: 6 additions & 10 deletions ios/RNIContextMenuView/RNIContextMenuViewShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
#if __cplusplus
#pragma once

#if __has_include(<react_native_ios_utilities/RNIBaseViewShadowNode.h>)
#include <react_native_ios_utilities/RNIBaseViewShadowNode.h>
#include <react_native_ios_utilities/RNIBaseViewProps.h>
#include <react_native_ios_utilities/RNIBaseViewEventEmitter.h>
#else
#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>
#endif
#include "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseViewShadowNode.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewEventEmitter.h)

#include <react/renderer/components/RNIContextMenuViewSpec/EventEmitters.h>
#include <react/renderer/components/RNIContextMenuViewSpec/Props.h>
Expand All @@ -34,7 +30,7 @@ class JSI_EXPORT RNIContextMenuViewShadowNode final :

public:
using RNIBaseViewShadowNode::RNIBaseViewShadowNode;

static RNIBaseViewState initialStateData(
const Props::Shared&r , // props
const ShadowNodeFamily::Shared&, // family
Expand Down
7 changes: 7 additions & 0 deletions ios/RNIHeaderUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#if __has_include(<react_native_ios_utilities/header>)
#define RNI_INCLUDE_HEADER(header) <react_native_ios_utilities/header>
#else
#define RNI_INCLUDE_HEADER(header) <react-native-ios-utilities/header>
#endif
4 changes: 0 additions & 4 deletions ios/Swift.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
//
// Created by Dominic Go on 8/24/24.
//

// When `use_frameworks!` is used, the generated Swift header is inside
// the module.
// Otherwise, it's available only locally with double-quoted imports.
#if __has_include(<react_native_ios_context_menu/react_native_ios_context_menu-Swift.h>)
#import <react_native_ios_context_menu/react_native_ios_context_menu-Swift.h>

Expand Down
8 changes: 4 additions & 4 deletions react-native-ios-context-menu.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ Pod::Spec.new do |s|
'"${PODS_CONFIGURATION_BUILD_DIR}/react-native-ios-utilities/**"',
'"${PODS_CONFIGURATION_BUILD_DIR}/react-native-ios-utilities/Swift Compatibility Header"',
'"${PODS_CONFIGURATION_BUILD_DIR}/react-native-ios-context-menu/Swift Compatibility Header"',

#'"$(PODS_ROOT)/Headers/Private/react-native-ios-utilities"',
#'"$(PODS_ROOT)/Headers/Public/react-native-ios-utilities"',

'"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging"',
'"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers"',
'"$(PODS_ROOT)/Headers/Private/Yoga"',
]

if fabric_enabled && ENV['USE_FRAMEWORKS']
user_header_search_paths << "\"$(PODS_ROOT)/DoubleConversion\""
user_header_search_paths << "\"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers\""
Expand All @@ -91,7 +91,7 @@ Pod::Spec.new do |s|
"HEADER_SEARCH_PATHS" => user_header_search_paths,
}

# s.xcconfig = {
# s.xcconfig = {
# 'HEADER_SEARCH_PATHS' => [
# '"${PODS_CONFIGURATION_BUILD_DIR}/react-native-ios-utilities/Swift Compatibility Header"',
# '"${PODS_CONFIGURATION_BUILD_DIR}/react-native-ios-utilities/**"',
Expand Down Expand Up @@ -138,5 +138,5 @@ Pod::Spec.new do |s|

s.exclude_files = exclude_files
s.compiler_flags = compiler_flags
s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h', 'ios/**/RNIHeaderUtils.h']
end

0 comments on commit 3161150

Please sign in to comment.