more on native apps

This commit is contained in:
David Botton 2022-09-02 13:59:05 -04:00
parent e2ddc41f1f
commit e6df0e5ab0
3 changed files with 48 additions and 10 deletions

39
NATIVE.md vendored
View file

@ -1,7 +1,23 @@
# Creating Native Applications with CLOG
1. Open app using chrome in app mode
2. Native app using :ceramic
Simple solution:
Common to all solutions is compiling you CLOG application to an executable.
See demos/make-snake and the source of the 01-demo.lisp file.
make-snake produces a native app that launches a browser. When snake game
exist the executable quits.
More advanced solutions:
1. Open app using chrome in app mode (not exactly native but looks it)
2. Use MacGap on Mac (best native option for Mac)
3. Native app using (ql:quickload :ceramic) (works well for Windows and Linux)
4. Native iOS and Android using Cordova and ECL
## 1 Open app using chrome in app mode
@ -16,12 +32,22 @@ On Linux:
google-chrome-stable --new-window --app="http://127.0.0.1:8080/builder"
On WindowsL
On Windows
chrome --new-window --app="http://127.0.0.1:8080/builder"
## 2 Use MacGap and XCode
## 2 Using Ceramic Mac/Windows/Linux
https://github.com/MacGapProject/MacGap2
```
git clone https://github.com/MacGapProject/MacGap2.git
open MacGap2/MG.xcodeproj/
```
In public/index.html in Xcode you use: MacGap.launch(appName)
to launch your app. Then connect to it on the port you have chosen.
## 3 Using Ceramic Mac/Windows/Linux
The documentation for ceramic is at:
http://ceramic.github.io/
@ -86,3 +112,8 @@ That should start up a native application with your CLOG app
To package you applicaton use:
1. (ceramic:bundle :elect)
## 4 Native iOS and Android using Cordova and ECL
https://cordova.apache.org/

View file

@ -4,6 +4,9 @@
(in-package :clog-demo-1)
(defparameter *app-mode* nil
"Run application once and shutdown")
;; Game Display
(defconstant display-width 375)
(defconstant display-height 375)
@ -179,11 +182,14 @@
(clog:shutdown)
(uiop:quit)))
(defparameter *app-mode* nil)
(defun start-demo (&key (host "0.0.0.0") (port 8080) app)
(defun start-demo (&key (host "0.0.0.0") (port 8080) (start-browser t) app)
"Start demo. If app is t, runs one game and shutsdown."
(when (eql port 0)
(setf port (clog-connection:random-port)))
(initialize 'on-new-window :host host :port port)
(if app
(setf *app-mode* app)
(open-browser :url (format nil "http://127.0.0.1:~A" port))))
(when app
(setf *app-mode* app))
(when start-browser
(format t "If browser does not start go to http://127.0.0.1:~A" port)
(open-browser :url (format nil "http://127.0.0.1:~A" port))))

1
demos/make-snake vendored Executable file
View file

@ -0,0 +1 @@
sbcl --eval "(ql:quickload :clog)" --eval "(clog:load-demo 1)" --eval "(sb-ext:save-lisp-and-die #P\"snake\" :toplevel (lambda () (clog-demo-1:start-demo :port 0 :app t :start-browser t) (loop (sleep 10))) :executable t :compression t)"