Skip to content

Commit 29a3f43

Browse files
chrfalchfacebook-github-bot
authored andcommitted
fixed defines in package.swift (#51284)
Summary: Our Cocoapods config has a list of defines that are used mostly when setting up pods: - RCT_FABRIC_ENABLED - USE_HERMES - RCT_AGGREGATE_PRIVACY_FILES - RCT_NEW_ARCH_ENABLED - APP_PATH - REACT_NATIVE_PATH - RCT_SKIP_CODEGEN - SWIFT_ACTIVE_COMPILATION_CONDITIONS - USE_FRAMEWORKS - USE_THIRD_PARTY_JSC - HERMES_ENABLE_DEBUGGER - REACT_NATIVE_DEBUGGER_ENABLED - REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY Out of these, only the following are used in objective-c/c code: - USE_HERMES - HERMES_ENABLE_DEBUGGER - REACT_NATIVE_DEBUGGER_ENABLED - REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY This commit adds the required defines to the correct targets. ## Changelog: Pick one each for the category and type tags: [IOS] [FIXED] - fixed defines in package.swift Pull Request resolved: #51284 Test Plan: No test-plan yet Differential Revision: D74872272 Reviewed By: cortinico Pulled By: cortinico
1 parent a3fa7ad commit 29a3f43

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

packages/react-native/Package.swift

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ class RNTarget: BaseTarget {
3838
let dependencies: [String]
3939
let sources: [String]?
4040
let publicHeadersPath: String?
41+
let defines: [CXXSetting]
4142

42-
init(name: String, path: String, searchPaths: [String] = [], linkedFrameworks: [String] = [], excludedPaths: [String] = [], dependencies: [String] = [], sources: [String]? = nil, publicHeadersPath: String? = ".") {
43+
init(name: String, path: String, searchPaths: [String] = [], linkedFrameworks: [String] = [], excludedPaths: [String] = [], dependencies: [String] = [], sources: [String]? = nil, publicHeadersPath: String? = ".", defines: [CXXSetting] = []) {
4344
self.linkedFrameworks = linkedFrameworks
4445
self.excludedPaths = excludedPaths
4546
self.dependencies = dependencies
4647
self.sources = sources
4748
self.publicHeadersPath = publicHeadersPath
49+
self.defines = defines
4850

4951
super.init(name: name, path: path, searchPaths: searchPaths)
5052
}
@@ -65,7 +67,8 @@ class RNTarget: BaseTarget {
6567
dependencies: self.dependencies,
6668
sources: self.sources,
6769
publicHeadersPath: self.publicHeadersPath,
68-
linkerSettings: linkerSettings
70+
linkerSettings: linkerSettings,
71+
defines: self.defines
6972
)
7073
}
7174
}
@@ -165,15 +168,23 @@ let reactJsInspectorNetwork = RNTarget(
165168
name: .reactJsInspectorNetwork,
166169
path: "ReactCommon/jsinspector-modern/network",
167170
searchPaths: ["ReactCommon", RuntimeExecutorPath],
168-
dependencies: [.reactNativeDependencies]
171+
dependencies: [.reactNativeDependencies],
172+
defines: [
173+
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED", to: "1", .when(configuration: BuildConfiguration.debug)),
174+
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY", to: "1", .when(configuration: BuildConfiguration.debug)),
175+
]
169176
)
170177

171178
let reactJsInspector = RNTarget(
172179
name: .reactJsInspector,
173180
path: "ReactCommon/jsinspector-modern",
174181
searchPaths: ["ReactCommon", RuntimeExecutorPath],
175182
excludedPaths: ["tracing", "network", "tests"],
176-
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .jsi, .reactJsInspectorTracing, .reactJsInspectorNetwork]
183+
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .jsi, .reactJsInspectorTracing, .reactJsInspectorNetwork],
184+
defines: [
185+
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED", to: "1", .when(configuration: BuildConfiguration.debug)),
186+
CXXSetting.define("REACT_NATIVE_DEBUGGER_ENABLED_DEVONLY", to: "1", .when(configuration: BuildConfiguration.debug)),
187+
]
177188
)
178189

179190
let reactCxxReact = RNTarget(
@@ -203,7 +214,10 @@ let reactHermes = RNTarget(
203214
path: "ReactCommon/hermes",
204215
searchPaths: ["ReactCommon", RuntimeExecutorPath],
205216
excludedPaths: ["inspector-modern/chrome/tests"],
206-
dependencies: [.reactNativeDependencies, .reactCxxReact, .reactJsiExecutor, .reactJsInspector, .reactJsInspectorTracing, .reactPerfLogger, .hermesPrebuilt, .jsi]
217+
dependencies: [.reactNativeDependencies, .reactCxxReact, .reactJsiExecutor, .reactJsInspector, .reactJsInspectorTracing, .reactPerfLogger, .hermesPrebuilt, .jsi],
218+
defines: [
219+
CXXSetting.define("HERMES_ENABLE_DEBUGGER", to: "1", .when(configuration: BuildConfiguration.debug))
220+
]
207221
)
208222

209223
let reactPerformanceTimeline = RNTarget(
@@ -331,7 +345,7 @@ let reactRuntimeApple = RNTarget(
331345
path: "ReactCommon/react/runtime/platform/ios",
332346
searchPaths: ["ReactCommon", RuntimeExecutorPath, CallInvokerPath, ReactFBReactNativeSpecPath, FBLazyVectorPath],
333347
excludedPaths: ["ReactCommon/RCTJscInstance.mm"],
334-
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .reactCxxReact, .rctDeprecation, .yoga, .reactRuntime, .reactRCTFabric, .reactCoreModules, .reactTurboModuleCore, .hermesPrebuilt]
348+
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .reactCxxReact, .rctDeprecation, .yoga, .reactRuntime, .reactRCTFabric, .reactCoreModules, .reactTurboModuleCore, .hermesPrebuilt, .reactUtils]
335349
)
336350

337351
let reactCore = RNTarget(
@@ -454,7 +468,7 @@ let reactRCTAnimation = RNTarget(
454468
name: .reactRCTAnimation,
455469
path: "Libraries/NativeAnimation",
456470
searchPaths: ["ReactCommon", ReactFBReactNativeSpecPath, FBLazyVectorPath, CallInvokerPath],
457-
dependencies: [.rctTypesafety, .jsi, .reactFeatureFlags, .yoga, .reactTurboModuleCore]
471+
dependencies: [.reactNativeDependencies, .rctTypesafety, .jsi, .reactFeatureFlags, .yoga, .reactTurboModuleCore, .reactUtils]
458472
)
459473

460474
let reactRCTImage = RNTarget(
@@ -648,7 +662,8 @@ extension Target {
648662
dependencies: [String] = [],
649663
sources: [String]? = nil,
650664
publicHeadersPath: String? = ".",
651-
linkerSettings: [LinkerSetting] = []
665+
linkerSettings: [LinkerSetting] = [],
666+
defines: [CXXSetting] = []
652667
) -> Target {
653668
let dependencies = dependencies.map { Dependency.byNameItem(name: $0, condition: nil) }
654669
let excludes = excludedPaths
@@ -666,10 +681,9 @@ extension Target {
666681
[
667682
.unsafeFlags(["-std=c++20"]),
668683
.define("DEBUG", .when(configuration: .debug)),
684+
.define("NDEBUG", .when(configuration: .release)),
669685
.define("USE_HERMES", to: "1"),
670-
// TODO: T223727527 Why doesn't it pick up this when DEBUG is set??
671-
.define("RCT_ENABLE_INSPECTOR", to: "1", .when(configuration: .debug)),
672-
] + cxxCommonHeaderPaths
686+
] + defines + cxxCommonHeaderPaths
673687

674688
return .target(
675689
name: name,

0 commit comments

Comments
 (0)