iOS Tutorial [Objective C] Writing libraries for B4i

Alberto Iglesias

Well-Known Member
Licensed User
I try:

Dim no As NativeObject = objCombo
objCombo.colorBorder = no.ColorToUIColor(Colors.Magenta)


and

Dim no As NativeObject
objCombo.colorBorder = no.ColorToUIColor(Colors.Magenta)



But not working!

In the objective side I have:
@property (nonatomic, readwrite)UIColor* colorBorder;



and the Error is:

Sending data to remote compiler. Error
B4i line: 40
objCombo.colorBorder = no.ColorToUIColor(Colors.Magenta)
no visible @interface for 'B4IComboBox' declares the selector 'setcolorBorder:'



[self._objcombo setcolorBorder:[_no ColorToUIColor:[[self.__c Colors] Magenta]]];
~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~
 

Haris Hafeez

Active Member
Licensed User
Hello All,

Do we need to copy all the .h files that our library needs to the folder where the B4IH2XML tool can find them? If I have a third party library, which files from that library does the B4iH2xml tool need?

I'm getting the following error when using the tool to create xml. I have got all the .h files in the folder where I'm executing it.

B4X:
parser._parsetype (java line: 695)
java.lang.NullPointerException
    at b4j.example.parser._parsetype(parser.java:695)
    at b4j.example.parser._parsemethod(parser.java:527)
    at b4j.example.parser._parseline(parser.java:433)
    at b4j.example.parser._parseh(parser.java:290)
    at b4j.example.parser._parseimport(parser.java:315)
Thanks.
 
Last edited:

Haris Hafeez

Active Member
Licensed User
Sorry I forgot to mention that I have created a wrapper that I'm passing to the xml tool.
So in light of this, do I need to put all the header files that my wrapper is using as well as the header files that the wrapped library itself is referencing?
 

Haris Hafeez

Active Member
Licensed User
You only need to convert the h file created for the wrapper.
That's exactly what I did. I ran the command line tool passing it the name of my .h file and the output .xml file but as you can see from the stack trace above, it's trying to read the imports. The tool failed with a file not found exception when I hadn't copied the header file used by the wrapper.

Is there a way to turn the log on for the h2xml tool?

Thanks.
 

Haris Hafeez

Active Member
Licensed User
UPDATE: My bad. I think what I failed to realise was that in order to build a library, anything that is exposed outside of our wrapper header file needs to be a wrapped type.
I was directly using a delegate in the header file which was causing the issues.

I still have some testing to do so hopefully...
 
Last edited:

Alberto Iglesias

Well-Known Member
Licensed User
Erel,

I´m creating another library for iOS, but this on depend of external library, so, I just put the dependencies on .H like instructions but not working, like this:

I try

//~dependson:libetpan-ios (without extension)

and

//~dependson:libetpan-ios.a (with extension)


This library is in B4i-MacServer/Libs in my server


When I compile I got this error


Ld Payload/POP3SAMPLE.app/POP3SAMPLE normal arm64
cd /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/iglesias/bin/Sencha/Cmd/3.1.0.192:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/iglesias/Development/sdk/platform-tools:/Users/iglesias/Development/sdk/tools"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -L/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload -L../../Libs -F/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload -F../../Libs -filelist /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/POP3SAMPLE.LinkFileList -ObjC -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.0 -lCore -framework Foundation -framework CoreGraphics -framework UIKit -lpop3 -framework AVFoundation -llibetpan-ios -liDebug -Xlinker -dependency_info -Xlinker /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/POP3SAMPLE_dependency_info.dat -o /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/POP3SAMPLE.app/POP3SAMPLE
ld: library not found for -llibetpan-ios


BTW: In my test with this library in another project directly in XCODE works perfectly (it´s in Build Phases->Link Binary With Libraries)


Thanks



Alberto Iglesias
 

Alberto Iglesias

Well-Known Member
Licensed User
OK, this step is ok now, but after this I have this problem when compiling:

In a simple test building a app calling my library (in XCODE), its working perfectly!


