简体   繁体   English

在iOS上的应用之间共享数据

[英]Sharing data between apps on iOS

I have several small apps that share common data (images, sounds files, etc). 我有几个小应用程序共享公共数据(图像,声音文件等)。 This data bloats the size of each app. 这个数据膨胀了每个应用程序的大小。 When the user installs 2 or more of these apps that will bloat the device space with duplicate data. 当用户安装两个或更多这些应用程序时,这些应用程序将使重复数据膨胀设备空间。 Is there a way that I can share this data between my apps so that each app doesn't duplicate this data within its bundle? 有没有办法可以在我的应用程序之间共享这些数据,以便每个应用程序不会在其捆绑包中复制此数据?

You can have a common file space between apps by using app groups. 您可以使用应用组在应用之间建立公共文件空间。 An example of how to use them can be found here: Sharing data in between apps in IOS 可以在此处找到如何使用它们的示例: 在IOS中的应用程序之间共享数据

You can use this as part of a solve for not duplicating the data in every bundle. 您可以将此作为解决方案的一部分,以便不复制每个包中的数据。 One way might be to have the data hosted on a server somewhere and when the app is installed you can check the App Group for the common data, if it is not there, you can download it and store it there. 一种方法可能是将数据托管在服务器的某个地方,当安装应用程序时,您可以检查应用程序组中的公共数据,如果不存在,您可以下载并将其存储在那里。 Then the next app that is installed will have the data already available. 然后,安装的下一个应用程序将具有已可用的数据。 This should help avoid having to include it in every small app. 这应该有助于避免将其包含在每个小应用程序中。

You can set up the code to check the shared location and download the data in a framework and share it between all your apps making it a bit easier to maintain. 您可以设置代码以检查共享位置并在框架中下载数据并在所有应用程序之间共享,从而使维护更容易。 If you do not already have a content management system then you could google for a few that have iOS support. 如果您还没有内容管理系统,那么您可以谷歌搜索一些支持iOS的内容。 There are many out there. 那里有很多。 You would then host the shared data there. 然后,您将在那里托管共享数据。 This would give you the ability to update the data for each app while they are in the field which could be a time saver. 这将使您能够在每个应用程序处于现场时更新每个应用程序的数据,从而节省时间。 If these apps are very small though, this may be overkill. 如果这些应用程序虽然非常小,但这可能有点过分。

No, this is not currently possible. 不,这目前不可行。 Ideally, this kind of resource-sharing would require creating a common framework bundle that would have to be submitted separately to the App Store as a third-party framework, so that even if only one of your apps is present on the device, it would be able to load the appropriate resources and function properly. 理想情况下,这种资源共享需要创建一个公共框架包,必须作为第三方框架单独提交到App Store,这样即使设备上只有一个应用程序,它也会能够正确加载适当的资源和功能。

Apple currently only allows third-party frameworks embedded within the app bundle. Apple目前仅允许嵌入在应用程序包中的第三方框架。 Even if two of your apps use the same exact version of your framework, they have to embed it separately. 即使您的两个应用程序使用相同的框架版本,它们也必须单独嵌入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM