trevordevore / levure

Application development framework for LiveCode
MIT License
32 stars 14 forks source link

On iOS, can't have "resources" folder in root of app folder #47

Closed spencerlearning closed 7 years ago

spencerlearning commented 7 years ago

On iOS, you cannot successfully build an application that has a folder named resources in the root of the app folder.

  1. Follow the wiki instructions to create a new project from master.

  2. Create a folder named resources in the root of the app folder alongside app.yml and put a file in the folder.

  3. Add the folder to copy files in app.yml:

    copy files:
      all platforms:
        1:
          filename: ./resources
  1. In Standalone Application Settings accept defaults except iOS is the only platform selected.

  2. In message box, run levurePackageApplication "beta". It builds much quicker than normal. Look at the contents of the generated iOS bundle. It is empty except for a single file.

  3. Now change the folder name to assets or any other name, update copy files in app.yml, and rebuild. It builds normally and everything is in the iOS bundle as expected.

  4. Now create a folder named resources inside the assets folder, add in a file so it isn't empty, and rebuild. Everything works fine.

Conclusion: On iOS you cannot have a folder named resources in the root of app folder. This issue does not occur with MacOS, Windows, or Android.

trevordevore commented 7 years ago

Here is the bug report explaining the issue:

http://quality.livecode.com/show_bug.cgi?id=9238

trevordevore commented 7 years ago

The LC standalone builder will typically report an error if you try to use a resources folder. The Levure packager runs the standalone builder under a special testing mode, however, by calling revSetTestEnvironment true. When running in testing mode this is what happens:

  1. When building a standalone revDoSaveAsStandalone calls revSaveAsMobileStandalone which in turn calls revSaveAsMobileStandaloneMain.
  2. revSaveAsMobileStandaloneMain throws an error if a resources folder is being added to the mobile app.
  3. In normal mode revSaveAsMobileStandalone catches the error and displays it using answer. In testing mode the error is returned.
  4. The caller, revDoSaveAsStandalone never checks for errors. In testing mode the error is swallowed up and never reported. That is why Levure didn't report anything.

I've pushed a change that runs the packager in normal mode rather than testing mode. The upside is that all errors are reported and you see feedback during the build process. The downside is that you have to press an OK button after each platform is built.

The reason you have to press OK after building for each platform is because the Levure packager builds one platform at a time. I found this approach to be more reliable then trying to build for all platforms at once.

In order to suppress the "Standalone application saved successfully." message that revSaveAsStandalone displays after building for a platform a new parameter would need to be added. Currently it can only be suppressed if running in test mode and that means all messages and feedback are suppressed.

trevordevore commented 7 years ago

I filed an enhancement request to suppress the success message when building standalone.

http://quality.livecode.com/show_bug.cgi?id=19638

trevordevore commented 7 years ago

Alright, now that all of the coding issues have been addressed we have to decided on which folder name to bless for resources. Suggestions? Shall we just go with assets?

macMikey commented 7 years ago

Why not stuffs? It's stuff, but it's plural. Assets is so not-LC.

trevordevore commented 7 years ago

@macMikey :-)

I'm aiming for something a little more professional.

spencerlearning commented 7 years ago

I think assets is probably the best choice. It is a synonym for resources and it is a standard term in web design. I can't think of any other good alternatives.

trevordevore commented 7 years ago

I was just looking through the code and there is only one place where resources is used. When loading extensions using load extension I was passing in a default with resource path that pointed to a resources folder alongside app.yml. I don't have a use case for doing this and the developer can specify a folder to use for with resource path in app.yml so I removed that code.

So perhaps we just need to make a note saying "don't use a folder named resources in the app folder" if you are building for iOS?

macMikey commented 7 years ago

I think you should probably go further than that. I think you should pick a name, whether it be "Assets" or "Support", or whatever, and then get the n00bs in the habit of using that name as a convention. In the docs, you can mention that "Resources" is bad because of ios and then leave it at that. When the Levure project is built, add the folder. I would expect that most users will just follow the convention you set.

trevordevore commented 7 years ago

@macMikey By "when the Levure project is built" are you referring to the stack that creates new projects?

macMikey commented 7 years ago

Yep. I think that that stack should create an "Assets" folder, and then the docs should just matter-of-factly state that's where those support files go. The app.yml file should also call it "Assets". Avoid 90% of the trouble by taking all the "paint inside the lines" "follow the directions" people out of play. Add notes to the docs to take care of just about everyone else, and for those special few, there's RTFM.

trevordevore commented 7 years ago

Agreed. I'll update the stack that creates a new project.

trevordevore commented 7 years ago

I just found a problem with not having the packager build standalones in testing mode. When building the standalones I now get errors about stacks in memory that need to be purged.

That leaves us in an interesting position. If we build in testing mode everything runs smoothly but there are some edge case errors that are not reported. If we don't build in testing mode then the IDE loads stacks differently and reports error that break the standalone building process.

Now to determine which problem is easier to fix...

trevordevore commented 7 years ago

I'm closing this as the issue reported in this bug report has been fixed.