###前提・実現したいこと
UnityからXcodeのCapabilitiesのPush Notificationsの設定を自動的にONにしたいと考えています。
###発生している問題・エラーメッセージ
Push NotificationsをONにするだけであれば、UnityのPostProcessorでproject.pbxprojに追記することで無理矢理実現はできました(下記ソース)が、entitlementsでエラーになってしまいます。
これを解決しようと、PostProcessor内でentitlementsファイルを作成してみたものの、
こちらをPostProcessor内でプロジェクトに反映する方法が分からず途方にくれております。
こちらを解決する方法をご教授いただきたいです。
CapabilitiesのPush Notificationsの「Steps:」にある 「Add the Push Notifications entitlement to your entitlements file」 にエラーのチェックが付いてしまいます。 
###該当のソースコード
C#
1string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; 2PBXProject proj = new PBXProject (); 3proj.ReadFromString (File.ReadAllText (projPath)); 4 5string[] lines = proj.WriteToString().Split ('\n'); 6List<string> newLines = new List<string> (); 7bool editFinish = false; 8 9for (int i = 0; i < lines.Length; i++) { 10 11 string line = lines [i]; 12 13 if (editFinish) { 14 newLines.Add (line); 15 } else if (line.IndexOf ("isa = PBXProject;") > -1) { 16 do { 17 newLines.Add (line); 18 line = lines [++i]; 19 } while (line.IndexOf("TargetAttributes = {") == -1); 20 21 newLines.Add("TargetAttributes = {"); 22 newLines.Add("xxxxxxxxxxxxxxx = {"); 23 newLines.Add("DevelopmentTeam = EEEEEEEEE;"); 24 newLines.Add("SystemCapabilities = {"); 25 newLines.Add("com.apple.Push = {"); 26 newLines.Add("enabled = 1;"); 27 newLines.Add("};"); 28 newLines.Add("};"); 29 newLines.Add("};"); 30 editFinish = true; 31 32 } else { 33 newLines.Add (line); 34 } 35} 36 37File.WriteAllText(projPath, string.Join ("\n", newLines.ToArray ()));
###試したこと
project.elementファイルを作成後、
PBXProjectのAddFileメソッドなどの使用を試みたものの、
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。