I was excited when @Simeon recently announced that we could now incorporate additional iOS functionality in Codea thanks to @jfperusse’s objc bridge. I’m a amateur programmer that loves Lua and Codea and longed for the ability to create utilities on my iPad but needed additional GUI, web browser, and speech recognition capabilities to do so. I was especially wanting to create displays that were multi-functional (e.g. contain a textbox for data entry, a web-browser for knowledge searching, and 2 and 3D drawing capability to display images). I initially asked Simeon if they would consider making Codea’s built in browser resizable, and he suggested instead to use the new objc bridge to create a resizable browser with iOS’s built in WKWebView (there is also a fully resizable SFSafariViewController in iOS but it doesn’t seem to be working yet with the objc bridge). Thus, I created the following example of a resizable web browser to share with others what I learned about how to use the objc bridge in Lua, and how one might combine objc code with standard Lua code in Codea. I thank jfperusse for offering suggestions when I got stuck trying to program with the objc bridge.
Please note that the program is not fully polished and crashes not infrequently which may improve after future objc updates in Codea. It doesn’t do everything that Safari can do nor run as smoothly, and the Codea objects don’t quite update at the same time as their adjacent objc objects do. Still, I think other might find it useful as an example since the objc bridge is relatively new. As amateur programmer, I welcome all feedback to improve the code.
(Code and sprites too large for one post; posted separately as subsequent post of same title (code))
You should be able to post it as a zip file (choose Export → Zip). If you bundle your assets directly in the project folder (so they are referenced via asset.Name) then it should just work for someone who downloads the zip file into Codea
Thanks, @sim, and sorry about that. I was recently corresponding with @jfperusse about some great updates he was making to the Codea objc bridge and suspect he was trying to help by moving this old post of mine in the old forum to where it could be more visible. At the time I initially posted this demo, I had included an obj file that was too big to package as an asset to be posted to the forum. I just swapped out that larger obj file with the build in 3D robot so that I could now paste the demo for others to view from the forum. ObjcMultiWind.zip (8.1 KB)
Hi, @Bri_G.
Sorry to hear that it kept crashing on you. Are you still on 3.5.3, too (I’m not on the 3.6 beta)? If you are not on Codea 3.5.3, I wonder if some functionality of the objc bridge has changed.
Will cc: @jfperusse
@Bri_G I was able to do whatever I wanted with Google in the left window. I did Codea.talk and brought up this discussion and looked thru it. I did searches on other things without problems.
@dave1707 - update, after posting above I thought I had better find out how to crash this demo so that others could reproduce it. I couldn’t.
Loaded up again, ran, played with the robot, switched to the browser window and tried my best to crash Codea - no joy. Browser was great by the way.
Came out of it into Safari and started to make this reply and — Codea Crashed !!!
A message fired up - I have commented before that I think that V4 may be leaving residual activity/code in which may be causing crashes when you switch to other apps.
@Bri_G I notice Codea crashes after I exit Codea, but not all the time. I figure it’s just the new versions and I won’t worry about it until we get to final versions.
@jfperusse - will try those conditions to see if I can crash Codea reproducibly.
One observation though, Codea crashed several times on me when still in the background, the crash alert popped up in front of Safari when I was looking at the forum.
One thing I noticed. Codea will crash when I run code and move it to the background the first time I use it after it’s been closed awhile. After the initial crash, if I run code and move it to the background, it doesn’t crash even after closing/opening several times. I’m not sure how long it has to be closed before I get the crash but I’ve noticed that for awhile now.
PS. Come to think of it, for quite a few releases, after loading a new version of Codea, it always crashed the first time I would use it after moving it to the background or closing it.