iOS: Change device capabilities with a postProcessBuild step

So, this one solves a bug in Unity 2017.4.2f2 that causes the armv7 device capability to be added to a 64 bit only build. We actually want arm64 instead of armv7 so I’ve setup this little hack to handle the fix


using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System;

// This has been added as a patch to solve a bug in Unity 2017.4.2f2 that incorrectly adds armv7 instead of arm64 to the plist
// ...and no, I don't like doing this.

public class PatchArchitecture
public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
if (target != BuildTarget.iOS)


string filePath = Path.Combine(pathToBuiltProject, "Info.plist");
PlistDocument plist = new PlistDocument();
PlistElementDict rootDict = plist.root;

// Get or create array to manage device capabilities
const string capsKey = "UIRequiredDeviceCapabilities";
PlistElementArray capsArray;
PlistElement element;

capsArray = rootDict.values.TryGetValue(capsKey, out element) ? element.AsArray() : rootDict.CreateArray(capsKey);

// Remove the armv7
const string arch = "armv7";
capsArray.values.RemoveAll(x => arch.Equals(x.AsString()));

// Add the arm64
File.WriteAllText(filePath, plist.WriteToString());

#endif // #if UNITY_IOS


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: