Files
Kudo ChienandFacebook GitHub Bot bdfa368060 Fix build errors when importing React-Core module from Swift (#38993)
Summary:
supersedes https://github.com/facebook/react-native/issues/38806
the errors are actually coming from https://github.com/facebook/react-native/commit/42d67452eb9a#diff-226ff5f87f146abfebd14a69eeb7d95c358d53da30533321e3ae9281c8acc6f0L102. we should keep c++ headers as cocoapods private headers, so that those headers will not expose into the umbrella header.

this pr also adds a swift test file to rn-tester, so we can verify the fix and prevent the similar build errors in the future.

## Changelog:

[IOS] [FIXED] - Fix build errors when importing React-Core module from Swift

Pull Request resolved: https://github.com/facebook/react-native/pull/38993

Test Plan: add a swift file in rn-tester and make sure it builds successfully

Reviewed By: cipolleschi

Differential Revision: D48414292

Pulled By: NickGerleman

fbshipit-source-id: d65273adc4bfab927d7c3db1db6bb48d3e48349e
2023-08-18 17:31:01 -07:00

24 lines
739 B
Swift

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// The SwiftTest here in rn-tester acts as a guard to make sure that we can build React-Core clang module and import from Swift.
import React
func getReactNativeVersion() -> String {
let version = RCTGetReactNativeVersion()
guard let major = version?[RCTVersionMajor],
let minor = version?[RCTVersionMinor],
let patch = version?[RCTVersionPatch] else {
fatalError()
}
var result = "\(major).\(minor).\(patch)"
if let prerelease = version?[RCTVersionPrerelease] {
result += "-\(prerelease)"
}
return result
}