iOS Question Compile To Library creates incomplete B4iProject output

b4x-de

Active Member
Licensed User
Longtime User
I am trying to compile a large B4i project as a library with Compile To Library in B4i 10.00 using the local builder.

The same source code compiles when the project is built as a normal application. The problem only appears when compiling it as a library provider.

The project contains many source modules. All modules are listed in the .b4i project file with ModuleN entries. The project has about 170 library / module entries.

When the library compile fails, the generated folder:

B4X:
Objects/src/B4iProject

contains only one generated class, for example:

B4X:
b4i_classa.h
b4i_classa.m

ClassA uses ClassB, ClassC and ClassD in its B4X source code. These classes are also listed as ModuleN entries in the same .b4i project file. However, after the failed Compile To Library run, the corresponding generated files are missing:

B4X:
b4i_classb.h / .m
b4i_classc.h / .m
b4i_classd.h / .m

The generated header for ClassA contains forward declarations for these classes, for example:

B4X:
@class b4i_classb;
@class b4i_classc;
@class b4i_classd;

but the actual generated implementation files for these modules are not created.

After that, B4i reports what looks like a B4X syntax error in valid code.

Example 1:

B4X:
B4i Version: 10.00
Parse den Code.    (6.04s)
Building folders structure.    (0.06s)
Führe individuellen Aktion aus.    (9.14s)
Führe individuellen Aktion aus.    (0.14s)
Kompiliere den Code.    Error
Fehler beim Kompilieren des Programms.
Fehlerbeschreibung: ',' erwartet.
Fehler in Zeile: 528
objSubject = CallSub(mObject, "getSomeValue")
Word: )

Example 2 from another compile attempt:

B4X:
B4i Version: 10.00
Parse den Code.    (5.15s)
Building folders structure.    (0.01s)
Führe individuellen Aktion aus.    (15.77s)
Führe individuellen Aktion aus.    (0.95s)
Kompiliere den Code.    Error
Fehler beim Kompilieren des Programms.
Fehlerbeschreibung: '(' erwartet.
Fehler in Zeile: 270
objClassB.Initialize
Word: initialize

In both cases the B4X code and also the generated Objective-C code for the second example looks normal:

B4X:
_objclassb = [b4i_classb new];
[_objclassb _initialize /*NSString**/ :self.bi];

So the generated code for ClassA looks reasonable, but the generated project appears to be incomplete because the other modules are not generated.

I also enabled the IDE log mode and checked the generated log.txt. Unfortunately it did not contain a clear hint about the real cause. The only suspicious parts were entries like:

B4X:
CompilingManager: not ready
Macro
Build modules tree: 37
Building folders structure.
System.Exception: Fehler beim Kompilieren des Programms.
Fehlerbeschreibung: ',' erwartet.
...

The project might be a little bigger and complex than average projects. It uses macros before compilation to switch environment-specific internal libraries and refresh the Libraries tab. I also clean the project before compiling. Still, the failure appears as if the module tree used by Compile To Library is incomplete or inconsistent.

I would appreciate help understanding what could cause Compile To Library to generate only one b4i_classa.h/.m file although the other modules are listed in the project file and the same source code compiles as a normal application.

It would also appreciate help to get more details about the internal build process of Compile To Library: at which stage are the ModuleN entries resolved, when is the module tree built, and under which conditions can B4i stop after generating only a partial Objects/src/B4iProject folder?

Thanks,
Thomas
 

b4x-de

Active Member
Licensed User
Longtime User
Thank you for looking into this.

I tried to create a small reproducible example project, but unfortunately the issue is very hard to reproduce in a deterministic way. In a simplified test project, the problem only occurred two or three times out of about fifty compilation attempts.

So at the moment it looks like the generated output in small projects is not consistently incomplete, but rather that the issue appears intermittently. This makes it difficult to provide a minimal project that reliably demonstrates the problem.

However, while testing this, I noticed three concrete things that might help to narrow it down:

  1. The issue might be related to the already known includesSingletonModules="true" problem, especially in cases where the generated files were not updated consistently, the Libraries tab was not refreshed correctly, or the project was not cleaned before compiling again.

  2. In very rare cases, the generated XML file for a referenced library did not contain includesSingletonModules="true", although this attribute is normally always present for that library. Instead, the library was included as a normal dependsOn dependency.


  3. Several times, although again not in a reliably reproducible way, the library build failed with the following error:

    B4X:
    error: include of non-modular header inside framework module 'TestProjectB'

I am not sure whether all of these observations are caused by the same underlying issue, but they appeared while trying to reproduce the incomplete B4iProject output. I hope this helps a little in narrowing down the problem. Of course, I would be happy to provide more details if that would be useful.
 
Upvote 0
Top