macOS default framework search paths not correct

Try this:

 PublicFrameworks.AddRange(
             new string[]
             {
                 "/Library/Frameworks/iTunesLibrary.framework"
             }
             );

Note: The standard locations for frameworks are the /System/Library/Frameworks directory and the /Library/Frameworks directory on the local system.

see documentation

UE4 does not search /Library/Frameworks for frameworks, and by definition it should.

Take for example, iTunesLibrary.framework which is an Apple supplied framework in that directory. By all means you should be able to link it w/ *.build.cs with:

    PublicFrameworks.AddRange(
    			new string[]
    			{
    				"iTunesLibrary"
    			}
    			);

and be able to import its headers in objective-c++ files using:

#import <iTunesLibrary/iTunesLibrary.h>

However neither of these thing are possible, because you get the error during linking:

ld: framework not found iTunesLibrary

I consider this to be a bug, especially because /System is not writable anymore, so you cannot work around this by adding a framework to /System/Library/Frameworks.

Without trying to overcomplicate this bug report with a question: Is there any way, using *.build.cs, to add a Framework Search Path? When looking around for how to include third party frameworks, most search results are from 2014 and use the word “yet” or “at this time” to talk about how it’s not “easy” to do this. It is now 2017 and it’s unclear what the solution is.

OK, that works at fixing the linking problem (no more framework not found error). That’s one part solved

However, the framework search path is not properly added when building. If you try to include/import a header from the framework using the framework syntax:

#import <iTunesLibrary/iTunesLibrary.h>

You get the following error:

CompilerResultsLog: /Users/me/Documents/Unreal/FrameWorksTest/Source/FrameWorksTest/FWTest.mm:11:9: fatal error: 'iTunesLibrary/iTunesLibrary.h' file not found

Compared to importing a system framework which succeeds and builds just fine:

#import <Foundation/Foundation.h>

Hi coupler,

Sorry for not getting back to you sooner. I was able to reproduce the issue that you have described, and it still seems to be happening in our most recent internal version of the Engine. I have entered UE-56000 to have this investigated further.

Hi folks, ! I see UE-56000 is listed as fixed and resolved, but I am still experiencing the same issue as the original poster.

In the ActionRPG demo project, I add the following to my ActionRPG.Build.cs:

if (Target.Platform == UnrealTargetPlatform.IOS)
{
	PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "OnlineSubsystemUtils" });
	DynamicallyLoadedModuleNames.Add("OnlineSubsystemFacebook");
	DynamicallyLoadedModuleNames.Add("OnlineSubsystemIOS");
	DynamicallyLoadedModuleNames.Add("IOSAdvertising");
    PublicFrameworks.AddRange(
        new string[] {
            "/Library/Frameworks/iTunesLibrary.framework",
        }
    );
}

But I still get this linking error:
UATHelper: Packaging (iOS): ld: framework not found /Library/Frameworks/iTunesLibrary.framework

It doesn’t work when I try the string “iTunesLibrary” by itself either. I confirmed I do have /Library/Frameworks/iTunesLibrary.framework on my machine.

This is without adding any other code at all. Maybe I’m missing something obvious. But of course if I try to
#import <iTunesLibrary/iTunesLibrary.h>,
I still get:
fatal error: 'iTunesLibrary/iTunesLibrary.h' file not found.

I am on macOS Big Sur 11.2, UE 4.26.1, and Xcode 12.4. Please advise, thank you!

I see what my problem was, the iTunesLibrary.framework is a Mac framework and I was making an iOS game. When I used our own third-party iOS framework it worked perfectly. Btw I had to add my third-party framework as an Unreal Engine Build.cs Framework class, it works really well.