Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.03k stars 1.13k forks source link

Location Usage Description required? [Bug] #659

Closed sam598 closed 3 years ago

sam598 commented 3 years ago

Describe the bug iOS app does not build when "Location Usage Description" is blank.

To Reproduce Steps to reproduce the behavior:

  1. Download the latest version of AR Foundation
  2. Clear the Location Usage Description
  3. Try to build for iOS
  4. See error:
    Exception: A required capability description is not set.
    UnityEditor.iOS.PostProcessiPhonePlayer.PostProcess (UnityEditor.iOS.PostProcessiPhonePlayer+BuildSettings bs, UnityEditor.iOS.PostProcessiPhonePlayer+ProjectPaths paths, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport buildReport) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:864)
    UnityEditor.iOS.PostProcessiPhonePlayer.PostProcess (UnityEditor.iOS.PostProcessorSettings postProcessorSettings, UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:668)
    UnityEditor.iOS.iOSBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/ExtensionModule.cs:45)
    Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
    UnityEditor.iOS.iOSBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/ExtensionModule.cs:49)
    UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at /Users/bokken/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:29)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:324)
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler() (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorApplication.cs:432)

Expected behavior Build iOS application without location services.

Actual behavior iOS application does not build.

Smartphone (please complete the following information):

tdmowrer commented 3 years ago

The error is telling you what the problem is here.

There is a sample that uses location services, so to build the samples for iOS, you must provide a location usage description. You do not need a location usage description in your own app unless, of course, you are using location services.

sam598 commented 3 years ago

Project will build if the folder Assets/Scenes/ARKit/ARKitGeoAnchors is deleted. Is this documented?

sam598 commented 3 years ago

Ah just saw the comment by @tdmowrer. It sort of is.

sam598 commented 3 years ago

Actually it looks like there is more to it.

In Assets/Scripts/UX/CheckAvailableFeatures.cs lines 445-457:

if (sessionDescriptors.Count > 0 && IsiOS14OrLater())
{
    m_ARKitGeoAnchors.interactable = true;
}

and lines 492-497:

#if UNITY_IOS && !UNITY_EDITOR
        [DllImport("__Internal", EntryPoint = "ARFoundationSamples_IsiOS14OrLater")]
        static extern bool IsiOS14OrLater();
#else
        static bool IsiOS14OrLater() => false;
#endif

need to be commented out in order for the xcode project to build.