I have an app that has some huge .m files that have a ton of drawing code. When I went to submit my app, the code files brought me well over 50 MB. I am wondering, is it somehow possible to precompile the .m file, stick it on a server somewhere, and then download it into my app when the user needs to use it?
我有一个应用程序,有一些巨大的.m文件,有大量的绘图代码。当我去提交我的应用程序时,代码文件带给我超过50 MB。我想知道,是否有可能预编译.m文件,将其粘贴在某个服务器上,然后在用户需要使用它时将其下载到我的应用程序中?
4 个解决方案
#1
3
No, you can't run downloaded code. What you can do is put a data file (Plist/XML/JSON) on the web, then interpret it to draw what it represents. But the drawing code must be on the app.
不,您无法运行下载的代码。您可以做的是在Web上放置一个数据文件(Plist / XML / JSON),然后解释它以绘制它所代表的内容。但绘图代码必须在应用程序上。
#2
2
Nope, Apple won't let you.
不,Apple不会让你。
In the App Store Submission Guidelines* (A.K.A. The Rules), Apple explicitly says that apps can't download code.
在App Store提交指南*(A.K.A。规则)中,Apple明确表示应用程序无法下载代码。
Why? Well, it has to do with app review. Since Apple wants to control what comes into the store (and rightly so), they check each and every app and update coming in.
为什么?好吧,它与应用程序审查有关。由于Apple希望控制进入商店的内容(这是正确的),因此他们会检查每个应用并进行更新。
Now imagine apps could download code like this: I, the user, download an app called Bob's Money Stealer (I never read app titles). The app passed review because it looked like an app to check up on an trade your stocks. When it went through review, it worked just like that.
现在想象应用程序可以下载这样的代码:我,用户,下载一个名为Bob的Money Stealer的应用程序(我从未阅读应用程序标题)。该应用程序通过审查,因为它看起来像一个应用程序来检查您的股票交易。当它经过审查时,就像那样工作。
But Bob's Money Stealer has a catch: After one week of use (to make sure it's not being reviewed), it goes out to a server and downloads a certain piece of code. This code pops up a little dialog asking for my username and password to my stock-trading account.
但Bob的Money Stealer有一个问题:使用一周后(为了确保它没有被审查),它会发送到服务器并下载一段代码。此代码弹出一个小对话框,询问我的用户名和密码到我的股票交易账户。
Being the unsuspecting user that I am, I immediately give them to the app. After all, I've been using it for a week and nothing has happened. The next day, all my stocks are gone.
作为我不知情的用户,我立即将它们提供给应用程序。毕竟,我已经使用了一个星期,没有发生任何事情。第二天,我的所有股票都消失了。
See? Now I'm mad at Apple for allowing such an app through. I sue them, win (bad justice system where I live), and Apple loses money.
看到?现在我因为允许这样的应用程序通过Apple而感到很生气。我起诉他们,赢了(我住的坏司法系统),而苹果亏钱。
* If someone has a link, add it! I'm on mobile right now.
*如果有人有链接,请添加它!我现在在移动设备上。
#3
1
Sounds like what you need is some kind of a rendering engine to execute your drawing. What if you use some kind of data scheme to store the drawing instructions rather than the code to draw itself?
听起来你需要的是某种渲染引擎来执行你的绘图。如果使用某种数据方案来存储绘图指令而不是代码来绘制自身怎么办?
For example, you could use a much simpler structure to the XML files exported in a COLLADA format from 3D applications like Maya or 3D Studio Max where all it contains is coordinates to draw and what to put where. The application reading the model knows what to do with those instructions.
例如,您可以使用更简单的结构来处理从Maya或3D Studio Max等3D应用程序以COLLADA格式导出的XML文件,其中包含绘制的坐标和放置的位置。阅读模型的应用程序知道如何处理这些指令。
Example:
Have a selector in your code that takes 2 CGPoints to draw a line.
在代码中有一个选择器,需要2个CGPoints来绘制一条线。
Have a JSON string returned by a server with 2 coordinates:
拥有一个由2个坐标的服务器返回的JSON字符串:
{"start":{"x":10, "y":10},"end":{"x":100, "y":10}}
Your selector could read that JSON object and draw the line between the 2 coordinates.
您的选择器可以读取该JSON对象并在2个坐标之间绘制线条。
#4
0
I feel like what you are trying to do will make too many unnecessary connections to the web, or not.
我觉得你想要做的事情会在网络上做太多不必要的连接。
Your code will be much faster and efficient if its all in your app rather that being fetched from a server that could potentially fail as some point in time.
如果您的代码全部在您的应用程序中,而不是从某个时间点可能会失败的服务器获取,那么您的代码将更快更有效。
Assume you have an image you want to use in your app all the time... Would you want to keep fetching such image from the web were you found it or just save it into your app and reference to it when you need it?
假设您有一个想要在应用程序中使用的图像......如果您找到它或者只是将其保存到您的应用程序并在需要时引用它,您是否希望继续从网络中获取此类图像?
I have had this issue and decide a few megabytes/kilobytes/bytes of data stored on a users phone is SAFER than having to keep fetching such data from a web server...
我遇到了这个问题,并确定用户手机上存储的几兆字节/千字节/字节的数据是SAFER,而不是从网络服务器获取此类数据...
This is just my opinion and my experience with app development, it's a push-pull issue that has its benefits one way, and benefits in other ways.
这只是我的观点和我在应用程序开发方面的经验,这是一个推拉式问题,它有一个好处,也有其他方面的好处。
But to finalize, keep the files stored on the app, more efficient but yes, the user will have to sacrifice a few megabytes of their mobile devices' memory.
但要最终确定,保持存储在应用程序上的文件更有效但是,用户将不得不牺牲几兆字节的移动设备内存。
If the app is good, like Facebook, who cares if the app takes up a few extra megabytes of memory, as long as it performs efficiently and the user isn't waiting forever to see changes occur. :)
如果应用程序是好的,就像Facebook一样,谁关心应用程序是否占用了几兆兆字节的内存,只要它有效执行并且用户不会永远等待看到更改发生。 :)
#1
3
No, you can't run downloaded code. What you can do is put a data file (Plist/XML/JSON) on the web, then interpret it to draw what it represents. But the drawing code must be on the app.
不,您无法运行下载的代码。您可以做的是在Web上放置一个数据文件(Plist / XML / JSON),然后解释它以绘制它所代表的内容。但绘图代码必须在应用程序上。
#2
2
Nope, Apple won't let you.
不,Apple不会让你。
In the App Store Submission Guidelines* (A.K.A. The Rules), Apple explicitly says that apps can't download code.
在App Store提交指南*(A.K.A。规则)中,Apple明确表示应用程序无法下载代码。
Why? Well, it has to do with app review. Since Apple wants to control what comes into the store (and rightly so), they check each and every app and update coming in.
为什么?好吧,它与应用程序审查有关。由于Apple希望控制进入商店的内容(这是正确的),因此他们会检查每个应用并进行更新。
Now imagine apps could download code like this: I, the user, download an app called Bob's Money Stealer (I never read app titles). The app passed review because it looked like an app to check up on an trade your stocks. When it went through review, it worked just like that.
现在想象应用程序可以下载这样的代码:我,用户,下载一个名为Bob的Money Stealer的应用程序(我从未阅读应用程序标题)。该应用程序通过审查,因为它看起来像一个应用程序来检查您的股票交易。当它经过审查时,就像那样工作。
But Bob's Money Stealer has a catch: After one week of use (to make sure it's not being reviewed), it goes out to a server and downloads a certain piece of code. This code pops up a little dialog asking for my username and password to my stock-trading account.
但Bob的Money Stealer有一个问题:使用一周后(为了确保它没有被审查),它会发送到服务器并下载一段代码。此代码弹出一个小对话框,询问我的用户名和密码到我的股票交易账户。
Being the unsuspecting user that I am, I immediately give them to the app. After all, I've been using it for a week and nothing has happened. The next day, all my stocks are gone.
作为我不知情的用户,我立即将它们提供给应用程序。毕竟,我已经使用了一个星期,没有发生任何事情。第二天,我的所有股票都消失了。
See? Now I'm mad at Apple for allowing such an app through. I sue them, win (bad justice system where I live), and Apple loses money.
看到?现在我因为允许这样的应用程序通过Apple而感到很生气。我起诉他们,赢了(我住的坏司法系统),而苹果亏钱。
* If someone has a link, add it! I'm on mobile right now.
*如果有人有链接,请添加它!我现在在移动设备上。
#3
1
Sounds like what you need is some kind of a rendering engine to execute your drawing. What if you use some kind of data scheme to store the drawing instructions rather than the code to draw itself?
听起来你需要的是某种渲染引擎来执行你的绘图。如果使用某种数据方案来存储绘图指令而不是代码来绘制自身怎么办?
For example, you could use a much simpler structure to the XML files exported in a COLLADA format from 3D applications like Maya or 3D Studio Max where all it contains is coordinates to draw and what to put where. The application reading the model knows what to do with those instructions.
例如,您可以使用更简单的结构来处理从Maya或3D Studio Max等3D应用程序以COLLADA格式导出的XML文件,其中包含绘制的坐标和放置的位置。阅读模型的应用程序知道如何处理这些指令。
Example:
Have a selector in your code that takes 2 CGPoints to draw a line.
在代码中有一个选择器,需要2个CGPoints来绘制一条线。
Have a JSON string returned by a server with 2 coordinates:
拥有一个由2个坐标的服务器返回的JSON字符串:
{"start":{"x":10, "y":10},"end":{"x":100, "y":10}}
Your selector could read that JSON object and draw the line between the 2 coordinates.
您的选择器可以读取该JSON对象并在2个坐标之间绘制线条。
#4
0
I feel like what you are trying to do will make too many unnecessary connections to the web, or not.
我觉得你想要做的事情会在网络上做太多不必要的连接。
Your code will be much faster and efficient if its all in your app rather that being fetched from a server that could potentially fail as some point in time.
如果您的代码全部在您的应用程序中,而不是从某个时间点可能会失败的服务器获取,那么您的代码将更快更有效。
Assume you have an image you want to use in your app all the time... Would you want to keep fetching such image from the web were you found it or just save it into your app and reference to it when you need it?
假设您有一个想要在应用程序中使用的图像......如果您找到它或者只是将其保存到您的应用程序并在需要时引用它,您是否希望继续从网络中获取此类图像?
I have had this issue and decide a few megabytes/kilobytes/bytes of data stored on a users phone is SAFER than having to keep fetching such data from a web server...
我遇到了这个问题,并确定用户手机上存储的几兆字节/千字节/字节的数据是SAFER,而不是从网络服务器获取此类数据...
This is just my opinion and my experience with app development, it's a push-pull issue that has its benefits one way, and benefits in other ways.
这只是我的观点和我在应用程序开发方面的经验,这是一个推拉式问题,它有一个好处,也有其他方面的好处。
But to finalize, keep the files stored on the app, more efficient but yes, the user will have to sacrifice a few megabytes of their mobile devices' memory.
但要最终确定,保持存储在应用程序上的文件更有效但是,用户将不得不牺牲几兆字节的移动设备内存。
If the app is good, like Facebook, who cares if the app takes up a few extra megabytes of memory, as long as it performs efficiently and the user isn't waiting forever to see changes occur. :)
如果应用程序是好的,就像Facebook一样,谁关心应用程序是否占用了几兆兆字节的内存,只要它有效执行并且用户不会永远等待看到更改发生。 :)