Why does Apple think my Unity project is trying to access the camera?
"This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data."
I feel like adding that key with the explanation of "This app does not use the camera" is not the correct solution... But I have no idea what could be seeming to use the camera.
It's a 2D Unity project. I'm updated to the latest of everything. I've written every line of code myself. I save & load four ints that I use as bitfields for persistent settings. I'm not using any services. (No ads, no in-app purchases, ect...) The only asset I've gotten from the asset store is a wav file. The app is fullscreen only and only supports the portrait and portrait upside down orientations. I set my export to 64 bit and iOS 8.0 or later.
My Google and Unity Answers searches haven't revealed any solutions. I have no starting point to debug from...
The rest of the code is fairly simple... What else can I look at?
I've made a list of everything I use in the code that's even remotely external:
UnityEngine
System.Collections
$$anonymous$$onoBehaviour
Vector3
GameObject
Rigidbody2D
SpriteRenderer
Collider2D
Vector2
Time
Input
Random
Sprite
Particle$$anonymous$$anager
Screen
AudioSource
Color
ScreenOrientation
Animator
Transform
ParticleSystem
Resources
CircleCollider2D
BoxCollider2D
PlayerPrefs
System.Collections.Generic
System.Serializable
List
I don't see how any of that could be remotely related to the device's camera.
I know that this sort of error happens if any files that XCode is even including accesses whatever it is (in this case the camera), even if the part of the file you're actually using doesn't use that item. Based on my research, this is where a lot of these false positives come from... But I'm not familiar enough with the internals of the Unity engine to know which of these structures comes from a file that could potentially access a device camera.
Answer by Frank84 · Jan 17, 2017 at 03:05 AM
I have released several iOS builds that do not use the camera with Unity 5.5.0f3, but upgrading to 5.5.0p4 causes this rejection when uploading the binary.
In terminal I ran: diff ./MyXcodeProjectOld/Classes ./MyXcodeProjectNew/Classes > diff1.txt diff ./MyXcodeProjectOld/Classes/Unity ./MyXcodeProjectNew/Classes/Unity > diff2.txt
and look what changed in /MyXcodeProjectNew/Classes/Preprocessor.h #define UNITY_USES_WEBCAM 1
set that to 0, increment build number, clean, archive, submit, success!
Just found an open issue for it too, which you all should vote on: https://issuetracker.unity3d.com/issues/ios-webcamtexture-and-microphone-classes-are-used-in-empty-unity-projects
Awesome. I've made a small post build editor script which changes that line in Preprocessor.h and the builds work again. Thanks!
using UnityEngine;
using System.IO;
using UnityEditor;
public class iOSBuildPostProcessor
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
{
if(target == BuildTarget.iOS)
{
Debug.Log ("<b>iOSBuildPostProcessor</b> OnPostProcessBuild");
#if UNITY_5_5_0
var targetfile = pathToBuiltProject + "/Classes/Preprocessor.h";
var filecontents = System.IO.File.ReadAllText(targetfile);
{
string seed = "#define UNITY_USES_WEBCA$$anonymous$$ 1";
string repl = "#define UNITY_USES_WEBCA$$anonymous$$ 0";
if (filecontents.Contains(seed))
{
Debug.Log("<b>iOSBuildPostProcessor</b> Removing faulty inclusion of CameraCapture");
filecontents = filecontents.Replace(seed, repl);
}
else
{
Debug.Log("Seed not found in file: " + seed);
}
}
System.IO.File.WriteAllText (targetfile, filecontents);
#endif
}
}
}
This is great! Thank you for sharing!
A few things I needed to do in order to make it work:
— Add: using UnityEditor.Callbacks;
for [PostProcessBuild]
to compile
— Create a C# script named iOSBuildPostProcessor and paste the code there. Place this file in a folder named "Editor"
— Change #if UNITY_5_5_0
to #if UNITY_5_5_1
(if you're using Unity 5.5.1 like me)
Answer by junmin4 · Oct 18, 2016 at 08:39 PM
having the same problem, this is very frustrating, please let me know if you find a solution
As a stopgap solution, I've been removing the references to camera functionality from the exported UnityInterface.h, and deleting the contents of CameraCapture.h & CameraCapture.mm, so those are just empty files in the project... But that's not a real solution. It works, but is indicative of a bug in the Unity engine's iOS exporter.
Thanks so much! your work-around let me submit the app. I think this issue should be solved.. it's a bit.. weird..
Answer by AmazingRuss · Oct 19, 2016 at 08:16 PM
I am also seeing this in a test project with one scene and one script that rotates a cube, all default build setting.
Answer by ckrin · Oct 20, 2016 at 09:16 PM
Same here, got rejected because of this. Hoping for an update or a clean solution.
Answer by andersemil · Jan 07, 2017 at 06:25 PM
Any resolve on this? Since upgrading to unity 5.5 we have the same issue, we're not using camera or photos in any way, but we get "invalid binary" when we upload to itunes connect and an email saying that we need to add NSCameraUsageDescription to info.plist. Please help if you can in any way. TIA
This was already solved by Unity. I'm using Unity 5.5 and its working fine.
Probably you have some third party library which is causing this error. (Ex. Old admob sdk)
That's incorrect. The current latest version of Unity still has this issue. It has not been fixed.
I updated all plugins and I'm still getting this error with Unity 5.5.0p3. Only solution atm is to use @Thajocoth 's hack to remove references to CameraCapture. Really annoying
Yes I can confirm it's back. It's working fine with Unity 5.5.0p1, but it's back with 5.5.0p4 (or any previous, I just downloaded new one).
Unity $$anonymous$$m, wtf?
This most definitely is not fixed in the latest version - or in fact any version after 5.5.0p1.