Skip to content

Commit 0c6ced7

Browse files
committed
refactor(ios): grouped the project-owned ios engine adapters
1 parent 33d4e18 commit 0c6ced7

22 files changed

Lines changed: 56 additions & 42 deletions

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
the build-time `ZFH_ENGINE` setting.
2323
- Updated `@react-native-documents/picker` to v12.0.2 in example and patched its SwiftPM
2424
manifest.
25-
- Moved the iOS Swift, C/C++, and React Native sources into separate directories.
25+
- Grouped the project-owned iOS engine adapters under `ios/Engines/Native` and
26+
`ios/Engines/Zig`. The upstream implementations remain under `third_party`.
2627
- Removed the old iOS bridge registration. `FileHash` is now registered through
2728
its generated TurboModule spec.
2829
- Android now relies solely on the generated `NativeFileHashSpec` methods.

FileHash.podspec

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ zig_source_files = [
3030
"ios/ReactNative/FileHashBridgeHelpers.h",
3131
"ios/ReactNative/FileHashPromiseTypes.h",
3232
"ios/ReactNative/FileHashBridgeHelpers.mm",
33-
"ios/FileHashBridgeZig.h",
34-
"ios/FileHashBridgeZig.mm",
35-
"ios/FileHashZigHelpers.h",
36-
"ios/FileHashZigHelpers.mm"
33+
"ios/Engines/Zig/FileHashBridgeZig.h",
34+
"ios/Engines/Zig/FileHashBridgeZig.mm",
35+
"ios/Engines/Zig/FileHashZigHelpers.h",
36+
"ios/Engines/Zig/FileHashZigHelpers.mm"
3737
]
3838

3939
zig_private_header_files = [
4040
"ios/ReactNative/FileHash.h",
4141
"ios/ReactNative/FileHashBridgeHelpers.h",
4242
"ios/ReactNative/FileHashPromiseTypes.h",
43-
"ios/FileHashBridgeZig.h",
44-
"ios/FileHashZigHelpers.h"
43+
"ios/Engines/Zig/FileHashBridgeZig.h",
44+
"ios/Engines/Zig/FileHashZigHelpers.h"
4545
]
4646

