Adding ObjC framework and errors

Hi :slight_smile:

I am experiencing difficulties when adding an iOS framework to my Fuse project. I am looking to add this framework - https://github.com/Cocoanetics/BarCodeKit

I have copied all source files, and added them like following:

  "Includes": [
    ...
    "BarcodeGenerator/src/iOS/UIImage+BarCodeKit.h:ObjCHeader:iOS",
    "BarcodeGenerator/src/iOS/UIImage+BarCodeKit.mm:ObjCSource:iOS",
    "BarcodeGenerator/src/.h:ObjCHeader:iOS",
    "BarcodeGenerator/src/.mm:ObjCSource:iOS"

  ]

I am not sure if this would be the correct or most optimal way to add this framework so if anyone has some tips I will really appreciate that. Furthermore, when adding the framework, I get an error when building:

../../../../../BarcodeGenerator/src/BCKCode.mm(365.1): E6118: '(id)kCTParagraphStyleAttributeName: CFBridgingRelease(paragraphStyle),
                                 (id)kCTFontAttributeName: CFBridgingRelease(font)': 'CFBridgingRelease(paragraphStyle),
                                 (id)kCTFontAttributeName: CFBridgingRelease(font)' is not a valid macro call
BarcodeGenerator/src/BCKCode.mm(365,2,365,10304): Error E6118: '(id)kCTParagraphStyleAttributeName: CFBridgingRelease(paragraphStyle),
                                 (id)kCTFontAttributeName: CFBridgingRelease(font)': 'CFBridgingRelease(paragraphStyle),
                                 (id)kCTFontAttributeName: CFBridgingRelease(font)' is not a valid macro call

I am quite lost, so if anyone could offer some help that would be amazing. Thanks!

Hey!

It’s hard to say what exactly is going wrong, but it might be that the default build settings for Objective-C that Fuse currently uses are incompatible with the library (in particular we currently have to disable ARC for legacy reasons).

If possible, instead of including all the source from the library, I would suggest compiling the library to a framework and then including the framework with e.g. the attributes [Require("Xcode.Framework", "@('relative/path/to/the/framework-file.framework':Path)"), Require("Xcode.FrameworkDirectory", "@('relative/path/to/the/':Path)")] on the Uno class with the foreign code that calls out to the library. When you do this the framework will be able to use its own build settings.

People have also had some success using CocoaPods with Fuse. See this thread.

Hope that helps! Don’t hesitate to ask if you have any further questions. :slight_smile:

Olle, thanks for the reply. I have tried adding framework, but I am getting an empty framework with no headers in it. I am just shifting through different cocoapods libraries to get one working, and this one has a framework compiled - https://github.com/yeahdongcn/RSBarcodes

[Require("Xcode.Framework", "@('BCGen/Products/RSBarcodes.framework':Path)"),Require("Xcode.FrameworkDirectory", "@('BCGen/RSBarcodes/':Path)")]
[Require("Source.Import", "RSBarcodes/aHeader.h")]
[Require("Source.Import", "RSBarcodes/RSBarcodes.h")]

BCGen is the root folder for above github files. RSBarcodes/aHeader.h doesn’t exist, and checking frameworks in xcode RSBarcodes is empty with an empty “headers” file.

What’s the difference between “Xcode.Framework” and “Xcode.FrameworkDirectory” ?

Can you verify that the framework actually contains everything that you’re using? You can do it with Finder since it’s actually just a directory.

Xcode.FrameworkDirectory corresponds to the FRAMEWORK_SEARCH_PATHS setting in Xcode projects, which is something like a search path for headers (sort of like the -I flag that many compilers accept). I’m actually not sure why it’s necessary to also specify that information (shouldn’t the frameworks be enough?), but that’s how it works currently. Maybe we could add some more automation there though. :slight_smile:

If the framework is at the path that you’ve specified above the framework directory should probably be BCGen/Products/.