Delphi Mobile Apps Development using Delphi

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
Mobile Apps Development using Delphi

Today’s topic is about mobile apps development using Delphi. This article is for people who already use Delphi for desktop development and just heard something or thought that they have to improve their software and add for example mobile (cell phones and tablets) support.

What is Delphi today.​

I'd like to refresh in our minds some history. If you have already participated in our webinars you have already saw some of the slides. That’s all for new people. Anyway, let's just refresh what Delphi was in the past and what it is now.

Delphi is a software development tool used to build desktop, mobile and different IOT software today. It is up-to-date despite it was developed in 1995. The reason for it is that it's been regularly updated by Embarcadero, at least, according to my information, we have a couple of releases per a year and Embarcadero keeps it up-to-date. It has been all the time and it is still a huge Delphi community comprising experienced engineers and developers.

Delphi was a revolutionary technology for rapid application development in the 90s and 2000s. It was a really unique tool which you could use for desktop development compared with this ugly Microsoft Visual Studio 6 version. That time it was too hard to start development of an application with Visual Studio 6 compare with Delphi where you could just create the project put the controls then run. And observe how the miracles started happening.

An interesting fact is that the Chief Architect behind Delphi was Anders Hejlsberg who was later persuaded to move to Microsoft where he worked as a lead architect of C#. I provided such information here just like a food for the thought. And after that in 2003 Microsoft introduced .NET/C# and Visual Studio 2003 which in my point of view is a Microsoft’s version of RAD studio. They spent a lot of money into advertisement and marketing of these tools and the popularity of Delphi started decreasing and eventually .NET caught the leadership.
1627813227145.png

The reasons to continue using Delphi.​

We will divide this question in two parts: pros and cons. First we need to talk about pros and cons of Delphi because, of course, we have pros and cons if we want to be objective.

Pros
  • Delphi is a cross-platform tool. Today you really can develop apps for iOS, Android, I'm not talking about Windows because it's like a must-have, you can develop applications for macOS or applications for Linux.
  • Delphi is easy to use and designed for rapid development approach for desktop development. According to my experience software development with Delphi is really easier and really more rapid if compared with WPF which of course has a much richer UI than WinForms. However from the other side it's really much harder to develop WPF UI applications as compared with Delphi. But if we're talking about WinForms I cannot even compare it with Delphi because WinForms is very weak in UI and possibilities and it's not easy to improve the UI of WinForms applications.
  • Delphi applications are easy to deploy since executables don't need any pre-installed frameworks, and hence there is no headache about frameworks versioning, packages versioning, etc. And this is what I mean. If you have, for example, some .NET application you should know which .NET version your clients have, which packages they have, how it will be, will they have any conflicts, and you have to deploy assemblies and there is a lot of questions.
  • Even today Delphi has a huge set of 3rd party components, for example look at TMS Software set. It’s a really huge set of components which can cover UI, background operations or show media, different cross-platforms controls, web controls and so on.
  • Of course, one more advantage is regular new releases of Delphi and RAD Studio from Embarcadero.
  • As a pro, we have a lot of software which was developed using Delphi. Right now you can really migrate that legacy software using for example Delphi 5, Delphi 7 to the up-to-date Delphi versions without rewriting it from scratch. If your software has a lot of background logic, you can keep 90-95% of your code. Of course, like a remark, only if you don't need a code review and rewriting your code and rewriting spaghetti.
1627813280761.png

Cons.

Two major cons in my point of view are future risks and negative information noise.
  • Future risks: this is what I'm hearing from our clients and our partners: will Embarcadero have enough resources to compete on par with other development tools? Will we have enough specialists and developers on the market for supporting and developing our software? And these questions are really important. Right now even we are fighting for Delphi and trying to be like Delphi evangelists explaining people why they don't need to be scared.
  • Negative information noise: in the 90s and 2000s Delphi was studied in universities and now it's replaced by other tools. Last year, as I remember, Embarcadero introduced a free version of Delphi (Community Edition) and now maybe different universities will again continue using Delphi and young people will study it during their classes. Again, today young developers consider Delphi to be obsolete, not fashionable technology. They don't have any facts. This is what they just hear and this is what I'm calling a negative information noise. Delphi is not an operating system owner. So this is self-explanatory why it's always half a step back from Microsoft, Apple or Google. When Microsoft already developed something, implemented in their development tools, Embarcadero needed time to add the support of these new features in their Delphi. That's life.
  • Again, my point of view, Delphi is not suitable for web development. I am talking about web development in classic understanding. If compared with native web technologies like Visual Studio and ASP.NET, Apache and PHP, you don't have a native for Delphi.
  • Time consuming for the development of complex mobile applications. It's not easy to implement any custom SDKs from Facebook, Google or Apple which are not supported in FireMonkey by default. This is a very serious disadvantage. Sometimes if you are using native tool for Android development, like Android Studio, for implementing a new version of SDK from Facebook you will need maybe a couple of hours, but for Delphi, unfortunately, if you're not experienced it can take two days, a week, and so on.
