Uploaded app is too large

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Uploaded app is too large

Post by jessamy99 » Wed Apr 17, 2013 8:08 pm

Dear Team,

I have just finished a version 2 for one of my apps that is in the Store.
After uploading, it was rejected. I had an email from Apple saying that the max size for an upload is now 60Mb.
Mine is 106Mb.

They say this size applies to the compiled executable and suggest I store my images as a resource inside the app bundle, instead of putting them inside the compiled executable itself.

How do I do this in LiveCode?

Any help would be gratefully appreciated!!

With best wishes,
Jessamy Goddard.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Uploaded app is too large

Post by endernafi » Thu Apr 18, 2013 6:22 am

Hi Jessamy,

* Ensure that your images are copied to the engine / app bundle.
{File -> Standalone Application Settings -> Copy Files -> Add Folder...}

* Replace your images in the app with empty areas.
{Drag-Drop from the Tools Palette or on-the-fly using create image command}

* Before opening the card, associate the empty image and the resource.
Update the below script according to your needs and place it in the openCard or preOpenCard handler:

Code: Select all

put specialFolderPath("engine") & "/theImagesFolder/image_1.png" into tImageSource
set the filename of image "imagePlaceHolder_1" to tImageSource

Hope it helps...

Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Uploaded app is too large

Post by jmburnod » Thu Apr 18, 2013 12:12 pm

Hi Jessamy,
You can also download image files it in a subfolder of documents folder, but i'm not sure Apple like it.

Hi Ender,
Did you find your speakers for the story ?
I make an app with 800 Mo image and aif file.I never uploaded a app in the apple store, it is for a schools store
At the first launch the app download these folders from a server
For this app I need to add contents to the documents" folder, therefore i can't use the "engine" folder
Do you think that is possible in the Apple store ?

Best regards
Jean-Marc
https://alternatic.ch

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Uploaded app is too large

Post by endernafi » Thu Apr 18, 2013 1:15 pm

Jean Marc, hi...

No luck with the speakers, yet :/
Thank you, it's kind of you remembering it...

As of Apple's rules,
they absolutely don't like using the documents folder;
whether you copy the files on installation / first run
or download from a server.
My fingers get burned many times 8)
It's strictly reserved for the files created by the user and merely by the user, I understand.
Don't take risk, I advise, and use the cache folder.
The contents of it can be deleted if iOS needs disk space;
However, I use it in all my apps and iOS never emptied it due to disk real-estate needs.

Downloading a document-file {music, image, etc.} is fine,
the only kind you can't download is executables or executable-like files {stacks, in our case :wink: }
One may want to use some database / library stacks, thus not-executable files
but Apple still don't allow them.
Other than that, you're fine.

These are, of course, purely personal experiences and others may suggest opposite ideas.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Uploaded app is too large

Post by jessamy99 » Fri Apr 26, 2013 6:32 pm

Thankyou both, Jean-Marc and Ender Nafi.

My apologies for the delay in replying but family stuff interrupted.

Ender, I understand how to add in the folder of photos.
The second part where I associate the photos is puzzling me.
I will get back to you when I have given it a go.

Thankyou both so much for helping!

With best wishes,
Jessamy.

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Uploaded app is too large

Post by jessamy99 » Sun Apr 28, 2013 2:28 pm

endernafi wrote:Hi Jessamy,

* Ensure that your images are copied to the engine / app bundle.
{File -> Standalone Application Settings -> Copy Files -> Add Folder...}

* Replace your images in the app with empty areas.
{Drag-Drop from the Tools Palette or on-the-fly using create image command}

* Before opening the card, associate the empty image and the resource.
Update the below script according to your needs and place it in the openCard or preOpenCard handler:

Code: Select all

put specialFolderPath("engine") & "/theImagesFolder/image_1.png" into tImageSource
set the filename of image "imagePlaceHolder_1" to tImageSource

Hope it helps...

Best,

~ Ender Nafi

Dear Ender Nafi,

I am having difficulty getting the photos to be associated with the program.
I hope you can put me on the right path.

