Recent

Author Topic: dwindows for iOS  (Read 1968 times)

PierceNg

  • Sr. Member
  • ****
  • Posts: 374
    • SamadhiWeb
dwindows for iOS
« on: December 17, 2022, 06:27:28 am »
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
« Last Edit: December 17, 2022, 06:33:37 am by PierceNg »

PierceNg

  • Sr. Member
  • ****
  • Posts: 374
    • SamadhiWeb
Re: dwindows for iOS
« Reply #1 on: December 27, 2022, 08:18:18 am »
Another step forward. The littlest Pascal demo now works on iPhone simulator.

The source repo:

Code: Text  [Select][+][-]
  1. % ls -l
  2. total 16
  3. -rw-r--r--@  1 pierce  staff  3580 Dec 26 23:37 CMakeLists.txt
  4. -rw-r--r--@  1 pierce  staff   655 Dec 26 22:20 Info.plist
  5. drwxr-xr-x   5 pierce  staff   160 Dec 27 13:23 dwinpas.app/
  6. drwxr-xr-x  10 pierce  staff   320 Dec 27 13:33 src/
  7.  
  8. % ls -l src
  9. total 960
  10. -rw-r--r--@ 1 pierce  staff   82581 Dec 27 11:21 dw.h
  11. -rw-r--r--@ 1 pierce  staff  392608 Dec 16 23:20 dw.m
  12. -rw-r--r--  1 pierce  staff    1770 Dec 27 13:21 dwindows.pas
  13. -rw-r--r--@ 1 pierce  staff    2167 Dec 27 13:23 dwinpas.pas
  14. -rw-r--r--  1 pierce  staff     323 Dec 24 18:20 lcextra.c

The meta-building:

Code: Text  [Select][+][-]
  1. % cmake -S . -B build \
  2.   -DCMAKE_FPC_COMPILER=$HOME/pkg/fpc331/lib/fpc/3.3.1/ppcrossx64 \
  3.   -DFPC_TARGET_CPU=x86_64 \
  4.   -DFPC_TARGET_OS=iphonesim \
  5.   -DXCODE_IOS_PLATFORM=iphonesimulator
  6. -- The C compiler identification is AppleClang 14.0.0.14000029
  7. -- The CXX compiler identification is AppleClang 14.0.0.14000029
  8. -- Detecting C compiler ABI info
  9. -- Detecting C compiler ABI info - done
  10. -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
  11. -- Detecting C compile features
  12. -- Detecting C compile features - done
  13. -- Detecting CXX compiler ABI info
  14. -- Detecting CXX compiler ABI info - done
  15. -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
  16. -- Detecting CXX compile features
  17. -- Detecting CXX compile features - done
  18. -- The OBJC compiler identification is AppleClang 14.0.0.14000029
  19. -- Detecting OBJC compiler ABI info
  20. -- Detecting OBJC compiler ABI info - done
  21. -- Check for working OBJC compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
  22. -- Configuring done
  23. -- Generating done
  24. -- Build files have been written to: /Users/pierce/dwinpas/build

The building:

Code: Text  [Select][+][-]
  1. % (cd build; make)
  2. ...
  3. ...
  4. [100%] Generating dwinpas
  5. /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.pas
  6. Free Pascal Compiler version 3.3.1 [2022/12/22] for x86_64
  7. Copyright (c) 1993-2022 by Florian Klaempfl and others
  8. Target OS: Darwin/iPhoneSim for x86_64
  9. Compiling /Users/pierce/dwinpas/src/dwinpas.pas
  10. Compiling /Users/pierce/dwinpas/src/dwindows.pas
  11. Assembling (pipe) /Users/pierce/dwinpas/build/x86_64-iphonesim/dwindows.s
  12. Assembling (pipe) /Users/pierce/dwinpas/build/x86_64-iphonesim/dwinpas.s
  13. Linking /Users/pierce/dwinpas/build/x86_64-iphonesim/dwinpas
  14. ld: warning: dylib (./x86_64-iphonesim//libdwindows.dylib) was built for newer iOS Simulator version (13.0) than being linked (9.0)
  15. 132 lines compiled, 0.4 sec, 835584 bytes code, 245759 bytes data
  16. [100%] Built target default
  17. /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

  • Sr. Member
  • ****
  • Posts: 374
    • SamadhiWeb
Re: dwindows for iOS
« Reply #2 on: December 30, 2022, 03:14:47 am »
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  [Select][+][-]
  1. procedure dwmain(argc: Integer; argv: PPChar); cdecl;
  2. begin
  3.   dw_init(TRUE, argc, argv);
  4.   dw_messagebox('Free Pascal + dwindows', DW_MB_OK or DW_MB_INFORMATION, 'Hello from Pascal, courtesy of dwindows!');
  5.   dw_exit(0);
  6. 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.
« Last Edit: December 30, 2022, 05:17:26 am by PierceNg »

 

TinyPortal © 2005-2018