Skip to content

Commit

Permalink
Merge branch 'hotfix/v2.2.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
HarrisonHough committed Apr 25, 2024
2 parents cf3a011 + 248c11a commit 935f360
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .github/latest.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

## Changelog

- update install description
### Fixed
- update IOS build processor to include WebKit framework in [#37](https://github.com/readyplayerme/rpm-unity-sdk-webview/pull/37)
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.2.1] - 2024.25.04

### Fixed
- feat: update install description by @rk132 in [#37](https://github.com/readyplayerme/rpm-unity-sdk-webview/pull/37)

## [2.2.0] - 2024.24.01

### Updated
Expand Down
65 changes: 49 additions & 16 deletions Editor/IOSBuildProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,63 @@
#if UNITY_IOS
using System;
using System.IO;
using UnityEditor.Callbacks;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;
using UnityEngine;

namespace ReadyPlayerMe.WebView.Editor
{
public class IOSBuildProcessor : IPostprocessBuildWithReport
public class IOSBuildProcessor
{
public int callbackOrder => 0;

public void OnPostprocessBuild(BuildReport report)
[PostProcessBuild(100)]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (report.summary.platform != BuildTarget.iOS) return;
if (buildTarget != BuildTarget.iOS) return;

var projectPath = $"{report.summary.outputPath}/Unity-iPhone.xcodeproj/project.pbxproj";
var projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
var type = Type.GetType("UnityEditor.iOS.Xcode.PBXProject, UnityEditor.iOS.Extensions.Xcode");
if (type == null)
{
Debug.LogError("unitywebview: failed to get PBXProject. please install iOS build support.");
return;
}
var src = File.ReadAllText(projPath);
var proj = type.GetConstructor(Type.EmptyTypes).Invoke(null);
{
var method = type.GetMethod("ReadFromString");
method.Invoke(proj, new object[] { src });
}
var target = "";
{
var method = type.GetMethod("GetUnityFrameworkTargetGuid");
target = (string) method.Invoke(proj, null);
}

var pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);

// Main
var targetGuid = pbxProject.GetUnityMainTargetGuid();
pbxProject.AddFrameworkToProject(targetGuid, "WebKit.framework", false);

pbxProject.WriteToFile(projectPath);
{
var method = type.GetMethod("AddFrameworkToProject");
method.Invoke(proj, new object[] { target, "WebKit.framework", false });
}
var cflags = "";
if (EditorUserBuildSettings.development)
{
cflags += " -DUNITYWEBVIEW_DEVELOPMENT";
}
#if UNITYWEBVIEW_IOS_ALLOW_FILE_URLS
cflags += " -DUNITYWEBVIEW_IOS_ALLOW_FILE_URLS";
#endif
cflags = cflags.Trim();
if (!string.IsNullOrEmpty(cflags))
{
var method = type.GetMethod("AddBuildProperty", new Type[] { typeof(string), typeof(string), typeof(string) });
method.Invoke(proj, new object[] { target, "OTHER_CFLAGS", cflags });
}
var dst = "";
{
var method = type.GetMethod("WriteToString");
dst = (string) method.Invoke(proj, null);
}
File.WriteAllText(projPath, dst);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions Runtime/WebViewPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ReadyPlayerMe.Core;
using ReadyPlayerMe.Core.WebView;
using UnityEngine;
using UnityEngine.Events;

namespace ReadyPlayerMe.WebView
{
Expand All @@ -23,6 +24,8 @@ public class WebViewPanel : MonoBehaviour
[SerializeField] public WebViewEvent OnUserSet = new WebViewEvent();
[SerializeField] public WebViewEvent OnUserAuthorized = new WebViewEvent();
[SerializeField] public AssetUnlockEvent OnAssetUnlock = new AssetUnlockEvent();
[SerializeField] public UnityEvent OnUserLogout = new UnityEvent();
[SerializeField] public WebViewEvent OnUserUpdate = new WebViewEvent();

private WebViewBase webViewObject = null;

Expand Down Expand Up @@ -155,6 +158,12 @@ private void HandleEvents(WebMessage webMessage)
case WebViewEvents.USER_AUTHORIZED:
OnUserAuthorized?.Invoke(webMessage.GetUserId());
break;
case WebViewEvents.USER_LOGOUT:
OnUserLogout?.Invoke();
break;
case WebViewEvents.USER_UPDATED:
OnUserUpdate?.Invoke(webMessage.GetUserId());
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.readyplayerme.webview",
"version": "2.2.0",
"version": "2.2.1",
"displayName": "Ready Player Me WebView",
"description": "Ready Player Me WebView helps you display an in-engine browser that helps you load RPM website where you can create avatars and receive avatar URL at the end of the process.\nWebView is mobile only and works in Android and IOS builds.",
"category": "tool",
Expand Down

0 comments on commit 935f360

Please sign in to comment.