Repository navigation
Expand file tree
/
Copy pathPoseTrackerVision.podspec
More file actions
86 lines (72 loc) · 3.47 KB
/
Copy pathPoseTrackerVision.podspec
File metadata and controls
86 lines (72 loc) · 3.47 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
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
# One pod for the package's two native parts (autolinking links a single podspec per package;
# the pod keeps its historical name). Same rules as react-native.config.js:
#
# - Apple Vision frame-processor plugin (ios/PoseTrackerVision): only when the host app installed
# react-native-vision-camera, since it compiles against the VisionCamera pod.
# - PoseTrackerNet native backend (ios/PoseTrackerNetNative: the React Native wrapper and, under
# generated/, the PoseTrackerNet iOS core vendored by scripts/sync-posetrackernet-native.mjs):
# by default. Left out when the host opted out (POSETRACKER_NATIVE_POSETRACKERNET=0, or
# { "posetracker": { "nativePoseTrackerNet": false } } in the app's package.json). Without it
# `model: 'posetrackernet'` runs in the WebView. It raises the pod's minimum iOS version to
# 15.1: an app with a lower deployment target must opt out (or raise its target).
host_dirs = [Dir.pwd]
begin
host_dirs << Pod::Config.instance.installation_root.to_s
rescue StandardError
# Not inside `pod install`.
end
host_dirs = (host_dirs + host_dirs.map { |dir| File.dirname(dir) }).uniq
with_vision = host_dirs.any? do |dir|
File.exist?(File.join(dir, 'node_modules', 'react-native-vision-camera', 'package.json'))
end
# The vendored core compiles from iOS 15.1 (the minimum of React Native 0.76 and later).
posetrackernet_ios = '15.1'
with_posetrackernet = true
env = (ENV['POSETRACKER_NATIVE_POSETRACKERNET'] || '').strip.downcase
if %w[0 false no off].include?(env)
with_posetrackernet = false
elsif !%w[1 true yes on].include?(env)
host_dirs.each do |dir|
manifest = File.join(dir, 'package.json')
next unless File.exist?(manifest)
host = JSON.parse(File.read(manifest)) rescue nil
with_posetrackernet = false if host.is_a?(Hash) && host['posetracker'].is_a?(Hash) && host['posetracker']['nativePoseTrackerNet'] == false
end
end
Pod::Spec.new do |s|
s.name = 'PoseTrackerVision'
s.version = package['version']
s.summary = 'Native code of the PoseTracker React Native SDK: PoseTrackerNet native backend and Apple Vision body-pose frame processor'
s.homepage = 'https://posetracker.com'
s.license = package['license']
s.authors = package['author']
s.platforms = { :ios => with_posetrackernet ? posetrackernet_ios : '14.0' }
s.source = { :git => 'https://github.com/movelytics/posetracker-rn-sdk.git', :tag => "v#{s.version}" }
sources = []
frameworks = []
s.requires_arc = true
s.swift_version = '5.0'
s.dependency 'React-Core'
if with_vision
sources << 'ios/PoseTrackerVision/**/*.{h,m,mm,swift}'
frameworks += %w[Vision CoreMedia CoreVideo]
s.dependency 'VisionCamera'
end
if with_posetrackernet
core = JSON.parse(File.read(File.join(__dir__, 'ios/PoseTrackerNetNative/generated/posetrackernet/core.json')))
sources << 'ios/PoseTrackerNetNative/**/*.{h,m,mm,swift}'
frameworks += %w[AVFoundation CryptoKit UIKit SwiftUI]
# The interpreter of the core (CPU, XNNPACK), at the version the core pins.
s.dependency 'TensorFlowLiteSwift', core['tensorFlowLiteSwift']
# TensorFlow Lite is a static binary: with `use_frameworks!` this pod must stay static too.
s.static_framework = true
end
s.source_files = sources
s.frameworks = frameworks.uniq unless frameworks.empty?
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'SWIFT_COMPILATION_MODE' => 'wholemodule',
}
end