본문 바로가기
Unreal Engine

Unreal Engine iOS에서 LaunchURL 동작 오류 대응 가이드 (iOS 18 대응)

by 브랑제리 2025. 5. 5.
반응형

언리얼 엔진에서 외부 웹사이트를 여는 대표적인 방법은 UKismetSystemLibrary::LaunchURL 함수를 사용하는 것입니다. 이 함수는 블루프린트에서도 쉽게 사용할 수 있어, 게임 내에서 외부 링크로 사용자를 유도할 때 매우 유용합니다.

📌 UKismetSystemLibrary::LaunchURL의 내부 동작

UKismetSystemLibrary::LaunchURL은 내부적으로 FPlatformProcess::LaunchURL을 호출합니다. 그리고 플랫폼 별로 실제 동작은 FGenericPlatformProcess를 기반으로 각각의 OS에 맞는 구현체가 실행됩니다.

언리얼 엔진에서 FGenericPlatformProcess::LaunchURL를 이용해 iOS에서 외부 브라우저로 이동하려 할 때, iOS 18부터는 동작하지 않는 문제가 발생합니다. 이는 Apple이 기존의 UIApplication::openURL: 메서드를 더 이상 지원하지 않기 때문입니다.

수정할 함수는 다음과 같습니다:
void FIOSPlatformProcess::LaunchURL(const TCHAR* URL, const TCHAR* Parms, FString* Error)

📌 문제 요약

🧩 수정 대상 코드

파일 경로: Engine/Source/Runtime/Core/Private/IOS/IOSPlatformProcess.cpp

🔸 기존 코드 (문제 발생)

NSString* CFUrl = (NSString*)FPlatformString::TCHARToCFString(URL);
PRAGMA_DISABLE_DEPRECATION_WARNINGS
bool Result = [[UIApplication sharedApplication] openURL: [NSURL URLWithString: CFUrl]];
PRAGMA_ENABLE_DEPRECATION_WARNINGS

✅ 수정 코드 (iOS 10 이상 API 사용)

NSString* CFUrl = (NSString*)FPlatformString::TCHARToCFString(URL);
PRAGMA_DISABLE_DEPRECATION_WARNINGS
bool Result = false;
if (@available(iOS 10.0, *)) {
    Result = true;
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:CFUrl] options:@{} completionHandler:nil];
} else {
    Result = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:CFUrl]];
}
PRAGMA_ENABLE_DEPRECATION_WARNINGS

🛠 전체 함수 수정 예시

void FIOSPlatformProcess::LaunchURL(const TCHAR* URL, const TCHAR* Parms, FString* Error)
{
#if PLATFORM_VISIONOS
    *Error = TEXT("LaunchURL is not supported on VisionOS");
#else
    UE_LOG(LogIOS, Log, TEXT("LaunchURL %s %s"), URL, Parms ? Parms : TEXT(""));

    if (FCoreDelegates::ShouldLaunchUrl.IsBound() && !FCoreDelegates::ShouldLaunchUrl.Execute(URL))
    {
        if (Error)
        {
            *Error = TEXT("LaunchURL cancelled by delegate");
        }
        return;
    }

    NSString* CFUrl = (NSString*)FPlatformString::TCHARToCFString(URL);
    PRAGMA_DISABLE_DEPRECATION_WARNINGS
    bool Result = false;
    if (@available(iOS 10.0, *)) {
        Result = true;
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:CFUrl] options:@{} completionHandler:nil];
    } else {
        Result = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:CFUrl]];
    }
    PRAGMA_ENABLE_DEPRECATION_WARNINGS

    if (Error != nullptr)
    {
        *Error = Result ? TEXT("") : TEXT("unable to open url");
    }
#endif
}

📄 결론

iOS 18 이상 환경에서는 UIApplication::openURL: API가 더 이상 지원되지 않기 때문에, 언리얼 엔진 내부 LaunchURL() 함수에 새로운 API를 적용해야 합니다. 위와 같이 수정하면 외부 링크 호출이 iOS 18에서도 정상 작동합니다. 해당 코드는 엔진 소스 자체를 수정해야 하므로, GitHub에서 포크하거나 소스 빌드 환경에서 적용하는 것이 좋습니다.

🔗 참고 공식 문서

반응형