Skip to content

Instantly share code, notes, and snippets.

@mattiaswargren-zz
Created November 15, 2017 15:40
Show Gist options
  • Save mattiaswargren-zz/310a4407cea32f418c86682348ca4e03 to your computer and use it in GitHub Desktop.
Save mattiaswargren-zz/310a4407cea32f418c86682348ca4e03 to your computer and use it in GitHub Desktop.
Unity XCode 9 1024x1024 icon fix
#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