Building a react native SDK to be used by IOS

我的梦境 提交于 2020-12-15 06:27:17

问题


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.

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.

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

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

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.


回答1:


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.

Now the SDK user will have to do the following:

On the terminal

$ pod repo add REPO_NAME SOURCE_URL

Inside the Podfile

source SOURCE_URL

pod YourSdkName

Edit: I wrote a blog about it https://asendar.medium.com/building-react-native-0-61-5-sdk-to-be-used-by-native-ios-applications-swift-481d38f549bb



来源:https://stackoverflow.com/questions/60084117/building-a-react-native-sdk-to-be-used-by-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!