Skip to content

Commit

Permalink
refactor: clean up imports with macro
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsoftwaretyler committed Dec 15, 2024
1 parent 571e7fd commit 8dbac1d
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 48 deletions.
4 changes: 2 additions & 2 deletions ios/RNIContextMenuButton/RNIContextMenuButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Dominic Go on 8/24/24.
//

#import "RNIHeaderUtils.h"
#import "../RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseView.h)
#import RNI_INCLUDE_HEADER(RNIBaseView.h)

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

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

RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
RNI_INCLUDE_HEADER(RNIObjcUtils.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
#include "RNIContextMenuButtonComponentDescriptor.h"
RNI_INCLUDE_HEADER(RNIBaseViewState.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
#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,9 +10,9 @@

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

RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)

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

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

#include "RNIHeaderUtils.h"
#include "../RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewShadowNode.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
RNI_INCLUDE_HEADER(RNIBaseViewEventEmitter.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 Down
4 changes: 2 additions & 2 deletions ios/RNIContextMenuButton/RNIContextMenuButtonViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#import "RNIContextMenuButton.h"
#import <objc/runtime.h>

#import "RNIHeaderUtils.h"
#import "../RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)

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

#import "RNIHeaderUtils.h"
#import "../RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseView.h)
#import RNI_INCLUDE_HEADER(RNIBaseView.h)

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
Expand Down
22 changes: 9 additions & 13 deletions ios/RNIContextMenuView/RNIContextMenuView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@

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

RNI_INCLUDE_HEADER(RNIBaseView.h)
RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
RNI_INCLUDE_HEADER(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
RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#else
RNI_INCLUDE_HEADER(RNIBaseView.h)
RNI_INCLUDE_HEADER(RNIContentViewParentDelegate.h)
RNI_INCLUDE_HEADER(UIApplication+RNIHelpers.h)
RNI_INCLUDE_HEADER(RNIObjcUtils.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#endif

#if RCT_NEW_ARCH_ENABLED
#include "RNIContextMenuViewComponentDescriptor.h"

RNI_INCLUDE_HEADER(RNIBaseViewState.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewState.h)
#import RNI_INCLUDE_HEADER(RNIBaseViewProps.h)

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
Expand Down
5 changes: 3 additions & 2 deletions ios/RNIContextMenuView/RNIContextMenuViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

#import "RNIContextMenuView.h"
#import <objc/runtime.h>
#import "RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)
#import "../RNIHeaderUtils.h"

#import RNI_INCLUDE_HEADER(RNIBaseViewUtils.h)

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

#include "RNIHeaderUtils.h"
#include "../RNIHeaderUtils.h"

RNI_INCLUDE_HEADER(RNIBaseViewShadowNode.h)
RNI_INCLUDE_HEADER(RNIBaseViewProps.h)
RNI_INCLUDE_HEADER(RNIBaseViewEventEmitter.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 Down
9 changes: 4 additions & 5 deletions ios/RNIHeaderUtils.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#define RNI_INCLUDE_HEADER(header) \
#if __has_include(<react_native_ios_utilities/header>) \
#include <react_native_ios_utilities/header> \
#else \
#include <react-native-ios-utilities/header> \
#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
11 changes: 9 additions & 2 deletions ios/Swift.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
//
// Created by Dominic Go on 8/24/24.
//
#import "RNIHeaderUtils.h"
#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>

#elif __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>

#else
#import "react_native_ios_context_menu-Swift.h"
#endif

RNI_INCLUDE_HEADER(react_native_ios_context_menu-Swift.h)

// #import <react-native-ios-utilities/react-native-ios-utilities-Swift.h>
// #import "<react_native_ios_utilities/react_native_ios_utilities-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 8dbac1d

Please sign in to comment.