Page 1 of 2

Environment: which applies when?

Posted: Sat Jun 15, 2019 12:55 am
by sritcp
I’d like to understand when the different environments operate: e.g., consider “development”, “standalone application”, and “mobile”. Which one applies when:

i) testing using the iOS simulator on Mac
ii) testing with iOS device connected to the Mac
iii) standalone installed on the iOS device

Thanks,
Sri

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 8:59 am
by Klaus
Hi Sri,

for all three BOTH applies:
the environment = "standalone application" AND the environment = "mobile"


Best

Klaus

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 12:16 pm
by bogs
Heya Sri,

*If* your sure you don't mean 'engine', you can stick in somewhere (probably openCard) something like

Code: Select all

answer the environment
...which will tell you exactly where your program is working in.
Selection_001.png
An interesting situation developed....

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 2:19 pm
by sritcp
May be I wasn't clear about my confusion!

Suppose I want to play a video in an iOS app, being developed on a Mac.
The code might be

Code: Select all

if the environment is "development" then
show player 1
start player 1
else if the environment is "mobile" then
play video tVideoURL
end if
Would it be appropriate to use "mobile" if I am testing on a simulator? or would the program consider the environment to be "development", as we are not really testing it on an iOS device?
Are "standalone" and "mobile" interchangeable in the above example?

Thanks,
Sri

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 3:07 pm
by bogs
OH!

Sorry, I sure don't know much about the simulators and how they work, but, you certainly could still find out what environment the simulator is using with what I posted.

*IF* the answer is mobile, then try the tUrl code. How long could it take to test? (Again, I have no idea how the simulators work! I suppose it could take hours :P )

...But, I know a few who don't use the simulators at all for testing, and I suppose that if you really wanted it to be a 'mobile' environment, you could test directly on the device itself (did I mention I don't develop on mobile?_) :D

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 3:19 pm
by Klaus
Ah, OK, if the environment = "mobile" it CANNOT be "development" at the same time.
And the simulator should report "mobile".

Is that what you mean?

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 4:06 pm
by sritcp
Klaus:

It is not "development" and "mobile" at the same time!

See, "play video" works only on mobile, where it plays a video fullscreen.
"Player" object works only on desktop OS.
So, while developing I put in "if the environment is ...." clause, so it works on both (while testing).
If the simulator considers its environment as "mobile", then "play video" should run on the simulator, resulting in a fullscreen (i.e., stack size) video.

So, my question was both practical and conceptual. I wondered when I would use "standalone" instead of "mobile". I guess "standalone" is to be used for desktop standalone. (The environment options seem to be a mishmash of OSs and device types. I don't see a function for determining the OS. There is only a systemVersion)

Regards,
Sri

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 5:11 pm
by jacque
The OS is returned in "the platform".

Only the IDE is considered "development", the mobile environment is anything that is running the mobile version of the OS whether it's a phone, simulator, or emulator.

Note that the iOS simulator finds files using the same paths as the IDE (that is, the Mac Finder locations) where a real phone uses a different internal path. The best way to build a file path is to use the specialFolderPath function which will sort out the differences for you. In particular, use specialFolderPath("resources") to find videos and keep the videos in the same folder, or a subfolder, of the mainstack.

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 5:43 pm
by Klaus
Hi Sri,

if not "mobile" then it must be desktop, so this should do the job:

Code: Select all

...
if the environment = "mobile" then
   play video tVideoURL
else
  ## Desktop: IDE or Standalone
  show player 1
  start player 1
end if
...
Best

Klaus

Re: Environment: which applies when?

Posted: Sat Jun 15, 2019 6:58 pm
by sritcp
jacque wrote:
Sat Jun 15, 2019 5:11 pm
... In particular, use specialFolderPath("resources") to find videos and keep the videos in the same folder, or a subfolder, of the mainstack.
The dictionary says, "On iOS systems, only create files in the "documents", "cache" and "temporary" folders. Be careful not to change or add any files within the application bundle. The application bundle is digitally signed when it is built, and any changes after this point will invalidate the signature and prevent it from launching."

If my app is designed to periodically add videos and text files that are part of program resources (as opposed to user-created files), where would I put them? Evidently, not in "resources" folder (due to signature invalidation, above). Keeping it in "documents" folder doesn't make sense, as I wouldn't want the user to be able to access them outside of the app.

Thanks,
Sri

Re: Environment: which applies when?

Posted: Sun Jun 16, 2019 5:56 pm
by jacque
On mobile the documents folder is not available to anyone (or any other app) because it's inside the app sandbox. To share resources outside the sandbox you'd use specialFolderPath("external documents"). Files in documents are safe unless the user has rooted the android device or jailbroken the iPhone, unless the user is very focused on cracking your particular app and has the skills to do so. There's no failsafe way around that for any app.

I'd store the files in documents if you want to be sure they are permanently available. If they are intended only for the current session then cache or temporary are a good choice.

Re: Environment: which applies when?

Posted: Mon Jun 17, 2019 1:32 am
by sritcp
That helps. (Although there is still a great deal of iOS fog in my mind!)
Thank you.

Sri.

Re: Environment: which applies when?

Posted: Sun Feb 09, 2020 4:27 am
by sritcp
I am sorry to bring this up again, but
in the case of a standalone application running on iOS
what would the function environment() return?
"standalone application" or "mobile" ?
Why?
(I am assuming the function returns only one result).

Thanks,
Sri

Re: Environment: which applies when?

Posted: Sun Feb 09, 2020 10:55 am
by jmburnod
Hi Sri,
what would the function environment() return?
"standalone application" or "mobile" ?
it should be "mobile"
Best
Jean-Marc

Re: Environment: which applies when?

Posted: Sun Feb 09, 2020 5:28 pm
by jacque
The reason is that originally LC only produced desktop standalones. When mobile was added we needed a new term to differentiate.