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,297
Last edited:

Chris Lee

Member
Licensed User
This is obviously useful in certain scenarios such as release of a library to the forum, but it won't save time during the development stage?

I've got a lot of code in multiple libraries across different platforms and I'm constantly updating them. So I have to jump into the different IDEs to fix up and rebuild the equivilent libraries. I was thinking this might help save time but unless I script up something to create the zip files it won't help. Even if I do that I won't know if my code is valid until it's in a given environment.

I know I can script the compilation already using B4JBuilder etc but I typically end up in the IDE anyway because adding a code file to a library in B4J won't add the same file to the B4A library.

It will be great to have single library files from the forum that I can drop into all environments but I don't think this will make a practical impact on my daily development without an easy way to compile from one IDE into multiple environments.

Not trying to be negative, I just don't see much practical benefit for my use case.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I find this feature very useful for development of cross platform libraries. I do create a batch file for most b4x libs that builds the library and copies it to the three additional libraries folders. It is much simpler than compiling three projects after each change.
It also supports features that are not supported in regular libraries such as:
- Files and layout files.
- High level referenced libraries.
- The modules code doesn't need to be compiled on its own.
- Last but not least there are many cases where the fact that the source code is included is an advantage.

Libraries such as XUI Views, X2 (games) and others cannot be created and maintained without this feature.
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Where is the best place to locate this libs? B4A Internal Libraries AND B4J Internal Libraries, or inside additional libs folder, to share between both platforms?
Thanks!
 
Upvote 0

Scotter

Active Member
Licensed 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.
...
I'm looking for the B4X XUI Views (so I can do special cross-platform combo boxes/spinners in my B4A projects) library that you reference from a few places but... no where seems to be a link directly to download the actual library file. I've clicked all of the links I can find here and none seem to be the library file. "AnotherDatePicker" doesn't seem to be what I'm looking for. Thanks.
 
Upvote 0

Scotter

Active Member
Licensed User
Seems quite simple to find it.
Search: https://www.b4x.com/search?query=xui+views
The library is attached to the first post.
Thanks for dealing with my confusion! I know you are busy and this is relatively value-less/time-wasting stuff that is probably my fault for not being observant enough.
Please indulge me here in case there is a chance that others are encountering what I am.
Please watch the steps I take following your search because it doesn't seem to lead me to the download of that library:
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hello @Scotter,
I'm not sure how you missed it but the library and example is at the bottom of the first post Scott.

Right download called 'XUI Views.b4xlib'
Untitled-2.png


Enjoy...
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I have a question. Suppose the module is only one, then written B4X.
It would not be necessary to create an xml.

Where does the module version come from?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Ok, I understood that the manifest was xml.
So the manifest is optional, but you would not know the version if it were not there

Now it's clear to me, thank you
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Just wondering if in the future the IDEs could somehow detect the modules included in the B4Xlib and give a warning if a module not meant for that IDE is not compatible.
For instance, yesterday a user apparently put a B4XLib meant for B4A in the additional library folder of B4J and an error only appeared while he tried to compile the project. Preferably there would be a warning while adding the B4XLib to the the project.

For instance, when developing my client B4XLibs libraries for my latest project B4XIDEViewer, I only managed to have the same modules working together for B4i and B4J and thus I was able to create one B4XLib which is OK for B4i and B4J. However, I was not able to add the modules for B4A, maybe because I am using a service, and I had to make a separate B4XLib (maybe it is possible but then I haven't understood how to do it). In this case, it could be useful if we could put some information in the manifest instructing the IDE to ignore modules not pertaining to a specific IDE. In this way, we could include various code-modules independently of platform and still use only one B4XLib for distributing it.

Maybe this is already possible? If yes, how would this be done?
 
Upvote 0
Top