iOS Question Error using simple test library

marcel

Active Member
Licensed User
Hi,

I have created a simple Objective C library to add 2 numbers. Nothing more than that. But for some reason I get error when using the this in my B4I App. The error is Class Not found B4ITestLib??

Steps I did:
1) Create a static library, called B4ITestLib
2) Create a method AddNumbers that return the value of Left+Right
3) Create the xml file using "java -jar B4Ih2xml.jar TestLib.h TestLib.xml"
4) Create a test program, copy the TestLib.cml to the libraries directory and use the lib in B4I
5) When running the program I get the error in the log : Class Not found B4ITestLib

I have attached the project and the xml file.

What is wrong?

Thanks for helping me here....
 

Attachments

  • TestLib.zip
    16.1 KB · Views: 150
  • TestLib.xml
    801 bytes · Views: 146

marcel

Active Member
Licensed User
But the complete project file is attached in the zip. But I have attached the .a file in zip as well.
 

Attachments

  • libTestLib.a.zip
    1.9 KB · Views: 154
Last edited:
Upvote 0

marcel

Active Member
Licensed User
Thanks!! :) it is working now. I had the settings correct but some how it did not compile for the correct architecture. So I have now created a RakeFile and successfully build a fat library file. I am not sure the simulator is needed but maybe for the feature..

See example:

B4X:
def xcodebuild(sdk, archs, iphoneos_deployment_target, products_dir)
  sh "xcodebuild -project 'iTestFlight.xcodeproj' -configuration 'Release' -sdk '#{sdk}' clean build ARCHS='#{archs}' VALID_ARCHS='#{archs}' IPHONEOS_DEPLOYMENT_TARGET='#{iphoneos_deployment_target}' TARGET_BUILD_DIR='#{products_dir}' BUILT_PRODUCTS_DIR='#{products_dir}'"
end

desc "Build arm"
task :build_arm do
  xcodebuild('iphoneos8.1', 'armv7 armv7s', '5.0', 'build-arm')
end

desc "Build arm64"
task :build_arm64 do
  xcodebuild('iphoneos8.1', 'arm64', '7.0', 'build-arm64')
end

desc "Build i386"
task :build_i386 do
  xcodebuild('iphonesimulator8.1', 'i386', '5.0', 'build-i386')
end

desc "Build x86_64"
task :build_x86_64 do
  xcodebuild('iphonesimulator8.1', 'x86_64', '7.0', 'build-x86_64')
end

desc "Build fat"
task :build_fat => [:build_arm, :build_arm64, :build_i386, :build_x86_64] do
  sh "lipo -create ./build-arm/libiTestFlight.a ./build-arm64/libiTestFlight.a ./build-i386/libiTestFlight.a ./build-x86_64/libiTestFlight.a -output libiTestFlight.a"
end

desc "Clean"
task :clean do
  sh 'rm -rf build*'
end

desc "Clean binary"
task :distclean => [:clean] do
  sh 'rm -rf libiTestFlight.a'
end

task :default => [:distclean, :build_fat]

So my test flight lib is working now :) I will post it in the weekend after good testing.
 
Last edited:
Upvote 0

marcel

Active Member
Licensed User
From my experience if a device is not connected to the Mac then Xcode ignores the build settings and creates a x86 binary.
Correct but if you hook up your device (I have a 4s) it generates only arm7. So that is the reason I do it like this.
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Erel,

I put the lipo command like your post, but not work! And the iPhone 6 connected in a MAC.

I closed my xcode before execute lipo command.

Look the result after command:


AlbertoesiasMBP:Libs iglesias$ lipo -i *.a
Architectures in the fat file: libCore.a are: arm64 armv7
input file libMQTTKit.a is not a fat file
Architectures in the fat file: libiAd.a are: armv7 arm64
Architectures in the fat file: libiAdMob.a are: armv7 arm64
Architectures in the fat file: libiArchiver.a are: armv7 arm64
Architectures in the fat file: libiBLE.a are: armv7 arm64
Architectures in the fat file: libiBarcode.a are: armv7 arm64
Architectures in the fat file: libiDebug.a are: armv7 arm64
Architectures in the fat file: libiDesigner.a are: armv7 arm64
Architectures in the fat file: libiDropboxSync.a are: armv7 arm64
Architectures in the fat file: libiEncryption.a are: armv7 arm64
Architectures in the fat file: libiGoogleMaps.a are: armv7 arm64
Architectures in the fat file: libiHUD.a are: armv7 arm64
Architectures in the fat file: libiHttp.a are: armv7 arm64
Architectures in the fat file: libiJSON.a are: armv7 arm64
Architectures in the fat file: libiLeadbolt.a are: armv7 arm64
Architectures in the fat file: libiLocation.a are: armv7 arm64
input file libiMQTT.a is not a fat file
Architectures in the fat file: libiMedia.a are: armv7 arm64
Architectures in the fat file: libiNet.a are: armv7 arm64
Architectures in the fat file: libiNetwork.a are: armv7 arm64
Architectures in the fat file: libiPhone.a are: armv7 arm64
Architectures in the fat file: libiRandomAccessFile.a are: armv7 arm64
Architectures in the fat file: libiSQL.a are: armv7 arm64
Architectures in the fat file: libiSideMenu.a are: armv7 arm64
Architectures in the fat file: libiStore.a are: armv7 arm64
Architectures in the fat file: libiStringUtils.a are: armv7 arm64
Architectures in the fat file: libiWebSocket.a are: armv7 arm64
Architectures in the fat file: libiXmlBuilder.a are: armv7 arm64
Architectures in the fat file: libiXmlSax.a are: armv7 arm64
Non-fat file: libMQTTKit.a is architecture: arm64
Non-fat file: libiMQTT.a is architecture: arm64
AlbertoesiasMBP:Libs iglesias$


The questions are:

1) Why in debug mode, I can compile and run perfectly and release no?
2) Look the libraries libMQTTkit.a and libiMQTT.a (this is my library, wrapper the first one) . both without armv7, is normal?

Thanks
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Erel, Finally I FOUND THE ERROR!!!!!!!!!!


The problem is not in my Library compilation

The problem is in compilation of wrapper library, this one!

https://github.com/mobile-web-messaging/MQTTKit

And them I re-compile with both architecture, and then re-compile my library, and then WORKS!

Thanks for yout tip!

Alberto Iglesias
 
Last edited:
Upvote 0
Top