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 authored and dominicstop committed Dec 15, 2024
1 parent 9ee22ff commit 5adcc15
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 90 deletions.
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 5adcc15

Please sign in to comment.