Ser Pounce
Ser Pounce

Reputation: 14571

Possible to download compiled .m file into app?

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?

Upvotes: 0

Views: 114

Answers (4)

Simon Germain
Simon Germain

Reputation: 6844

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.

Example:

Have a selector in your code that takes 2 CGPoints to draw a line.

Have a JSON string returned by a server with 2 coordinates:

{"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.

Upvotes: 1

jsetting32
jsetting32

Reputation: 1632

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...

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. :)

Upvotes: 0

Undo
Undo

Reputation: 25697

Nope, Apple won't let you.

In the App Store Submission Guidelines* (A.K.A. The Rules), Apple explicitly says that apps can't download code.

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.

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.

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.

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.

* If someone has a link, add it! I'm on mobile right now.

Upvotes: 2

Marcelo
Marcelo

Reputation: 9944

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.

Upvotes: 3

Related Questions