1627813307352.png
 

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009

Why do we have to think about shifting to mobile platforms​

I think it's a very clear question: why do we have to think about mobile platforms today? Here I just provided some numbers. Of course, it's too hard to measure what people are using, which development tools they are using and I based my numbers on the traffic in the web. Because right now web is everything. Clients generate traffic and based on this I just measured which tools people are using. You can see that in 2010 95% was desktop traffic. In 2015 – it dropped to almost 60 percent. If we're talking about 2019 finally mobile apps traffic won. This information is for April. People got used to mobile apps and they like them. This is why these numbers are so high. Here are exact numbers based on the StatCounter service.

1627813330663.png

How can we develop mobile apps (native, cross-platform, hybrid, progressive web apps)​

Now let's discuss how can we develop mobile apps at all. In Softacom we have experience almost with all of these techniques and we developed commercial apps using all these technologies, techniques, frameworks, and tools. And again, we will discuss pros and cons. I divided all the types of development tools for mobile applications in three parts: native, cross-platform (hybrid), web based. And there is no standard which can tell you that exactly this tool belongs to this type. Now it's a little bit blurred and one tool can belong to two different types.

Let's start with pros of native development. I will talk about XCode and Android Studio. Xcode for iOS, it can be Objective C language or Swift and Android studio like JavaScript, Kotlin for Android.
  • The main advantage is that it has the best speed and performance. They are trying to develop the tool which will be closest to the platform, to the device, to the operation system.
  • Permanent support of newest features and up-to-date documentation. All other tools like cross-platform, hybrid should again implement all these new features in their tools.
  • Publishing to app stores - the typical way of app distribution for people. Cross-platform applications are also published to app stores.
  • But here you're protected hundred percent, it has lower risks during publishing to app stores.
  • Available SDKs from all vendors. If we have any source hardware, third-party services, SDKs - all of these vendors in the first place will develop SDK for native platform: for Xcode and Android Studio, and it's a very good benefit.
1627813386813.png

Cross-platform app development approach​

  • The idea of all these cross-platform tools is a re-usable source code for different platforms. Yes, theoretically you can write some code only once and use it in different platforms. In real life it's not so easy of course. Because different platforms again have different techniques, different nuances which you have to implement in your code. As for UI: sometimes it can be a common UI but sometimes you have to create forms, controls, different versions for each platform.
  • Publishing to app stores. Cross-platform tool creates a native package for the app store: for the Apple App Store and Google Play Market.
  • Possibility to use the same knowledge which you are using for desktop. Because sometimes if we're talking about Delphi we can develop application for desktop and then with FireMonkey import it to the mobile.
  • Better development speed for not very complex apps. Again, because of re-usable code, re-usable UI.
  • And it can be cheaper up to 30-40% compared with native while developing apps for both iOS and Android platforms even if you have different UI and you need time for implementing all necessary SDKs sometimes.
 

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009

Web based apps development approach​

It is a very famous technology nowadays – PWA or progressive web application. It includes a lot of different tools, frameworks. JQuery, Bootstrap, React.js, Angular and so on. App can work everywhere where you can use web browsers. This app really can work on desktop, Mac OS, iOS, Android, Linux – it doesn't matter. It even can work without internet connection. When you are opening the application it can cache the application on your device and using JavaScript it caches a lot of logic, pages, and your application can work even without internet connection. For example, the data retrieval from the web, from the server, theoretically can work without internet connection like regular application. You even will have an icon on your desktop. Possibility to apply the same knowledge which you are using for web development: C#, HTTP/CSS/JavaScript. Update process of your applications is easier. You can change the app HTML/CSS/JavaScript files on the server only once and all users will have this update and the they won't need to update the app in the App Store. If we're talking about native apps, you have to control that your users updated your application, that they use the latest version without the bugs which you fixed.

1627813421047.png

Now cons.​

