title: Unity app crashes when built for iOS with camera enabled
body: <p>I have an app which uses zxing to scan qr codes in the app. However when I build the app with these scripts in the scene the app crashes on startup. I thought it was something in the Awake() or Start() but I've wrapped those methods in a try catch, and even then I'm not getting any errors, and it doesn't crash on android and in the editor. </p>
  
  <p>I don't have access to a Mac, and am using Unity Cloud Build to build it.</p>
  
  <p>I also don't know how to enable permissions, I thought I did when creating the .p12 file, but I've also found that there's an info.plist file that I have to request permissions with. </p>
  
  <p>Prior research I found this <a href="https://forum.unity.com/threads/how-can-you-add-items-to-the-xcode-project-targets-info-plist-using-the-xcodeapi.330574/" rel="nofollow noreferrer">Unity Question about adding items to the Xcode project</a> but not only did including the xcodeapi give me errors, but the using statements didn't work.</p>
  
  <p>There are two scripts</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  using System;
  
  public class WebCamController : MonoBehaviour {
  
      public int desiredWidth = 1280;
      public int desiredHeight = 720;
      public int desiredFPS = 60;
      public RawImage output;
      [HideInInspector]
      public WebCamTexture webcamTexture;
  
      void Start ()
      {
          webcamTexture = new WebCamTexture(desiredWidth, desiredHeight, desiredFPS);
          output.texture = webcamTexture;
          Play();
      }
      public void Play()
      {
          webcamTexture.Play();
      }
      public void Pause()
      {
          webcamTexture.Stop();
      }
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  using ZXing;
  using ZXing.QrCode;
  using ZXing.Common;
  using System;
  
  public class CodeScanner : MonoBehaviour {
      private static CodeScanner _instance;
      public static CodeScanner Instance
      {
          get
          {
              if(null == _instance)
              {
                  Debug.Log("Code Scanner Instance not found");
              }
              return _instance;
          }
      }
  
      [Header("References")]
      public WebCamController wcc;
  
      [Header("Properties")]
      private BarcodeReader codeScanner;
      private string lastScanned = "";
  
      public delegate void Found(string text, string type);
      public event Found OnCodeScanned;
      private bool active;
  
      public void Awake()
      {
          _instance = this;
      }
  
      void Start () {
          codeScanner = new BarcodeReader();
          StartCoroutine(ReadCode());
          wcc.Play();
      }
  
      IEnumerator ReadCode()
      {
          while (active)
          {
              try
              {
                  var data = codeScanner.Decode(wcc.webcamTexture.GetPixels32(), wcc.webcamTexture.width, wcc.webcamTexture.height);
                  if (data != null)
                  {
                      //if (data.Text != lastScanned)
                      //{
                      OnCodeScanned(data.Text, data.BarcodeFormat.ToString());
                      //}
                      lastScanned = data.Text;
                  }
              }
              catch(Exception e)
              {
  
              }
              yield return new WaitForSeconds(1.0f);
          }
      }
  
  
      public void Activate()
      {
          wcc.Play();
          active = true;
          StartCoroutine(ReadCode());
      }
  
      public void Stop()
      {
          active = false;
          wcc.Pause();
      }
  }
  </code></pre>
  
  <p>My device is added properly to the .p12 certificate I can compile and run the program without these scripts in the scene.</p>