英文:
Cross-platform development: How to mitigate the issue of depending on 3rd party plugins for native functionality?
问题
我正在启动一个新项目,它将是一个跨平台的移动应用程序。
我正在考虑使用ReactNative、NativeScript或带有Capacitor的Ionic 4。
关于所有这些技术,我注意到一个共同点,那就是需要插件来实现自定义行为或访问原生功能。
虽然有各种开源插件可用,但这可能存在风险。例如,假设您的应用程序依赖于一个iBeacon插件。
- 如果没有iBeacon插件怎么办?
- 如果有一个插件,但它不能满足您的需求怎么办?
- 如果有一个插件,但开发者放弃了插件或不再修复问题等等,怎么办?
难道您唯一的选择就是学习如何构建插件吗?
我们是一家小公司,没有太多时间用于插件开发,因为我们忙于主要产品。
英文:
I'm starting a new project and it will be a cross-platform mobile app.
I'm considering using either ReactNative, NativeScript or Ionic 4 w/ Capacitor.
One thing I have noticed about all of these technologies is that custom behaviour or access to native functionality requires plugins.
While there are a variety of open-source plugins out there, this can be a risk. For example, let's say that your application relies on an iBeacon plugin.
- What if there is no iBeacon plugin
- What if there is a plugin but it doesn't do what you need it to do
- What if there is a plugin but the developer abandons the plugin or is not working to fix issues etc.
Is your only option to learn how to build plugins?
We are a small company and don't have a lot of time for plugins as we are busy with the main product.
答案1
得分: 1
React-Native已经存在了一段时间,拥有强大的社区支持。现在,你的情况完全取决于设计。
-
如果你正在设计产品,最好在设计时查看React-Native插件,这样你可以在开发中精确地实现你的设计。
-
如果你已经有了设计,而且你可以根据React-Native提供的外部/内部插件来修改一些设计,那么遵循React-Native是明智的选择,因为它拥有大多数组件。
-
如果你已经有了设计,并且要求严格按照设计进行开发,那么如果React-Native中甚至没有一个组件的替代方案,那将是一个大问题。在这种情况下,你可以选择使用原生编码等方式。
所以一切都取决于设计和功能。
因此,希望我已经回答了你的问题,如果有任何疑问,请随时提出。
英文:
React-Native has been there for quite a while and has a strong community support. Now your case it entirely depends on design.
- If you are designing the product then it would be better to take a
look at react-native plugins while designing so that you can achieve
in development exactly what you designed.
2.If you are given the designs and its like that you can modify some of the designs according to external/internal plugins provided by react-native. It would be wise to follow react-native as it has most of the components.
- IF you are given the designs and you are asked to strictly follow the design, then it would be great problem if suppose even 1 component alternative is not present in react-native. So here you can opt for native coding and all.
So it all depends on design and functionalities.
So hence hope i did answer your question, would love any doubts,
答案2
得分: 1
我在过去几个月里一直在开发一个Ionic应用,并遇到了你提到的问题。简而言之,如果没有插件或插件有问题,你就会遇到麻烦,这意味着你必须自己构建(或修复)插件。
Ionic的好处在于它是建立在Cordova之上的,Cordova属于Apache。他们拥有相当数量的插件,这些插件在Ionic中运行完美,而且得到了良好的维护。它们覆盖了主要功能。
Ionic本身有一个社区插件列表,附有快速说明,你可以在这里找到。大多数都运行良好,但有些存在问题。
他们还有高级访问(称为Premier),可以让你访问官方插件和支持,但这是非常昂贵的。
好消息是:一旦你知道如何做,构建自己的插件并不难(如果你懂JavaScript和本机代码)。不过,很难找到教程,特别是考虑到Ionic的不同版本之间差异很大。这个教程是一个很好的起点(请查看底部的参考文献)。
不仅谈论本机代码,还谈论Ionic中的插件:有时我也使用Angular插件,大多数情况下都很成功。关于JS库,有些可以直接使用(如HammerJS),而有些我无法使其正常工作(如jQuery)。
英文:
I have been developing an Ionic App for the last months and have faced the problems you mention. In few words, if there is no plugin or the plugin has problems, you're screwed, meaning that, that you have to build (or fix) the plugin yourself.
The good thing with Ionic is that it is built on top of Cordova, wich belongs to Apache. They have quite a good collection of plugins that work perfectly in Ionic and are good maintained. They cover the main functionality.
Ionic self has a list of community plugins with quick instructions, you can find it here. Most of them work fine, some are buggy.
They also have a premium access (called Premier), which gives you access to official plugins and support, but this is extremely expensive.
Good news is: once you know how to do it, it is not difficult to build your own plugin (if you know JavaScript and the native code). It is not easy to find tutorials, though, specially knowing that Ionic versions differ a lot among them. This tutorial is a good starting point (check the bibliography at the bottom).
Not talking about native, but also about plugins in Ionic: sometimes I have also use Angular plugins, mostly successfully. About JS libraries, some work out of the box (like HammerJS), other I just could not make them work (like jQuery).
答案3
得分: 1
Ionic仅在WebView内运行,不提供原生用户体验,个人不建议使用。
ReactNative提供原生用户体验,但如果要定制插件,您需要了解Java/Objective C或Swift。即使了解这些语言,随着时间的推移,定制可能会变得困难。他们拥有大量的社区插件,但不能保证持续支持。
另一方面,NativeScript允许您完全访问设备API,只需使用JavaScript,无需了解原生编程语言,但仍需要一些关于将原生代码转化为JS/TS的基本知识,他们在此方面有很好的文档。
在我看来,如果您完全依赖社区插件,应选择ReactNative。如果您是一个好学者(或您的团队是),可以花一些时间构建插件,那么您会喜欢NativeScript。对插件的定制将更容易管理,因为它主要是JavaScript,您可以始终覆盖原型链,而不必触及原始插件代码。
英文:
You are comparing entirely different frameworks here.
Ionic is just going to run inside WebView, it doesn't give native UX. So I wouldn't recommend it personally.
ReactNative gives you native UX but in oder to customize a plugin, you should know Java / Objective C or Swift. Even then it may be difficult to manage customisations over time. They do have a large number of community plugins, but again continuous support is something one can not guarantee.
On the other hand NativeScript gives you 100% access to device APIs using just JavaScript, you don't have to know native programming languages but still you would need some basic knowledge about marshalling the native code into JS / TS, they have a very good documentation on that.
In my opinion, you should choose ReactNative if you are completely relying on community plugins. If you are a good leaner (or your team), you may spend some time on building plugins, then you would love NativeScript. Customisations on plugins will be lot easier to manage, as it's mostly JavaScript you can always override the prototype chain and will not have to touch the original plugin code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论