Today it's not enough to have for example application for iOS or for Android if this is commercial application, not some specific service application. If this is an application for everybody, like e-commerce, you should have this application for both platforms, at least for two platforms: iOS and Android. It will be different tools for different platforms, not reusable source code. You will need different resources and different specialists. Of course, maybe you have a guy who knows Android and iOS, and he can use two different platforms, but anyway, you have to multiply his time for developing two versions of your application. It's not for one person. If we're talking about cross-platform, it can be one guy who can develop your application on all platforms. If we're talking about cross-platform, it's usually not hundred percent platform support. This is what I talked about. For example Delphi. I'm not sure how it is right now, but for example previously it didn’t have a support of some things. For cross-platform SDKs availability is worse than for native tools - like an example, if you need the latest Firebase and Facebook SDKs support, you have to wait or develop it yourself. As I remember, Embarcadero released maybe a couple of days ago Firebase support for Delphi and that’s great but this is just an example. In real life you have hundreds and thousands different SDKs for different third-party providers, integrations for different systems and so on. If we're talking about web-based, you need web hosting. You have to store somewhere your web application or PWA application. It can web hosting or virtual machine which is much more expensive and can have a lot of headache. Limited support of distribution via app stores. I think that's very important because for people it is a typical way: go to App Store to download an application. It is not like “You should go to my website, check this link, open something and the application will be installed”. Sometimes it's a disadvantage. But sometimes you cannot deploy your application according app stores policy. For example, for some industries which are prohibited in app stores. They can develop a portable web application and deploy it via your website and do another architecture. In this case it will be an advantage.

What does Delphi offer us for mobile apps development​

1627813444048.png
Now let's talk about what does Delphi offer us for mobile apps development. It can be different variants, different options. Here I provided only the most popular which we used. We have a lot of experience with such realizations.
  1. The first one is classic – FireMonkey Native while being Cross-platform application. It is an Embarcadero solution.
  2. Next one is web application (which is hosted somewhere on the hosting) plus FireMonkey web browser container. And finally for the app store it will look like native application. You won't open it with web browser. It will become a compiled application which will be installed on your phone and it will work like regular native application.
  3. The third option which we will discuss today is TMS Web Core PWA project.
You can see all these circles which are provided here. It's like an example how it works and which resources will you need for implementation of this techniques. If we're talking about FireMonkey and we will develop iOS application and Android application, for iOS you will need Mac OS, installed Xcode, PAServer from Embarcadero (platform assistant server). Delphi project will connect to MAC, compile your application and your project exactly on Mac OS. And you will have finally an .apk package. It's like applications file for iOS which you can upload to app store using iTunes Connect an application loader from Xcode package. You will need a physical computer with Mac OS, or virtual machine. For Java and Android it's a little bit easier. On the same machine with Delphi you will just compile your application using Java, in the output folder you will have apk package which you can just via browser upload to Google Play market. If we are talking about web app plus FireMonkey it has almost the same process. But you also will need a hosting for your web application. It can be shared hosting or it can be cloud-based hosting like Azure and your web application can be built in any technology you want. It can be ASP.NET, PHP. Communication between your web application and Delphi can be with JavaScript. Delphi has different techniques for this purposes. The third option is TMS Web Core PWA project. In Delphi you will create a specific project which is called TMS Web Core project. It's not like regular VCL FireMonkey project, it's TMS Web Core project and on Delphi machine you will be able to design your application, compile. In the output folder you will have your website and specific files for supporting PWA technology and you will need a hosting like Azure virtual machine or any on premise server. This is like TMS Web Core PWA works.
 

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009

Two options we can choose using Delphi for mobile apps development: FireMonkey Cross-platform framework and TMS WEB Core framework.​

1627813497844.png

FireMonkey Cross-platform framework

Now we will discuss deeper how this FireMonkey works. I am hearing a lot of questions “how a cross-platform application can be native?” Yes, it really can. Because of a FireMonkey architecture and how it works. Delphi compiles FireMonkey project to native packages (.ipa and .apk) for iOS and Android which will be deployed to App Store via iTunes Connect and Google Play Market. Embarcadero is calling such solution Native Apps with Single Codebase. On the next slide I will show how it works using iOS. Both platforms Apple and Android accept the packages like native apps, and they even don't know, I think, that they were compiled not using Xcode and Android Studio. You don't need any additional web application, emulators, virtual machines for running the application. Delphi creates a real native mobile applications using XCode and Java compiler. This is what I have already said.

Let's talk about the pros when we are using FireMonkey. You can use Object Pascal code and Delphi IDE for developing iOS and Android mobile applications. You can use the same source code, the same code base, and UI for both platforms. Sometimes you can use the same UI but sometimes it can be a little bit different. But if compared with the other tools, for example Xamarin, they have common UI but they also have possibility to create different UI. From my experience it is a more popular way. But for Delphi you will have one UI for both platforms. You can use compiler directive for platform-specific code. If you have some platform difference because of course hardware is different, operation system is different, and you have a possibility to use the compiler directive, and in the same procedure write a piece of the code which will belong to different platforms.

1627813529186.png

