How to Use Third Party Frameworks?

Hi, I’m a user of Stencyl which recently updated OpenFL, and that AFAIK includes third party framework support for iOS extensions. I already have an extension working that uses a static library and some header files, but I haven’t figured out how to integrate frameworks. Specifically, the problem is that the extension can’t be rebuilt because I don’t know how to import the header files of the framework without getting a file not found error. For the static library case, header files are located in project/include and importing just works with the file name and no path information needed. For the framework case, the framework is in another location. Importing the header files by name (or in the format framework/header) doesn’t work. When I run the Stencyl game, even though it fails to finish, I can see the framework linked in the Xcode project, so I don’t think my include.nmml file is the problem.

Oh, interesting, can you tell what version of OpenFL Stencyl is using now?

When you rebuild an extension, it’s based on the “Build.xml” (usually) in the extension “project” directory (it could be somewhere else, but that’s the normal convention for it)

That gives you full access to the flags and arguments used when building your library, so if you need to add an “-l” or “-L” or whatever is needed, that can be done.

As for adding Framework references when building your project, there is a <dependency name="" /> or <dependency path="" /> tag you can use to either point to an exact location (for a local framework) or the framework name (for one on the system)

Checking the OpenFL changelog file I see 2.2.4 dated two weeks ago.

I was thinking I might have to modify Build.xml, but I don’t know exactly what to do. Is there a way to indicate a location for header files, or do I need to copy/move the framework headers into the include folder? Would that even work?

It looks like you can do it like this:

That would go in the <target> tag of the Build XML

That didn’t seem to do anything. I did get the extension working though by copying all the header files from the framework and placing them in the include folder. I thought having duplicated header files might cause problems but testing worked just fine.

Hi. Please check this old related post http://www.openfl.org/archive/community/general-discussion/custom-framework-ios-extension-xcode5/

Did anyone found a solution to this ?
I mean, other than “unwrapping”, copying the headers from the framework in an other folder ?

I tryed the vflag thing but it didn’t work.

It seems that the required argument to link a local framework are the following :
-Fpath/to/framework/FrameworkName -framework FrameworkName

so I trieed to add those in compilerflag or vflag tag but it didn’t work, till have a file not found on my header files…

I’d like to do it this way cause it feels cleaner to me, and updating the framework when needed will be easier as well.

By the way, this is not really rellated but, if I link a framework in my extension, do I still need to link it as a dependency in my include.xml ? I feel like the answer is no as the framework is then embeded in the extension binary but I may be wrong ?

Okay, actually it works.

in your build.xml , in the tag about ios files, ad the following compilerflag :
-Fpath/to/your/frameworks/folder

for instance, my framworks are in the dependencies/ios folder, so I use -F…/dependencies/ios

Then, in the target tag , add the vflag with your Framework name as singmajesty said.

My Build.xml look like this :

1 Like

Sorry to bump, I’m with Rob sorta, except I’ve gotten all the frameworks imported. My only problem now is that I’m having troubles with dynamic libraries. Is it possible to use .dylib files? Like libz.dylib and libsquite3.dylib?

I’m running on Stencyl too and I’m trying to finish creating the Vungle extension for Stencyl which requires those dynamic libraries.

Try using the <dependency /> tag, like <dependency path="to/my.dylib" /> or <dependency name="my.dylib" />, depending on whether it is a local a file or a system file

1 Like