Other [new feature] b4xlib - a new type of library

Erel

B4X founder
Staff member
Licensed User
Longtime User
As B4X matures, more and more reusable components are written in B4X directly.
In most cases it is simpler to implement the logic in B4X directly and the code can be cross platform. Especially with the relatively new XUI library.

Standard libraries will never be cross platform as they are compiled to the platform native binary / bytecode. They also have other restrictions related to them being compiled.

Starting with B4A (8.80), B4i (v5.50), B4J (v7.00) and B4R (v3.50), a new type of libraries is available - b4x libraries.

A b4x library is a simple zip file with:

- Code modules. All types are supported including activities and services.
- Files, including layout files.
- Optional manifest file with the following fields:
Version, DependsOn (list of required libraries), Supported Platforms. Fields can be shared between the platforms or be platform specific. For example:
B4X:
Version=2.00
B4J.DependsOn=jXUI, jDateUtils
B4A.DependsOn=XUI, DateUtils
B4i.DependsOn=iXUI, iDateUtils

Files and code modules can also be platform specific.

Creating a b4x library is very simple. You just need to create a zip file with these resources. The zip file extension should be b4xlib. That's all.

Note that the source code can be extracted from a b4x library.

b4x libraries appear like all other libraries in the Libraries tab.

Example of AnotherDatePicker custom view packaged as a b4x library is attached. It is cross platform and using it is a matter of clicking on the library in the list of libraries.
 

Attachments

  • AnotherDatePicker.b4xlib
    9 KB · Views: 4,564
Last edited:

DonManfred

Expert
Licensed User
Longtime User
!!! W-O-W !!! I like it! ;-)
 
Upvote 0

ocalle

Active Member
Licensed User
Longtime User
This is going from best to best, congratulations.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I can forsee a major potential problem.
If I understand correctly, any given user can simply unzip and play around with the code modules... If by doing so, the code gets broken, how can the "library" creator give support?
This also means that B4X libs cannot be neither paid neither donation ware!(?)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Erel can always encrypt the source files inside these libs to offer some sort of 'protection'.
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
Yes, finally; as well as all the code you find on GitHub is free!

Who wants to continue to earn "creating" libraries can always keep doing it for specific languages.

Alternatively you give the library away but charge for support.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
@Erel, as you can see in this few coments, it will be a lots of requests for offer support for some kind of encription. Can you add this? An option in the IDE to "Encrypt B4X library", ask for a password, so the same developper can decrypt it, but can be distributed without having to share the code.
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
@Erel, as you can see in this few comments, it will be a lots of requests for offer support for some kind of encryption. Can you add this? An option in the IDE to "Encrypt B4X library", ask for a password, so the same developer can decrypt it, but can be distributed without having to share the code.
I think that the B4X Library feature will be a great enhancement to the B4X system. I'm in agreement with @ivan.tellez in that the code should be encrypted to protect the developer's investment and ability to support the library. I would also recommend that not only code be encrypted but all files (db and xls for example) be encrypted as well. In many cases, the data files embedded within the library ZIP can also be proprietary to the developer and/or the operation of library depends upon an unmodified known state of the data files.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I think this is a very good feature.
There are so many old libraries in this forum that the developer don't give support and it is outdated (and I can't try to fix the problems).
I think so this is not the only way to create libraries and If you want to create a library or wrap and sold/give support, you can use the old ways.
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
I think this is a very good feature.
There are so many old libraries in this forum that the developer don't give support and it is outdated (and I can't try to fix the problems).
I think so this is not the only way to create libraries and If you want to create a library or wrap and sold/give support, you can use the old ways.
I think you are missing the point for this newly proposed B4X Library. This library is intended as a cross-platform library. Yes, the old way works but it has its limitations.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This library is intended as a cross-platform library

Cross platform is a very important advantage however it is not the only one. Other advantages:
- Can include files and layout files.
- Very simple to create.
- Supports activities and services.
- Libraries code can directly call external subs.
- Conditional compilation is supported.
- Source code is available for the developer who uses the library. Note that you can set any license that you like for the code.

Encryption might be added in the future. It cannot be encrypted with a global key. Each encrypted library will have its own password.

There are also advantages to the compiled libraries:

- Can be referenced from native libraries. This is not possible with B4X libraries.
- Source code not available.
 
Upvote 0
Top