How can I use iOS Libraries?

I’m using a mac to write a game for iOS, I’m trying to use UIKit from xCode however when I import the framework I receive the error that it can’t be found. "Shell Script Invocation Error ‘UIKit/UIAlertView.h’ file not found. Someone asked a similar question and was referred to the unreal source code build.cs, I took my build.cs from there but I can’t see what I’m missing.

In my .cpp class I have:

#include "MyProject2.h"
#include "BasicHUD.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIAlertView.h> // Error here:  "Shell Script Invocation Error 'UIKit/UIAlertView.h' file not found

ABasicHUD::ABasicHUD(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}

void ABasicHUD::ShowAlert(){
    NSString *string = [[NSString alloc]init];
    UIAlertView *alert = [[UIAlertView alloc]init];
}

My build.cs looks like this:

using UnrealBuildTool;

public class MyProject2 : ModuleRules
{
    public MyProject2(TargetInfo Target)
    {

        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

        if (Target.Platform == UnrealTargetPlatform.IOS)
	    {
            PublicIncludePaths.AddRange(new string[] {"Runtime/Core/Public/Apple", "Runtime/Core/Public/IOS"});
		    AddThirdPartyPrivateStaticDependencies( Target, "zlib" );
		    PublicFrameworks.AddRange(new string[] { "UIKit", "AudioToolbox", "AVFoundation", "GameKit", "StoreKit", "CoreVideo", "CoreMedia", "CoreMotion"});

	    }
    }
}

Still wondering about this one.

I wonder if this is actually possible without making any bridge between Objective-C++ and C++. My guess is that #import is for Objective-C while code is being compiled as C++.

I don’t know a proper way to do this… Looks like standalone static library written in Objective-C++ (C++ simply interfacing Objective-C frameworks) would work… Not sure. never tried so far.

Do we have to dig into engine source to expose ios native features??

I found this QnA https://answers.unrealengine.com/questions/36890/plugin-doesnt-start-on-ios-device.html

So… static library plugin, it is.

Thanks for the reply.
Import and include are not so different, can use either. I was looking through the source code to try and find out how they have implemented their iOS features. I haven’t been able to figure out how they’ve done it though. In the source they have imported iOS frameworks no problem and have used objective-c in .cpp files which confuses me.

3 years later…
Any news on this? Can we build native iOS UIKIT in UE?

1 Like