Created
November 15, 2017 15:40
-
-
Save mattiaswargren-zz/310a4407cea32f418c86682348ca4e03 to your computer and use it in GitHub Desktop.
Unity XCode 9 1024x1024 icon fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_IOS | |
using UnityEditor.Callbacks; | |
using UnityEditor; | |
using System.IO; | |
using UnityEditor.iOS.Xcode; | |
using System; | |
using UnityEngine; | |
public class PostProcessXCodeMissingIconFix | |
{ | |
[PostProcessBuild] | |
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject) | |
{ | |
if (buildTarget == BuildTarget.iOS) | |
{ | |
FileUtil.CopyFileOrDirectory("Assets/Publish/App Icon/iTunesArtwork@2x.png", pathToBuiltProject + "/Unity-iPhone/Images.xcassets/AppIcon.appiconset/Icon-1024.png"); | |
string xcodeAppIconContentsFile = pathToBuiltProject + "/Unity-iPhone/Images.xcassets/AppIcon.appiconset/Contents.json"; | |
string xcodeAppIconContentsText = null; | |
try | |
{ | |
xcodeAppIconContentsText = File.ReadAllText(xcodeAppIconContentsFile); | |
} | |
catch (Exception exception) | |
{ | |
Debug.LogFormat(exception.ToString()); | |
} | |
string newString = xcodeAppIconContentsText.Replace("]", ", {\"size\" : \"1024x1024\", \"idiom\" : \"ios-marketing\",\"filename\" : \"Icon-1024.png\", \"scale\" : \"2x\"}, {\"size\" : \"1024x1024\", \"idiom\" : \"ios-marketing\", \"filename\" : \"Icon-1024.png\", \"scale\" : \"1x\" } ]"); | |
try | |
{ | |
File.WriteAllText(xcodeAppIconContentsFile, newString); | |
} | |
catch (Exception exception) | |
{ | |
Debug.LogFormat(exception.ToString()); | |
} | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment