Forum > iPhone/iPad
dwindows for iOS
(1/1)
PierceNg:
Another baby step: Running the dwindows demo (written in C) as an iOS app. In simulator only for now. Screenshots attached.
Cool:
- landscape / portrait auto layout switching works
- threading works
- some widgets like date picker, drive explorer are native
- web widget works - in the screenshot I've modified the source code to go to my blog
There are problems of course. Overall, I'd say dwindows is early beta quality for Android and iOS.
Now I just need working FPC cross compilers for iOS targets...
Edit: Android thread here: https://forum.lazarus.freepascal.org/index.php/topic,61606.0.html
PierceNg:
Another step forward. The littlest Pascal demo now works on iPhone simulator.
The source repo:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---% ls -ltotal 16-rw-r--r--@ 1 pierce staff 3580 Dec 26 23:37 CMakeLists.txt-rw-r--r--@ 1 pierce staff 655 Dec 26 22:20 Info.plistdrwxr-xr-x 5 pierce staff 160 Dec 27 13:23 dwinpas.app/drwxr-xr-x 10 pierce staff 320 Dec 27 13:33 src/ % ls -l srctotal 960-rw-r--r--@ 1 pierce staff 82581 Dec 27 11:21 dw.h-rw-r--r--@ 1 pierce staff 392608 Dec 16 23:20 dw.m-rw-r--r-- 1 pierce staff 1770 Dec 27 13:21 dwindows.pas-rw-r--r--@ 1 pierce staff 2167 Dec 27 13:23 dwinpas.pas-rw-r--r-- 1 pierce staff 323 Dec 24 18:20 lcextra.c
The meta-building:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---% cmake -S . -B build \ -DCMAKE_FPC_COMPILER=$HOME/pkg/fpc331/lib/fpc/3.3.1/ppcrossx64 \ -DFPC_TARGET_CPU=x86_64 \ -DFPC_TARGET_OS=iphonesim \ -DXCODE_IOS_PLATFORM=iphonesimulator-- The C compiler identification is AppleClang 14.0.0.14000029-- The CXX compiler identification is AppleClang 14.0.0.14000029-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped-- Detecting C compile features-- Detecting C compile features - done-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - done-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped-- Detecting CXX compile features-- Detecting CXX compile features - done-- The OBJC compiler identification is AppleClang 14.0.0.14000029-- Detecting OBJC compiler ABI info-- Detecting OBJC compiler ABI info - done-- Check for working OBJC compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped-- Configuring done-- Generating done-- Build files have been written to: /Users/pierce/dwinpas/build
The building:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---% (cd build; make)......[100%] Generating dwinpas/Users/pierce/pkg/fpc331/lib/fpc/3.3.1/ppcrossx64 -v -FE/Users/pierce/dwinpas/build/x86_64-iphonesim -Fl/Users/pierce/dwinpas/build/x86_64-iphonesim -Tiphonesim -Px86_64 /Users/pierce/dwinpas/src/dwinpas.pasFree Pascal Compiler version 3.3.1 [2022/12/22] for x86_64Copyright (c) 1993-2022 by Florian Klaempfl and othersTarget OS: Darwin/iPhoneSim for x86_64Compiling /Users/pierce/dwinpas/src/dwinpas.pasCompiling /Users/pierce/dwinpas/src/dwindows.pasAssembling (pipe) /Users/pierce/dwinpas/build/x86_64-iphonesim/dwindows.sAssembling (pipe) /Users/pierce/dwinpas/build/x86_64-iphonesim/dwinpas.sLinking /Users/pierce/dwinpas/build/x86_64-iphonesim/dwinpasld: warning: dylib (./x86_64-iphonesim//libdwindows.dylib) was built for newer iOS Simulator version (13.0) than being linked (9.0)132 lines compiled, 0.4 sec, 835584 bytes code, 245759 bytes data[100%] Built target default/opt/local/bin/cmake -E cmake_progress_start /Users/pierce/dwinpas/build/CMakeFiles 0
The screenshot... is attached.
Next, to get this running on my phone.
PierceNg:
Step by step. The littlest Pascal demo now builds in Xcode, gets packaged as a signed iOS app, installs into my iPhone, and runs.
Screenshot attached, Android phone on the left, iPhone on the right.
The code putting up the message box is the same:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure dwmain(argc: Integer; argv: PPChar); cdecl;begin dw_init(TRUE, argc, argv); dw_messagebox('Free Pascal + dwindows', DW_MB_OK or DW_MB_INFORMATION, 'Hello from Pascal, courtesy of dwindows!'); dw_exit(0);end;
Scaffolding is different: on Android, the Pascal program is built as a shared library, dwindows is another shared library, while on iOS the Pascal program becomes an executable and dwindows is a framework.
Next is to build a demo with more GUI widgets.
Beyond the short term, as I see it, the best approach to building Android/iOS apps with a common Pascal code base is to use HTML/CSS through the web widget, like what my fpwebview does for the desktop platforms. (Indeed, recurring question for webview is whether it works for Android and iOS.)
Using, say, mORmot to do server-side rendering fully, the app should require minimal to zero Javascript on the front end. Concerns about latency, state management etc that motivated the creation of fancy Javascript front-end frameworks go away as the app is effectively a single-user single-browser tab on-device web app.
Alright, that sounds like a plan.
Navigation
[0] Message Index