构建一个可被IOS使用的React Native SDK [英] Building a react native SDK to be used by IOS

查看:112
本文介绍了构建一个可被IOS使用的React Native SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用react native构建SDK,以供本机android和IOS应用程序使用.我试图使SDK易于设置,因此SDK用户不必使用yarn或npm.根据一些博客,android似乎可行.但是,使用IOS时,我在添加react native依赖项时遇到了一些麻烦.

I am building an SDK using react native to be used by native android and IOS apps. I was trying to make the SDK easy to be set up, so the SDK user does not have to use yarn or npm. Based on some blogs, android seems to be doable. However, with IOS i am having some troubles adding the react native dependencies.

反应本机文档建议添加使用已下载的节点模块的Pod.有什么方法可以让SDK用户仅将SDK容器添加到他/她的应用中,而无需添加任何反应本机容器?我是cocoapods的新手,据我了解,IOS仅在cocoapods repo上搜索豆荚.

React native docs suggests adding pods using downloaded node modules. Is there any way for the SDK user to only add the SDK pod to his/her app without adding any react native pods? I am new to cocoapods and as far as i understand IOS searches for pods on the cocoapods repo only.

我尝试将所有react native依赖项上载到公共存储库,SDK用户可以将所有Pod添加到他/她的Podfile中.如果有人要使用SDK,则Podfile如下所示:

I tried uploading all the react native dependencies to a public repository so the SDK user can add all the pods to his/her Podfile. If someone wants to use the SDK the Podfile would look like this:

  pod 'MySdk', :path => '../my-sdk'

  repository = 'git@github.com:AbdullahAsendar/react-native-ios-pod.git'
  tag = '0.61.5'

  pod 'FBLazyVector', :git => repository, :tag => tag
  pod 'FBReactNativeSpec', :git => repository, :tag => tag
  pod 'RCTRequired', :git => repository, :tag => tag
  pod 'RCTTypeSafety', :git => repository, :tag => tag
  pod 'React', :git => repository, :tag => tag
  .... THE REST OF THE PODS

这可能是可以接受的,但不必添加所有这些pod会更好,

This may be acceptable but not having to add all these pods would be better,

我还能为每个依赖项创建一个pod并将这些pod上载到 CocoaPods 吗?这样,我将在我的SDK中引用这些Pod,而SDK用户只需添加SDK Pod.

Also, can i create a pod for each one of the dependencies and upload these pods to CocoaPods? This way i would reference these pods in my SDK and the SDK user will only have to add the SDK pod.

推荐答案

如果有人感兴趣,我最终创建了私有Podspec存储库,其中包含我需要用于SDK的所有Podspec.所有podspec都指向其原始存储库.看起来像是.

Incase anyone is interested, i ended up creating a private Podspec repo, which contains all the podspecs that i need for the SDK. All the podspecs are pointing to their original repositories. It looks like this.

现在,SDK用户将必须执行以下操作:

Now the SDK user will have to do the following:

在终端上

$ pod repo add REPO_NAME SOURCE_URL

在Podfile中

source SOURCE_URL

pod YourSdkName

我写了一个博客 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