How can I integrate a third-party framework into my Unreal project in Xcode?

I’ve done plenty of Xcode programming, but I’m a beginner with Unreal, so I’m hoping this will be a simple answer. I’d like to integrate a third-party framework into my project (specifically the Sketchup C API) but I’m unable to add a Link Binary To Libraries phase like I typically do with Xcode projects; when I view options for “Project - Mac” or “ProjectEditor - Mac,” there are no existing Build Phases and I am not given the option to add a new one.

I’ve already copied the framework to my Frameworks folder in the Xcode project and I know Xcode is finding it because the code completion has the headers and functions from the framework, but as soon as I try to build and run it fails to compile because the framework is not wrapped into the build process. I feel like there must be a simple protocol for integrating a third-party framework like this into an Unreal project, but I wasn’t able to find anything on the AnswerHub or Google. Any Unreal wizards care to shed some light on this?

We don’t have a clean way to add third-party frameworks to a UE4 project on Mac OS X at the moment. First, Xcode isn’t actually in charge of building UE4, that’s all controlled by UnrealBuildTool, which uses the various *.Build.cs files to determine how to build each module.

You’ll want to add your framework to your project’s module as a dependency - that’s the easy bit. The framework will need to be copied into the application bundle manually after building, or it won’t be found - we don’t automatically do this for you & there’s no easy way to set it up.

Thanks for your quick answer. I’ve written scripts for manually copying frameworks on build, so that won’t be a problem; however, I can’t find documentation on how to add frameworks to a module as a dependency. I thought it may have been PublicDependencyModuleNames at first, but that appears to be for entire modules, not frameworks for a module. I would appreciate any advice–thanks for your help so far!

If you look in Core.Build.cs you can see there’s two options:
PublicFrameworks.Add: This will add the framework to the link arguments, you will probably need to add a reference in the form: /path/to/framework.framework where /path/to is replaced by whatever the path really is.

or

PublicAdditionalLibraries.Add: Which will need the full path to the actual dylib at the heart of the framework, you can see examples of that for CoreSymbolication & MultitouchSupport.

See if those approaches work & get back to us if they don’t. If everything builds, but the application can’t launch, open a Terminal window and type the following:
otool -l /path/to/module/that/links/framework
Where you replace the example path here with the actual path to the executable/dylib that links against your framework.

That will emit all the load commands for that executable which will tell us where it is trying to load your framework from.

Worked like a charm, thank you for the help!

Using PublicFrameworks.Add didn’t seem to work because it reported that the framework could not be found even though I verified the path with complete certainty. However, when I switched over to using PublicAdditionalLibraries.Add and pointed it towards the .dylibs from my framework, the project built with my includes and launched just fine.

What scripts did you use? I have a problem integrating a framework (HeyzapAds), it crashes whenever I try to call a method from that SDK.

The scripts that I wrote were specifically for copying the frameworks into the application bundle, I never had a problem calling the method from the SDK after I did that. It sounds like you’re up against a different error; I’d recommend creating your own AnswerHub post for it, and if you want you can link it here and I’ll take a look at the details.

PublicFrameworks.Add alone didn’t work out for us, but we’ve been successful in linking frameworks using:

PublicFrameworks.AddRange(
				new string[] {
					"CoreTelephony",
					"SystemConfiguration",
					"UIKit",
					"Foundation",
					"CoreGraphics",
					"MobileCoreServices",
					"StoreKit",
					"CFNetwork",
					"CoreData",
					"Security",
					"CoreLocation"
				});

without the need of specifying the full path.

Absolute life saver.