4747
native_source_files = [
4848
"ios/ReactNative/FileHash.h",
4949
"ios/ReactNative/FileHash.mm",
50-
"ios/NativeSwift/FileHash.swift",
51-
"ios/NativeCore/HashNative.h",
52-
"ios/NativeCore/HashNative.mm",
50+
"ios/Engines/Native/Swift/FileHash.swift",
51+
"ios/Engines/Native/Core/HashNative.h",
52+
"ios/Engines/Native/Core/HashNative.mm",
5353
"ios/ReactNative/FileHashBridgeHelpers.h",
5454
"ios/ReactNative/FileHashPromiseTypes.h",
5555
"ios/ReactNative/FileHashBridgeHelpers.mm",
@@ -76,8 +76,8 @@ Pod::Spec.new do |s|
7676
s.source = { :git => "https://github.com/Preeternal/react-native-file-hash.git", :tag => "#{s.version}" }
7777

7878
s.swift_version = "5.9"
79-
native_header_search_paths = "$(inherited) $(PODS_TARGET_SRCROOT)/ios/NativeCore $(PODS_TARGET_SRCROOT)/third_party/xxhash $(PODS_TARGET_SRCROOT)/third_party/blake3/c"
80-
zig_header_search_paths = "$(inherited) $(PODS_TARGET_SRCROOT)/third_party/zig-files-hash/src"
79+
native_header_search_paths = "$(inherited) $(PODS_TARGET_SRCROOT)/ios/Engines/Native/Core $(PODS_TARGET_SRCROOT)/third_party/xxhash $(PODS_TARGET_SRCROOT)/third_party/blake3/c"
80+
zig_header_search_paths = "$(inherited) $(PODS_TARGET_SRCROOT)/ios $(PODS_TARGET_SRCROOT)/ios/Engines/Zig $(PODS_TARGET_SRCROOT)/third_party/zig-files-hash/src"
8181

8282
ios_header_search_paths = if is_zig
8383
zig_header_search_paths
@@ -132,7 +132,7 @@ Pod::Spec.new do |s|
132132
# FileHash.h imports the C++ codegen spec and must not be pulled into the
133133
# Swift module. FileHash.swift only needs this C API from HashNative.h.
134134
s.ios.public_header_files = [
135-
"ios/NativeCore/HashNative.h"
135+
"ios/Engines/Native/Core/HashNative.h"
136136
]
137137
s.ios.private_header_files = [
138138
"ios/ReactNative/FileHash.h",

Package.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ let package = Package(
1717
],
1818
dependencies: [
1919
// These paths are supplied by React Native's SPM autolinker under
20-
// ios/build/generated/autolinking/libs/ReactNativeFileHash.
20+
// ios/build/generated/autolinking/plugins/ReactNativeFileHash.
2121
.package(name: "ReactNative", path: "../../../../xcframeworks"),
2222
.package(name: "React-GeneratedCode", path: "../../../ios"),
2323
],
2424
targets: [
2525
.target(
2626
name: "FileHashNativeCore",
27-
path: "ios/NativeCore",
27+
path: "ios/Engines/Native/Core",
2828
publicHeadersPath: ".",
2929
cSettings: [
30-
.headerSearchPath("../../third_party/xxhash"),
31-
.headerSearchPath("../../third_party/blake3/c"),
30+
.headerSearchPath("../../../../third_party/xxhash"),
31+
.headerSearchPath("../../../../third_party/blake3/c"),
3232
.define("BLAKE3_NO_SSE2", to: "1"),
3333
.define("BLAKE3_NO_SSE41", to: "1"),
3434
.define("BLAKE3_NO_AVX2", to: "1"),
3535
.define("BLAKE3_NO_AVX512", to: "1"),
3636
],
3737
cxxSettings: [
38-
.headerSearchPath("../../third_party/xxhash"),
39-
.headerSearchPath("../../third_party/blake3/c"),
38+
.headerSearchPath("../../../../third_party/xxhash"),
39+
.headerSearchPath("../../../../third_party/blake3/c"),
4040
.define("BLAKE3_NO_SSE2", to: "1"),
4141
.define("BLAKE3_NO_SSE41", to: "1"),
4242
.define("BLAKE3_NO_AVX2", to: "1"),
@@ -46,7 +46,7 @@ let package = Package(
4646
.target(
4747
name: "FileHashNative",
4848
dependencies: ["FileHashNativeCore"] + reactHeaders,
49-
path: "ios/NativeSwift",
49+
path: "ios/Engines/Native/Swift",
5050
linkerSettings: [
5151
.linkedFramework("CryptoKit"),
5252
.linkedFramework("Foundation"),

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ EXTERNAL SOURCES:
20982098

20992099
SPEC CHECKSUMS:
21002100
FBLazyVector: c00c20551d40126351a6783c47ce75f5b374851b
2101-
FileHash: e7bdffc3e08a18048480bf9011437cfbe83edc7f
2101+
FileHash: a8d3b7f77663840fc08a988c3d42742cbf52ea92
21022102
hermes-engine: 0ea749613fa10e2b07a40044df86ae2c78ed7e30
21032103
RCTDeprecation: 3bb167081b134461cfeb875ff7ae1945f8635257
21042104
RCTRequired: 74839f55d5058a133a0bc4569b0afec750957f64

examples/macos/macos/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,7 @@ SPEC CHECKSUMS:
24892489
DoubleConversion: d31b1eb37f6d6f456530c4fd9124b857d6889cab
24902490
fast_float: 20817c22759af6ac8d4d67e6e059b8b499953656
24912491
FBLazyVector: 3cde5aa3abeda29fd70560e5a3e3199e6add163f
2492-
FileHash: 88ed28afbe9ff67fbec77fa472261b69b7d84760
2492+
FileHash: e13abd0a118468fddde98891cef48ebc7d48dd73
24932493
fmt: 4cf0c5ec5864511c96d8d4bd7b03c3c69040af06
24942494
glog: 0b31c25149b9d350b2666c7d459229861a00ec07
24952495
hermes-engine: 7219f6e751ad6ec7f3d7ec121830ee34dae40749

ios/Engines/Native/Core/Blake3.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SwiftPM source shim; the upstream implementation lives in third_party.
2+
#include "../../../../third_party/blake3/c/blake3.c"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SwiftPM source shim; the upstream implementation lives in third_party.
2+
#include "../../../../third_party/blake3/c/blake3_dispatch.c"
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// SwiftPM source shim; the upstream implementation lives in third_party.
12
// BLAKE3's NEON implementation includes <arm_neon.h>, which is unavailable
23
// when an iOS Simulator build also targets x86_64. The dispatcher enables this
34
// object only on AArch64, where BLAKE3_USE_NEON is auto-detected as 1.
45
#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
5-
#include "../../third_party/blake3/c/blake3_neon.c"
6+
#include "../../../../third_party/blake3/c/blake3_neon.c"
67
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// SwiftPM source shim; the upstream implementation lives in third_party.
2+
#include "../../../../third_party/blake3/c/blake3_portable.c"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Swift-facing adapter for the native BLAKE3 and xxHash implementations.
12
#ifndef HASH_NATIVE_H
23
#define HASH_NATIVE_H
34

0 commit comments

Comments
 (0)