At the moment, I am accessing a database. My coding is as follows:-
1. In the stack...

command databaseConnect
local tDatabasePath, tDatabaseID
put getDatabaseID() into tDatabaseID
put specialFolderPath("documents") & "/Fish.sqlite" into tDatabasePath
put revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID
## Store the database id so other handlers can access it
setDatabaseID tDatabaseID
if TableName is not Fish then
databaseCreateTable
end if
if databaseGetIcon()= empty then
databaseInsertFish
end if
end databaseConnect


2. Also in the stack...

function databaseGetPhoto
put empty into the field "Photo" of card "showPhoto"
put getDatabaseID() into tDatabaseID
put "SELECT photo from Fish" into tSQL
put revDataFromQuery(tab,return,tDatabaseID,tSQL) into tRecords
return tRecords
end databaseGetPhoto

3. In the relevant card...

put line x of databaseGetPhoto() into field "Photo" of card "showPhoto"


How do I change this?
Is the problem that I am already accessing a special folder path for the database?

I really want to copy the photos into the Resources stack from the "engine". Is there a way?

I look forward to hearing your reply, and thank you in advance.
Best wishes,
Jessamy.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Uploaded app is too large

Post by endernafi » Sun Apr 28, 2013 4:43 pm

Hi Jessamy,

I have a few questions:
* Do you store your photos in the database as blob
or just the file paths of the photos?

* If the latter then are they in a server or in the device?
What is the output of databaseGetPhoto()?
{something like below maybe:
.../Documents/photos/photo1.jpg
.../Documents/photos/photo2.jpg
.../Documents/photos/photo3.jpg}

* Why do you use the below, for debugging purposes?

Code: Select all

put line x of databaseGetPhoto() into field "Photo" of card "showPhoto"
If you could answer these, then I can get the logic of your app
and hopefully post a sample solution stack here.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Uploaded app is too large

Post by jessamy99 » Sun Apr 28, 2013 8:45 pm

Dear Ender,

The program is for iPhone or iPad.

I already have a special folder for the database...
put specialFolderPath("documents") & "/Fish.sqlite" into tDatabasePath

The database has the names (not file paths) of all the photos in one column, and thumbnails in another column. Not blobs.
The other columns hold information about the fish that applies to the photo in that row, such as colour, size, depth etc and data for a quiz.

The photos and thumbnails are in the card "images" of the stack "Resources" at the moment. That obviously has to be changed.
They are copied in the bundle to the device inside the "images" card of the "Resources" stack.


The line...

put line x of databaseGetPhoto() into field "Photo" of card "showPhoto"

is part of a paragraph.

The information about colour, size, depth etc for line x of the database is all called at the same time to display the photo of the fish
and the information about it on the same page.
This line actually puts the image from the card "images" in the stack "Resources" into a field called "Photo".

"databaseGetPhoto()" holds all the photo names on separate lines which are accessed by looking for line x.

The headings of the database are....

put "CREATE TABLE Fish (id int(230), icon char(20), photo char(20), name char(20), propername char(40), colour char(20), size char(10), danger char(20), food char(30), found char(30), credit char(20), wiki char(20), question char(200), qA char(50), qB char(50), qC char(50), answerA char(15), answerB char(15), answerC char(15))" into tSQL
revExecuteSQL tDatabaseID, tSQL

For example, line 1 of the database is...

put "INSERT into Fish VALUES ('1','AngelfishAtie.png','AngelfishAtieb.png','Angel Fish','Emperor angelfish','Blue and yellow','50 cm','No danger','Algae, invertebrates and sponges','Depth up to 70m, by coral reefs and seagrass','Atie Bruinenberg','http://en.wikipedia.org/wiki/Pomacanthidae','1. What does a thumbs up signal mean?','A: This is good.','B: Are you OK?','C: Shall we go up?','No, try again','No, try again','Correct');" into tSQL

The large photos and the thumbnails are held in the second and third columns.

Is there a way to copy the images from "engine" to the card "images" in the stack "Resources" ?

I hope the above is clear!!

Thankyou for helping. :)

With best wishes,
Jessamy.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Uploaded app is too large

