Bug? Compile To Library fails with legacy iRSA library, while normal app build works on B4i 10.00

b4x-de

Active Member
Licensed User
Longtime User
Hi,

first of all: thank you for the continuous work on B4i and the Build Server. The move to the newer build infrastructure and xcframework-based libraries is a big step forward. I am reporting this because I think I found a small inconsistency in the native-library build flow that might be useful to improve.

I have a B4i project that references iRSA.

The normal B4i app build works correctly. The same library setup is accepted and iRSA is resolved without problems.

However, when I use the Compile To Library feature for the same project, the build fails during the Xcode / libtool step.

B4X:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool \
-static \
-arch_only arm64 \
-D \
-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.1.sdk \
-L/Users/user1/Build/B4iBuildServer_v10-00/UploadedProjects/<user id>/build/Release-iphoneos \
-filelist /Users/user1/Build/B4iBuildServer_v10-00/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/b4i-example.build/Objects-normal/arm64/b4i-example.LinkFileList \
-framework Foundation \
-framework CoreGraphics \
-framework UIKit \
-framework iArchiver \
-framework iCore \
-framework iDateUtils \
-framework iEncryption \
-framework iRandomAccessFile \
-liRSA \
-framework iStringUtils \
-framework iXmlBuilder \
-framework iXmlSax \
-framework AVFoundation \
-o /Users/user1/Build/B4iBuildServer_v10-00/UploadedProjects/<user id>/build/Release-iphoneos/b4i-example.framework/b4i-example

This error message is shown:

B4X:
error: libtool: can't locate file for: -liRSA
error: libtool: file: -liRSA is not an object file (not allowed in a library)
Command Libtool failed with a nonzero exit code

The Build Server Libs folder contains the legacy iRSA files:

B4X:
iRSA.h
iRSA.xml
libiRSA.a

This does not seem to be a general problem with iRSA, because the normal app build handles it correctly.

The problem appears only in the Compile To Library build flow. In that flow, libtool is called with -liRSA, but the relevant library search path only points to the generated project output folder:

B4X:
-L.../UploadedProjects/<user id>/build/Release-iphoneos

It does not seem to include the Build Server Libs folder where libiRSA.a is located. Therefore libtool cannot resolve -liRSA.

As a workaround, I was able to build the library manually by copying libiRSA.a into the generated build/Release-iphoneos folder and then running the Xcode build manually with suitable search paths.

If the normal B4i app build supports a legacy static library such as iRSA, then Compile To Library should either:
  1. resolve the same library from the Build Server Libs folder, or
  2. copy the required .a file into the generated build output folder, or
  3. otherwise handle the dependency in the same way as the normal app build.

Because the normal app build works, but Compile To Library fails because libtool cannot locate libiRSA.a. So I think this is a bug or at least an inconsistency in the Compile To Library build process when legacy .a libraries are involved.

I hope this report is useful. My intention is to help identify a small edge case in an otherwise very useful feature.
 

b4x-de

Active Member
Licensed User
Longtime User
This is the workaround I used for now:

I was able to work around the problem by manually rebuilding the generated Xcode project after the failed Compile To Library attempt.

The important point was to make libiRSA.a visible to the libtool step that creates the native library.

The generated command only had this library search path:

B4X:
-L/Users/user1/Build/B4iBuildServer_v10-00/UploadedProjects/<user id>/build/Release-iphoneos

However, libiRSA.a was located here:

B4X:
/Users/user1/Build/B4iBuildServer_v10-00/Libs/libiRSA.a

So the workaround does two things:

  1. Copy libiRSA.a into the generated build output folder.
  2. Run xcodebuild manually with explicit library and framework search paths.

Example:

B4X:
PROJECT_ROOT="/Users/user1/Build/B4iBuildServer_v10-00/UploadedProjects/<user id>"
BUILD_SERVER_ROOT="/Users/user1/Build/B4iBuildServer_v10-00"
LIBS_DIR="$BUILD_SERVER_ROOT/Libs"
RELEASE_DIR="$PROJECT_ROOT/build/Release-iphoneos"
TARGET_NAME="b4i-example"

mkdir -p "$RELEASE_DIR"

cp "$LIBS_DIR/libiRSA.a" "$RELEASE_DIR/libiRSA.a"

xcodebuild \
  -project "$PROJECT_ROOT/B4iProject.xcodeproj" \
  -target "$TARGET_NAME" \
  -configuration Release \
  -arch arm64 \
  ENABLE_BITCODE=NO \
  LIBRARY_SEARCH_PATHS="$RELEASE_DIR $LIBS_DIR" \
  FRAMEWORK_SEARCH_PATHS="$LIBS_DIR $LIBS_DIR/Extra $RELEASE_DIR"

The critical corrections are these:

B4X:
cp "$LIBS_DIR/libiRSA.a" "$RELEASE_DIR/libiRSA.a"

This makes -liRSA resolvable because libtool already searches build/Release-iphoneos.

And:

B4X:
LIBRARY_SEARCH_PATHS="$RELEASE_DIR $LIBS_DIR"
FRAMEWORK_SEARCH_PATHS="$LIBS_DIR $LIBS_DIR/Extra $RELEASE_DIR"

This makes both the generated output folder and the Build Server library folders available to Xcode during the manual build.

After that, the native framework can be built successfully. I then created an .xcframework from the generated framework and installed the result into the Build Server Libs folder using the same structure as the other B4i 10 libraries:

B4X:
/Users/user1/Build/B4iBuildServer_v10-00/Libs/b4i-example.xcframework/
/Users/user1/Build/B4iBuildServer_v10-00/Libs/b4i-example.xml

So the workaround is not a change to the B4i source project itself. It only corrects the native Xcode build environment after B4i has generated the Xcode project.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…