Import RTLabel in Oxygen for Cocoa

Hello,
for my project I need a label with different colored text passages inside. So I found [RTLabel][1] what stands for “Rich Text Label”.

Then I tried to import the library with the following script:

iOSSdkVersion="7.1";
processiOSLibrary({
  library: "libRTLabel",
  headers: ["RTLabel.h"],
  includePaths: ["/Users/Benny/Desktop/RTLabel"],
  includeFX: ["/Users/Benny/Desktop/RTLabel/SDK/iOS 7.1/UIKit.fx",
             "/Users/Benny/Desktop/RTLabel/SDK/iOS 7.1/CoreText.fx"],
  architectures: [architecture_iOS_armv7, architecture_iOS_armv7s, architecture_iOS_arm64],
  explicitHeaders: true,
  dummy: null
});

Back on Visual Studio I get an error when trying to compile the project:

Error    9    (Link) Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_RTLabel", referenced from:
      objc-class-ref in Showcase.o
ld: symbol(s) not found for architecture armv7

    C:\Program Files (x86)\MSBuild\RemObjects Software\Oxygene\RemObjects.Oxygene.Nougat.targets    329    5    Showcase

Do you know what I’m doing wrong?

Best regards
Benny

RTLabel-master.zip (809.5 KB)
[1]: https://github.com/honcheng/RTLabel

make sure to include “RTLabel” in the Libraries to Link field. Else the library will never get passed to the linker.

What do you mean? That I need to add link: ["RTLabel"] to the FxGen script?

Okay, I changed the script and everything seems to be correct.
But as soon as my project contains a line like this

var passage: RTLabel:= RTLabel.alloc.initWithFrame(CGRectMake(x, y, width, height));

I will get the aforesaid error.
Have a look at the files: RTLabel.zip (140.4 KB)

I think its

var RTLabel := new RTLabel withFrame(CGRectMake(x, y, width, height));

There is this page on the wiki but its missing, I don’t know why

http://www.elementswiki.com/en/Constructors_and_"init*"_Methods

should be fine too.

If it still gives the same error as above, “symbol(s) not found” then something is wrong with the import. either it’s still not passing the library to link, or maybe you’re referencing the wrong version (iOS Sim?) of the binary?

[quote=“mh, post:6, topic:4654”]
either it’s still not passing the library to link
[/quote]Mhm, I wouldn’t know what I should do differently. As you can see in the zip file, every needed file is present.
Here you can see a screenshot of FxGen

Not that I know of.

can you remove the 'lib" from the library name (in the edit box)? make sure the fx is called libRTLLabel.fx and put libRLTLabel.a next to it?

That should not matter, that name only drives the output name. for the fx.

Can you post the full LD command line, as it shows in the Detailed build log? does it contain

-lRTLabel

and

-L/path/to/libRTLabel.a

?

Here is the full log:

Error    22    (Link) ld: warning: ignoring file ./Debug/iOS/Link//Libraries/libRTLabel.a, file was built for archive which is not the architecture being linked (armv7): ./Debug/iOS/Link//Libraries/libRTLabel.a
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_RTLabel", referenced from:
      objc-class-ref in Showcase.o
ld: symbol(s) not found for architecture armv7

    C:\Program Files (x86)\MSBuild\RemObjects Software\Oxygene\RemObjects.Oxygene.Nougat.targets    329    5    Showcase

That’s the error message. there should also be the call to LD itself, something like

Executing: ld -arch x86_64 -ObjC ".../myapp.o"  -lSystem -lobjc  -framework Foundation -l"Nougat" -l"Swift" -L"/Users/mh/Code/git/Oxygene/Bin/Nougat/OS X" -dynamic -o "./obj/Debug/OS X/x86_64/myapp"  -lcrt1.10.6.o -syslibroot "%DEVELOPER%/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk" -macosx_version_min 10.10 

Mhm, I can’t find such lines. Where should they be?
I browsed each window (e.g. output) with no result.

You might need to set the log level to Detailed under Tools|Options|Project & Solution. You should also see this logged in Console.app on the Mac, as well.

31.07.14 23:17:18,304 crossbox[489]: Executing
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld
-arch armv7 -ObjC "./Debug/iOS/Link/armv7/Showcase.o"  -lSystem -lobjc  -framework CoreGraphics -framework Foundation
-framework UIKit -l"RTLabel" -l"sqlite3"
-l"Sugar" -l"xml2" -l"Nougat"
-L"./Debug/iOS/Link//Libraries" -dynamic -o
"./Debug/iOS/Link/armv7/Showcase"  -dead_strip -lcrt1.3.1.o -syslibroot
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk"
-force_load
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a"
-demangle -ios_version_min 7.1 

-L/path/to/libRTLabel.a seems to be mssing.

RTLabel.a should be in -L"./Debug/iOS/Link/Libraries" (which you can get to by right-clicking the CrossBox app icon and choosing Show Caches Folder and than finding the right one for your app, i.e. Showcase-*. is the .a file in there? If not, is the .a file next to the .fx file you are referencing, Windows side (it should be, since your screen sot shows thou have specified it under “libraries to copy”)?

The key issue is this guy:

(Link) ld: warning: ignoring file ./Debug/iOS/Link/Libraries/libRTLabel.a, file was built for archive which is not the architecture being linked (armv7): ./Debug/iOS/Link/Libraries/libRTLabel.a

It finds libRTLabel.a just fine, but that bile does not have armv7 code. It looks like maybe the iOS and the Simulator .a files get mixed up?

Can you send us the imported fx and .a files? (ideally the whole import folder, including iOS and iOS Simulator subfolders, and can you send me the full import log file?

Also, make sure you have “Build Active Architecture Only” off when you build this n Xcode. If that is on, Xcode mighty be generating, say, arm64 only (which is fine if thats what you want, but then you’d have to set your Elements app to build arm64-only as well). I recommend always building libraries for all architectures.