Post by endernafi » Sun Apr 28, 2013 10:26 pm

Hi Jessamy,

* Don't use the documents folder, Apple doesn't like it at all.
Use the caches directory, instead.

* Don't use the resources stack approach.
You already had some trouble with Apple regarding this issue.
Don't force it.
Sure, you can copy the images from engine into your stack.
A handler can crawl through the images folder in engine
and import the photos one by one into your resources stack
using the import paint from file syntax.
But, as I said, it's not wise.
It will bloat your executable after installation
and I don't think Apple will approve that, too.

* Follow Apple's advice.
Create empty images and set their filenames to the paths of related image files.
Here is a sample stack:
seaFauna.zip
(82.02 KiB) Downloaded 408 times
It's not pretty and not well-commented, I know.
But it demonstrates the process, you need.
It copies the resources folder from engine to cache at first run or if the app version changes.
Then it pulls the data from database,
creates thumbnails in the first card.
If a thumbnail clicked, it navigates to the detail card
where the user can see a full picture of the fish and some info about.

And the good thing is that the executable's filesize is about 5mb. 8)

Feel free to ask about any confusions regarding my code.


Hope it helps...

Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Uploaded app is too large

Post by jmburnod » Mon Apr 29, 2013 2:06 pm

Hi Ender,
If I understand correctly there is two copy of image. One in the cache folder and one in the engine folder. I'm right ?
Why doesn't download image files directly in the cache folder ?
Best
Jean-Marc
https://alternatic.ch

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Uploaded app is too large

Post by endernafi » Mon Apr 29, 2013 2:36 pm

Hi Jean-Marc,

If the images are to be downloaded on first run from a server,
then you're absolutely right; they should be downloaded directly to the cache directory.

But if they are packed with the app itself then this is the way.
The Copy Files pane of Standalone Application Settings copies the resources into the engine folder.
And changing the files inside the engine folder may -and probably will- cause trouble due to digital sign process.
So, I copy the resources from engine to the cache directory.
That process can be enhanced, of course, to remove the left-over files in the engine to save up disk space.
But I didn't need that ever and I'm not comfortable with changing the engine folder, as I said.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Uploaded app is too large

Post by jessamy99 » Tue Apr 30, 2013 12:42 am

Dear Ender,

Thankyou so much for your help!
I will have a look at your example and get back to you.

You are a real star!!

Best wishes,
Jessamy.

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Uploaded app is too large

Post by jessamy99 » Wed May 08, 2013 8:47 pm

Dear Ender,

Thankyou very much for the help.
I have managed to adapt your code for my program successfully.
I really appreciate your help.

Now I am stuck though.
I can't get my new version to go online to a url address.
My old program works perfectly in this respect.
I am sure I am doing something really silly!!

Any advice would be gratefully received!

Thankyou again for the help.
With best wishes,

Jessamy.

endernafi
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 296
Joined: Wed May 02, 2012 12:23 pm
Contact:

Re: Uploaded app is too large

Post by endernafi » Wed May 08, 2013 10:39 pm

Hi Jessamy,

What do you want to do, exactly?
* Downloading the big pictures from internet,
* Uploading user comments to a server,
* Syncing your app with a simple cloud-based system,
* Showing a web-page,
* Pulling a wikipedia-entry to show in the info section,
or anything else?

If you could define your problem specifically, I would do my best to help out.


Best,

~ Ender Nafi
~... together, we're smarter ...~
__________________________________________

macOS Sierra • LiveCode 7 & xCode 8

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Uploaded app is too large

Post by jessamy99 » Thu May 09, 2013 1:28 am

Dear Ender,

I have a simple link via a button, from each fish, to Wikipedia.
There you can see more information about each fish.

This works perfectly on my previous program.
In the new program, it works perfectly on the laptop, but not in the iPhone simulator or on the iPhone.
I must have changed something in the application settings.

I will have another look tomorrow.
I just got so frustrated as I thought I had finished!!

If you have any thoughts, they will be gratefully received.

Thankyou again,
Best wishes,
Jessamy.

Post Reply