-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-native-doc-scanner.podspec
More file actions
115 lines (105 loc) · 5.72 KB
/
Copy pathreact-native-doc-scanner.podspec
File metadata and controls
115 lines (105 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
react_native_pods_script = File.join(
File.dirname(`node --print "require.resolve('react-native/package.json')"`),
"scripts/react_native_pods.rb",
)
require react_native_pods_script
Pod::Spec.new do |s|
s.name = "react-native-doc-scanner"
# CocoaPods derives a Swift module name from `s.name` by underscoring
# hyphens ("react_native_doc_scanner"), but nitro.json's `iosModuleName`
# is "DocScanner" and nitrogen's generated C++ (DocScanner-Swift-Cxx-
# Umbrella.hpp, HybridDocScannerSpecSwift.hpp) hardcodes that exact name
# when looking for the auto-generated Swift-Cxx interop header. Other
# Nitro modules in this workspace (NitroImage, VisionCamera) avoid this by
# naming their *podspec* to already match their Nitro module name; this
# package keeps the conventional hyphenated npm package name instead and
# overrides just the compiled Swift module name to match nitro.json.
s.module_name = "DocScanner"
s.version = package["version"]
s.summary = package["description"]
s.homepage = "https://github.com/your-org/react-native-doc-scanner"
s.license = package["license"]
s.authors = { "Your Org" => "engineering@your-org.com" }
s.platforms = { :ios => "15.0" }
s.source = { :git => "https://github.com/your-org/react-native-doc-scanner.git", :tag => "#{s.version}" }
s.source_files = [
# Implementation (Swift) — HybridDocScanner.swift, ONNXInference.swift,
# ModelPathResolver.swift.
"ios/**/*.{swift}",
# OpenCVBridge's Objective-C header (OpenCVBridge.h) + its Objective-C++
# implementation (OpenCVBridge.mm), plus any autolinking/registration
# glue generated by nitrogen.
"ios/**/*.{h,m,mm}",
# Shared C++ (ONNX/OpenCV glue shared with Android via JNI where applicable).
"cpp/**/*.{hpp,cpp}",
]
# Host-only conformance checks (roadmap M2). `ios/Tests/` holds plain Swift
# that is compiled and run by `scripts/verify-ios-conformance.sh` on a
# developer machine or CI, never shipped in the pod — it exists to prove the
# Swift port of the shared frame-path arithmetic agrees with the TypeScript
# oracle, which no consumer needs at runtime.
s.exclude_files = ["ios/Tests/**/*"]
s.resources = ["assets/models/*"]
# Without this, CocoaPods classifies OpenCVBridge.h as a PRIVATE header —
# excluded from the auto-generated umbrella header that HybridDocScanner.swift
# / ONNXInference.swift rely on (via -import-underlying-module) to see
# OpenCVBridge/DSQuad/DSTextBox at all. Confirmed by inspecting
# Pods/Headers/Private/react-native-doc-scanner/OpenCVBridge.h after a plain
# `pod install` — it silently lands there unless declared public explicitly.
s.public_header_files = "ios/**/*.h"
s.pod_target_xcconfig = {
"DEFINES_MODULE" => "YES",
"SWIFT_VERSION" => "5.0",
# ONNX Runtime and OpenCV ship non-modular C/C++ headers; both react-native
# and RN's own Podfile post_install already need this flag for similar
# third-party pods, so it's consistent with the rest of the app's build.
"CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES" => "YES",
}
# Generated by `pnpm --filter react-native-doc-scanner run specs` (tsc && nitrogen) —
# must be run at least once before this resolves. Wires up NitroModules,
# React-jsi/callinvoker, and the generated C++ registration files.
load "nitrogen/generated/ios/DocScanner+autolinking.rb"
add_nitrogen_files(s)
# Official Microsoft ONNX Runtime iOS build (Objective-C API) — NOT the
# `onnxruntime-react-native` npm package, which we deliberately bypass (see
# docs/TROUBLESHOOTING.md — its New Architecture support is unverified and
# per-frame inference must run natively anyway, not over the JS bridge).
s.dependency "onnxruntime-objc", "~> 1.19"
# OpenCV, two-tier (the R1 retirement):
#
# Preferred: the source-built 4.12.0 xcframework produced by
# scripts/build-opencv-xcframework.sh into core/third_party/ — the ONLY
# OpenCV binary for iOS with a genuine simulator slice. Every published
# binary (the "OpenCV2" 4.3.0 trunk pod AND OpenCV's own
# -ios-framework.zip releases through 4.12) tags every slice
# LC_VERSION_MIN_IPHONEOS, including the x86_64 ones, so the simulator
# cannot link them. The built artifact is 181 MB and gitignored, hence
# detected rather than assumed.
#
# Fallback: the trunk "OpenCV2" pod (note: the pod named "OpenCV" only
# ever published 2.4.x and lacks the 4.x C++ API OpenCVBridge.mm uses) —
# DEVICE-ONLY, kept so a consumer who has not run the build script keeps
# exactly the previous behaviour. See docs/TROUBLESHOOTING.md.
opencv_xcframework = File.join(__dir__, "core", "third_party", "opencv2.xcframework")
if File.directory?(opencv_xcframework)
s.vendored_frameworks = "core/third_party/opencv2.xcframework"
else
s.dependency "OpenCV2", "~> 4.3.0"
end
# `analyzeFrame(frame: Frame)` in src/specs/DocScanner.nitro.ts references a
# HybridObject type owned by react-native-vision-camera. The generated
# nitrogen/generated/shared/c++/HybridDocScannerSpec.hpp #includes
# <VisionCamera/HybridFrameSpec.hpp>, and HybridDocScanner.swift does
# `import VisionCamera` — both require this pod's headers/module on the
# search path, which only happens if it's declared as an explicit
# dependency (see docs/TROUBLESHOOTING.md's "Nitro cross-module reference
# to Frame fails to compile" entry). Pod name per
# node_modules/react-native-vision-camera/VisionCamera.podspec — note this
# is NOT the npm package name ("react-native-vision-camera").
s.dependency "VisionCamera"
s.dependency "React-jsi"
s.dependency "React-callinvoker"
install_modules_dependencies(s)
end