Parsing code. 0.06
Compiling code. 0.33
Compiling layouts code. 0.11
Compiling debugger engine code. 2.82
Building Xcode project 0.40
Sending data to remote compiler. Error
Error: security: SecKeychainDelete: The specified keychain could not be found.
Out: Build settings from command line:
ARCHS = arm64
CODE_SIGN_IDENTITY = iPhone
CONFIGURATION_BUILD_DIR = /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload
OTHER_CODE_SIGN_FLAGS = --keychain iglesias
PRODUCT_NAME = POP3SAMPLE
PROVISIONING_PROFILE = 8fe2061a-8243-496c-8daa-118492f5bb7d
=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===
Check dependencies
warning: all apps should include an armv7 architecture (current ARCHS = "arm64").
Write auxiliary files
/bin/mkdir -p /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/POP3SAMPLE.LinkFileList
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-own-target-headers.hmap
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-project-headers.hmap
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-all-target-headers.hmap
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-all-non-framework-target-headers.hmap
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE.hmap
write-file /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-generated-files.hmap
Create product structure
/bin/mkdir -p /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/POP3SAMPLE.app
ProcessInfoPlistFile Payload/POP3SAMPLE.app/Info.plist B4iProject/B4iProject-Info.plist
cd /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/iglesias/bin/Sencha/Cmd/3.1.0.192:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/iglesias/Development/sdk/platform-tools:/Users/iglesias/Development/sdk/tools"
builtin-infoPlistUtility /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/B4iProject/B4iProject-Info.plist -genpkginfo /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/POP3SAMPLE.app/PkgInfo -expandbuildsettings -format binary -platform iphoneos -o /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/POP3SAMPLE.app/Info.plist
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.o B4iProject/main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/iglesias/bin/Sencha/Cmd/3.1.0.192:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/iglesias/Development/sdk/platform-tools:/Users/iglesias/Development/sdk/tools"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/7x/k042sg513nj8fzpf3cr7r64m0000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-generated-files.hmap -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-own-target-headers.hmap -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-all-target-headers.hmap -iquote /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-project-headers.hmap -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload -F../../Libs -MMD -MT dependencies -MF /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.d --serialize-diagnostics /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.dia -c /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/B4iProject/main.m -o /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/main.o
CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o B4iProject/b4i_main.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/iglesias/bin/Sencha/Cmd/3.1.0.192:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/iglesias/Development/sdk/platform-tools:/Users/iglesias/Development/sdk/tools"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch arm64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/7x/k042sg513nj8fzpf3cr7r64m0000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -fvisibility=hidden -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-generated-files.hmap -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-own-target-headers.hmap -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-all-target-headers.hmap -iquote /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/POP3SAMPLE-project-headers.hmap -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/arm64 -I/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload -F../../Libs -MMD -MT dependencies -MF /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.d --serialize-diagnostics /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.dia -c /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/B4iProject/b4i_main.m -o /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/b4i_main.o
Ld Payload/POP3SAMPLE.app/POP3SAMPLE normal arm64
cd /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/iglesias/bin/Sencha/Cmd/3.1.0.192:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/Users/iglesias/Development/sdk/platform-tools:/Users/iglesias/Development/sdk/tools"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -L/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload -L../../Libs -F/Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload -F../../Libs -filelist /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/POP3SAMPLE.LinkFileList -ObjC -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.0 -lCore -framework Foundation -framework CoreGraphics -framework UIKit -lpop3 -framework AVFoundation -letpan-ios -liDebug -Xlinker -dependency_info -Xlinker /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/arm64/POP3SAMPLE_dependency_info.dat -o /Users/iglesias/Development/B4i-MacServer/UploadedProjects/iglesias/Payload/POP3SAMPLE.app/POP3SAMPLE
Undefined symbols for architecture arm64:
"_deflate", referenced from:
_mailstream_low_compress_write in libpop3.a(mailstream_compress.o)
"_deflateEnd", referenced from:
_mailstream_low_compress_open in libpop3.a(mailstream_compress.o)
_mailstream_low_compress_free in libpop3.a(mailstream_compress.o)
"_deflateInit2_", referenced from:
_mailstream_low_compress_open in libpop3.a(mailstream_compress.o)
"_inflate", referenced from:
_mailstream_low_compress_read in libpop3.a(mailstream_compress.o)
"_inflateEnd", referenced from:
_mailstream_low_compress_open in libpop3.a(mailstream_compress.o)
_mailstream_low_compress_free in libpop3.a(mailstream_compress.o)
"_inflateInit2_", referenced from:
_mailstream_low_compress_open in libpop3.a(mailstream_compress.o)
"_sasl_client_init", referenced from:
_mailsasl_ref in libpop3.a(mailsasl.o)
"_sasl_client_new", referenced from:
_mailpop3_auth in libpop3.a(mailpop3.o)
"_sasl_client_start", referenced from:
_mailpop3_auth in libpop3.a(mailpop3.o)
"_sasl_client_step", referenced from:
_mailpop3_auth in libpop3.a(mailpop3.o)
"_sasl_decode64", referenced from:
_mailpop3_auth in libpop3.a(mailpop3.o)
"_sasl_dispose", referenced from:
_mailpop3_free in libpop3.a(mailpop3.o)
_mailpop3_auth in libpop3.a(mailpop3.o)
"_sasl_encode64", referenced from:
_mailpop3_auth in libpop3.a(mailpop3.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error: 2015-08-14 06:59:33.790 xcodebuild[32036:696636] [MT] PluginLoading: Required plug-in compatibility UUID 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CLITool+InfoPlist.xcplugin' not present in DVTPlugInCompatibilityUUIDs
** BUILD FAILED **

The following build commands failed:
Ld Payload/POP3SAMPLE.app/POP3SAMPLE normal arm64
(1 failure)
 

Alberto Iglesias

Well-Known Member
Licensed User
I trie, my library and the dependency libraries have a arm64 arch, look:

Alberto-Iglesias-MacBook-Pro:B4i-MacServer iglesias$ lipo -info /Users/iglesias/Development/B4i-MacServer/Libs/libpop3.a
Architectures in the fat file: /Users/iglesias/Development/B4i-MacServer/Libs/libpop3.a are: armv7 arm64
Alberto-Iglesias-MacBook-Pro:B4i-MacServer iglesias$

Alberto-Iglesias-MacBook-Pro:B4i-MacServer iglesias$
Alberto-Iglesias-MacBook-Pro:B4i-MacServer iglesias$ lipo -info /Users/iglesias/Development/B4i-MacServer/Libs/libetpan-ios.a
Architectures in the fat file: /Users/iglesias/Development/B4i-MacServer/Libs/libetpan-ios.a are: armv7 arm64
Alberto-Iglesias-MacBook-Pro:B4i-MacServer iglesias$



Question: Can I send to you my library source code to you can check this strange behavior?
 
Top