How does it work? How does it exactly work for iOS? You can see these circles like project life cycle. You're creating FireMonkey Delphi project and add iOS target platform. Then you have to connect Delphi to Mac machine with installed Xcode and Delphi PAServer app. After you establish this connection Delphi compiles the project on the Mac using PAServer and Xcode. PAServer is just an additional application from Embarcadero which helps to communicate Delphi and MacOS. It’s just like a helper for compiling the application using Xcode. And like the result you have compiled .ipa package on the Mac machine in some folder. After that you just can use the XCode Application Loader. Before, of course, you have to prepare the environment for developing your iOS application. You have to perform and finish all your certificates, provisioning profiles… After you made all these steps you can just open Xcode Application Loader, select your .ipa previously compiled with Delphi and upload to iOS. And if everything is okay, add a description and send it to Apple review and after couple of days you can publish your application to App Store.

What about the cons? Of course, FireMonkey does not have 100% of platform support. It is just impossible. A lot of a lot of features which Embarcadero should cover in Delphi and it's a lot of work but maybe not so many people who will use this code because this technology is not too popular. It means, for some functionality available for example from the box for XCode and Android Studio you won't have access for your app. You'll need to learn how to write the wrappers and bridge classes for accessing the missing classes and methods for iOS and Android SDKs. Almost all 3rd-party SDK and API providers have libraries for native platforms, again what I have already said, but for Delphi and FireMonkey it is more like an exception that you will have such support, unfortunately. You will again have to write wrappers and bridge classes for accessing all the SDK methods – this is extra work and your payment for cross-platform benefits.

1627813548705.png
 

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
TMS WEB Core framework

It was about FireMonkey, now let's talk about Web Core technology. A lot of people ask “is it really possible to create progressive web app using Delphi?” Yes, really. TMS WEB Core uses Object Pascal to JavaScript converter and creates PWA application which you can run using cell phone web browser. I mean that you are creating the project, compile it and after that you have a folder with your website which you deploy to the web hosting or cloud. Then you open this application from your web browser on your mobile phone and modern browsers detect that it is not a regular website - this is portable web application. It can remove your status bars, remove your main menu, and give a possibility to add an icon to the home screen of your device. One more advantage of course is that PWA application can have access to the platforms and device hardware. Of course, limited, not 100%, even worse than cross-platform. And, as I said, app will have shortcut and can be opened without internet access with limited functionality. It's again PWA technology like application cached your files and knows how to work on the device without internet connection until you don't need to refresh some data from the server.

1627813616031.png

How does it work? You create Delphi TMS WEB Core project on your machine. You compile it – you will have a folder with HTML5, JavaScript, CSS files. Then you deploy these files to the web server. Then you can open the app using a web browser on the cell phone and the app can have screen shortcut and can start without internet connection. For the first run of course you need internet connection.

Which pros do we have? You can use Delphi IDE for developing progressive web mobile applications using what-you-see-is-what-you-get (WYSIWYG) editor. Later on the next slides I will show you an example how it looks like in the IDE designer and in the real browser. Application is cached to the device and can work offline (in limited mode). If TMS WEB Core components list does not suggest you implement some functionality you can use JavaScript, HTML templates, CSS style files and customize your app whatever you want. TMS WEB Core project supports this possibility. You can use possibilities of Bootstrap and other popular JavaScript frameworks for developing your application. You really don't have to spend a ton of time learning how to work with each platform because it's really one applications with the same UI for different platforms.

1627813633539.png

Here is an example which I prepared. On the left side you can see how the form can look like in the IDE designer. Of course it's not exactly like it will look in the real life, on production because I added different UI implementation inside CSS and HTML and after I'm running it you can see how it can look like with a pretty good background but the UI looks like in the designer. You just can double click the register button, write the code, communicate with server and it will be converted to JavaScript which again will work with some REST API servers and you will have a real application.

1627813666745.png

Which cons do we have? I'd like to add a remark that almost all cons are not about TMS WEB Core product. Almost all of them are about PWA limitations at all. The first one is the problems with the distribution to app stores, especially for Apple App Store and this is the most famous distribution channel for the for the users where they search applications. For creating a rich UI and user experience application you will need a good JavaScript/HTML// CSS knowledge. But usually a lot of people start using PWA because they are already using HTML and JavaScript and they know this technology. PWA is a web browser application and it cannot have access to the hardware on the same level like native code can.

1627813684677.png

Now a couple of words about how you can start with mobile application development using Delphi. I just suggest you to start with this resources. Inside the Delphi GetIt package manager you can find amazing samples of mobile applications, they will explain you how to implement pretty and good-looking forms with different lists, scaling, UI. It has at least six samples. Then you can go to FMX Express. It is a website with a ton of examples and solutions for FireMonkey and I really like this site. For the TMS WEB Core you can explore detailed Developers Guide available after product installation. It's very detailed, with a lot of remarks, explanations how the technology works. And of course you can use Stack Overflow and other popular resources. This is what I can suggest you for the start.