Add code signing to ios

This commit is contained in:
Wojtek Figat
2023-05-17 18:53:04 +02:00
parent 24396031a7
commit 04d61eba3c
4 changed files with 86 additions and 0 deletions

View File

@@ -298,6 +298,10 @@ bool iOSPlatformTools::OnPostProcess(CookingData& data)
// TODO: expose event to inject custom post-processing before app packaging (eg. third-party plugins)
// Run code signing for Apple platform
if (EditorUtilities::CodeSignApple(data.DataOutputPath, GetPlatform(), *platformSettings))
return true;
// Package application
const auto buildSettings = BuildSettings::Get();
if (buildSettings->SkipPackaging)

View File

@@ -15,6 +15,9 @@
#include "Engine/Content/AssetReference.h"
#include "Engine/Content/Assets/Texture.h"
#include "Engine/Utilities/StringConverter.h"
#if PLATFORM_MAC
#include "Engine/Platform/Apple/ApplePlatformSettings.h"
#endif
#include <fstream>
#define MSDOS_SIGNATURE 0x5A4D
@@ -749,6 +752,48 @@ bool EditorUtilities::GenerateCertificate(const String& name, const String& outp
return false;
}
#if PLATFORM_MAC
bool EditorUtilities::CodeSignApple(const String& appFolder, PlatformType platform, const ApplePlatformSettings& settings)
{
switch(settings.CodeSigning)
{
case ApplePlatformSettings::CodeSigningMode::None:
break;
case ApplePlatformSettings::CodeSigningMode::WithProvisionFile:
{
LOG(Info, "Code signing with privision file '{0}'", settings.ProvisionFile);
// Embed privision profile file
String profileLocation = platform == PlatformType::Mac ? TEXT("Contents/embedded.provisionprofile") : TEXT("embedded.mobileprovision");
String dstPath = appFolder / profileLocation;
if (FileSystem::CopyFile(dstPath, settings.ProvisionFile))
{
LOG(Error, "Failed to copy privision file from '{}' to '{}'", settings.ProvisionFile, dstPath);
return true;
}
// Run codesign tool
CreateProcessSettings procSettings;
procSettings.FileName = TEXT("codesign");
procSettings.Arguments = String::Format(TEXT("-f -s \"{0}\" ."), settings.SignIdenity);
procSettings.HiddenWindow = true;
procSettings.LogOutput = true;
procSettings.WaitForEnd = true;
procSettings.WorkingDirectory = appFolder;
if (Platform::CreateProcess(procSettings) != 0)
{
LOG(Error, "Failed to sign code.'");
return true;
}
break;
}
}
return false;
}
#endif
bool EditorUtilities::IsInvalidPathChar(Char c)
{
char illegalChars[] =

View File

@@ -53,6 +53,9 @@ public:
static bool FindWDKBin(String& outputWdkBinPath);
static bool GenerateCertificate(const String& name, const String& outputPfxFilePath);
static bool GenerateCertificate(const String& name, const String& outputPfxFilePath, const String& outputCerFilePath, const String& outputPvkFilePath);
#if PLATFORM_MAC
static bool CodeSignApple(const String& appFolder, PlatformType platform, const class ApplePlatformSettings& settings);
#endif
public: