[英]Using React Native iOS dependency in Objective-c
I currently have the following dependency in a ReactNative project's package.json
:我目前在 ReactNative 项目的package.json
中有以下依赖项:
"vital-health-react-native": "file:../packages/vital-health-react-native"
This package has a .podspec
with the following dependency:这个包有一个.podspec
具有以下依赖性:
s.dependency "VitalHealthKit", "~> 0.7.7"
Because I am dealing with HealthKit and background delivery, I need to be able to call a method from this dependency inside the AppDelegate.mm
.因为我正在处理 HealthKit 和后台交付,所以我需要能够从AppDelegate.mm
中的这个依赖项调用一个方法。
I have tried everything to import VitalHealthKit
in the .mm
and even in the .h
, but the dependency is never found.我已经尝试了在.mm
甚至.h
中导入VitalHealthKit
的所有方法,但从未找到依赖项。 The spec for VitalHealthKit
can be found here .可以在此处找到VitalHealthKit
的规范。
What am I missing?我错过了什么?
I've not done sub-dependency imports myself but I think one would need to add the pod to the app project's Podfile like so我自己没有完成子依赖项导入,但我认为需要像这样将 pod 添加到应用程序项目的 Podfile
pod 'VitalHealthKitRN', path: "#{path_to_packages} /packages/vital-health-react-native/VitalHealthRN.podspec"
Having done that, if one still can't import VitalHealthKit in the app, it might be necessary to reference VitalHealthKit native pod in the Podfile directly, either in a usual way (that might create a conflict of dependency versions with the RN pod) or using a local relative path, similar to the above.这样做之后,如果仍然无法在应用程序中导入 VitalHealthKit,则可能有必要直接在 Podfile 中引用 VitalHealthKit 本机 pod,以通常的方式(这可能会与 RN pod 产生依赖版本冲突)或使用与上述类似的本地相对路径。 Might also have to use_frameworks!
可能还必须使用use_frameworks!
if you don't already to avoid double-linking vital health kit.如果您还没有避免双重链接重要的健康工具包。 Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.