Workaround:Xcode 项目里 Add Capability 'Access WIFI Information' && 申请地理位置权限
PostBuildCapabilityChanger.cs
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
namespace FinGameWorks.Scripts.Editor.Modifer
{
public static class PostBuildCapabilityChanger
{
[PostProcessBuild(999)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
{
string path = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
Debug.Log(path);
Debug.Log(PBXProject.GetUnityTargetName());
ProjectCapabilityManager capabilityManager = new ProjectCapabilityManager(path, "InkCloth.entitlements", PBXProject.GetUnityTargetName());
capabilityManager.AddAccessWiFiInformation();;
capabilityManager.WriteToFile();
}
}
}
PermissionManager.cs
using System.Collections;
using UnityEngine;
namespace FinGameWorks.Scripts.Manager
{
public class PermissionManager : Singleton<PermissionManager>
{
private LocationService m_LocationService;
protected override void OnAwake()
{
base.OnAwake();
m_LocationService = new LocationService();
m_LocationService.Start();
}
}
}