Skip to content

Commit a9e1763

Browse files
committed
iOS 경고 제거
1 parent 10b7ba5 commit a9e1763

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

Editor/BuildConfig/iOSBuildConfig.cs

+31-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Runtime.InteropServices;
45
using UnityEditor;
56
using UnityEditor.Callbacks;
@@ -18,14 +19,26 @@ namespace UNKO.Unity_Builder
1819
[StructLayout(LayoutKind.Auto)] // ignore codacy
1920
public class iOSBuildConfig : BuildConfigBase
2021
{
22+
private const string entitlements = @"
23+
<?xml version=""1.0"" encoding=""UTF-8\""?>
24+
<!DOCTYPE plist PUBLIC ""-//Apple//DTD PLIST 1.0//EN"" ""http://www.apple.com/DTDs/PropertyList-1.0.dtd"">
25+
<plist version=""1.0"">
26+
<dict>
27+
<key>aps-environment</key>
28+
<string>production</string>
29+
</dict>
30+
</plist>";
31+
32+
const string UNITY_IPHONE = "Unity-iPhone";
33+
2134
[PostProcessBuild(999)]
2235
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
2336
{
2437
bool platformIsiOS = buildTarget == BuildTarget.iOS;
2538
if (platformIsiOS)
2639
{
2740
#if UNITY_IOS
28-
string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
41+
string projectPath = path + $"/{UNITY_IPHONE}.xcodeproj/project.pbxproj";
2942

3043
PBXProject pbxProject = new PBXProject();
3144
pbxProject.ReadFromFile(projectPath);
@@ -51,18 +64,24 @@ public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
5164
Debug.LogError($"plist Can't open, path:{infoPlistPath}");
5265
}
5366

67+
// https://lhamed.github.io/66th-post-copy-2/
68+
var fileName = "unity.entitlements"; // 이거없으면 푸시 안됩니다
69+
var targetGUID = pbxProject.TargetGuidByName(UNITY_IPHONE);
70+
var entitlementsFilePath = $"{path}/{UNITY_IPHONE}/{fileName}";
71+
try
72+
{
73+
File.WriteAllText(entitlementsFilePath, entitlements);
74+
pbxProject.AddFile($"{UNITY_IPHONE}/{fileName}", fileName);
75+
pbxProject.AddBuildProperty(targetGUID, "CODE_SIGN_ENTITLEMENTS", UNITY_IPHONE + "/" + fileName);
76+
pbxProject.WriteToFile(projectPath);
77+
}
78+
catch (IOException e)
79+
{
80+
Debug.Log("Could not copy entitlements. Probably already exists. " + e);
81+
}
5482

55-
// 출처:https://forum.unity.com/threads/how-do-i-enable-remote-push-notification-capability-using-unity-cloud-build.457812/
56-
// get entitlements path
57-
string[] idArray = Application.identifier.Split('.');
58-
var entitlementsPath = $"Unity-iPhone/{idArray[idArray.Length - 1]}.entitlements";
59-
60-
var capManager = new ProjectCapabilityManager(projectPath, entitlementsPath, "Unity-iPhone");
61-
62-
// ITMS-90078: Missing Push Notification Entitlement
63-
capManager.AddBackgroundModes(BackgroundModesOptions.BackgroundFetch);
64-
capManager.AddBackgroundModes(BackgroundModesOptions.RemoteNotifications);
65-
capManager.WriteToFile();
83+
ProjectCapabilityManager pcm = new ProjectCapabilityManager(projectPath, entitlementsFilePath, UNITY_IPHONE);
84+
pcm.AddPushNotifications(false);
6685
#endif
6786
}
6887

0 commit comments

Comments
 (0)