버전
- 노트북 버전 : M1 Macbook, 11.6 (Big Sur)
- 유니티 버전 : Unity 2021.2.0a19 (ARM 최적화 빌드)
상황
M1 맥에서 ARM 최적화 빌드된 알파 버전 에디터를 사용하여 개발. File > Built Settings > iOS Platform 선택한 후 iOS 빌드 모듈 다운로드 버튼을 눌러 다운로드 받음. Build And Run 클릭 시 아래와 같이 오류 발생함.
UnauthorizedAccessException: Access to the path "/Applications/Unity/PlaybackEngines/iOSSupport/Trampoline/Libraries/libil2cpp-net40-wbarriers.a" is denied.
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at <56a09cea74224b4cafcbda9f814f7d23>:0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) (at <56a09cea74224b4cafcbda9f814f7d23>:0)
(wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions)
System.IO.FileSystem.CopyFile (System.String sourceFullPath, System.String destFullPath, System.Boolean overwrite) (at <56a09cea74224b4cafcbda9f814f7d23>:0)
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <56a09cea74224b4cafcbda9f814f7d23>:0)
UnityEditorInternal.FileMirroring.MirrorFile (System.String from, System.String to, System.Func`3[T1,T2,TResult] comparer) (at /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/FileMirroring.cs:30)
UnityEditor.iOS.PostProcessiPhonePlayer.InstallIncludedFiles (UnityEditor.iOS.PostProcessiPhonePlayer+IncludedFileList includedFiles, System.String installPath, UnityEditor.iOS.PostProcessiPhonePlayer+BuildSettings bs, UnityEditor.Build.Reporting.BuildReport buildReport) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:1625)
UnityEditor.iOS.PostProcessiPhonePlayer.UpdateInstallLocation (UnityEditor.iOS.PostProcessiPhonePlayer+ProjectPaths paths, UnityEditor.iOS.PostProcessiPhonePlayer+BuildSettings bs, UnityEditor.iOS.PostProcessiPhonePlayer+IncludedFileList includedFiles, UnityEditor.Build.Reporting.BuildReport buildReport) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:1519)
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:885)
UnityEditor.iOS.PostProcessiPhonePlayer.PostProcess (UnityEditor.iOS.PostProcessorSettings postProcessorSettings, UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/bokken/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:694)
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:28)
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:366)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
Build completed with a result of 'Failed' in 15 seconds (14827 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002be] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:193
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:94
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
문제 확인
UnauthorizedAccessException: Access to the path "/Applications/Unity/PlaybackEngines/iOSSupport/Trampoline/Libraries/libil2cpp-net40-wbarriers.a" is denied.
문구를 보고, 해당 디렉토리의 파일 권한 확인함
$ ls -alh /Applications/Unity/PlaybackEngines/iOSSupport/Trampoline/Libraries/
total 3142648
drwxr-xr-x 27 root wheel 864B May 28 21:47 .
drwxr-xr-x 12 root wheel 384B May 28 21:47 ..
-rw-r--r-- 1 root wheel 100B May 28 21:47 IL2CPPOptions.cpp.cpp
-rw-r--r-- 1 root wheel 348B May 28 21:47 Il2CppOptions.cpp
-rw-r--r-- 1 root wheel 59B May 28 20:52 RegisterFeatures.cpp
-rw-r--r-- 1 root wheel 39B May 28 20:52 RegisterFeatures.h
-rw-r--r-- 1 root wheel 744K May 28 21:47 baselib-amd64.a
-rw-r--r-- 1 root wheel 1.5M May 28 21:47 baselib-dev.a
-rw-r--r-- 1 root wheel 1.5M May 28 21:47 baselib.a
-rwxr-xr-x 1 root wheel 81M May 28 21:47 libiPhone-lib-amd64-il2cpp.dylib
-rw-r--r-- 1 root wheel 508M May 28 21:47 libiPhone-lib-il2cpp-dev.a
-rw-r--r-- 1 root wheel 314M May 28 21:47 libiPhone-lib-il2cpp.a
-rw------- 1 root wheel 25M May 28 21:47 libil2cpp-amd64-net40-debug-wbarriers.a
-rw------- 1 root wheel 25M May 28 21:47 libil2cpp-amd64-net40-debug.a
-rw------- 1 root wheel 22M May 28 21:47 libil2cpp-amd64-net40-wbarriers.a
-rw------- 1 root wheel 22M May 28 21:47 libil2cpp-amd64-net40.a
-rw------- 1 root wheel 22M May 28 21:47 libil2cpp-amd64.a
-rw------- 1 root wheel 54M May 28 21:47 libil2cpp-dev-net40-debug-wbarriers.a
-rw------- 1 root wheel 54M May 28 21:47 libil2cpp-dev-net40-debug.a
-rw------- 1 root wheel 47M May 28 21:47 libil2cpp-dev-net40-wbarriers.a
-rw------- 1 root wheel 47M May 28 21:47 libil2cpp-dev-net40.a
-rw------- 1 root wheel 47M May 28 21:47 libil2cpp-dev.a
-rw------- 1 root wheel 54M May 28 21:47 libil2cpp-net40-debug-wbarriers.a
-rw------- 1 root wheel 54M May 28 21:47 libil2cpp-net40-debug.a
-rw------- 1 root wheel 47M May 28 21:47 libil2cpp-net40-wbarriers.a
-rw------- 1 root wheel 47M May 28 21:47 libil2cpp-net40.a
-rw------- 1 root wheel 47M May 28 21:47 libil2cpp.a
.a 파일들의 권한이 루트 사용자에만 적용되어 있는 것을 확인할 수 있었음.
조치
다른 사용자들도 해당 .a 파일을 읽을 수 있도록 권한을 조정해 준다.
$ cd /Applications/Unity/PlaybackEngines/iOSSupport/Trampoline/Libraries/
$ sudo chmod a+r *
다시 한 번 빌드해 보면 잘 되는 걸 확인할 수 있다.
참고
- [유니티 / iOS] iOS 빌드 하기 : https://devparklibrary.tistory.com/34