Profile

성빈이의 기록장

성빈이

[SwiftUI] URL 작업에서 couldn’t be opened because you don’t have permission to view it (권한 없음) 오류 해결

728x90

외주 앱을 만들다가 제목과 같은 오류 때문에 진짜 미치는 줄 알았다!

 

엄청난 구글링 끝에 결국 해결 법을 찾았다.

 

 

fileUrl.startAccessingSecurityScopedResource()

...

fileUrl.stopAccessingSecurityScopedResource()

 

 

이 메서드들을 이용하면 된다.

 

그렇다면 저 메서드는 무슨 역할을 할까?

 

stackoverflow.com/a/49196035에 따르면

startAccessingSecurityScopedResource() makes the security scoped bookmark's resource

available to your app's sandbox thus granting you access to that resource.

라고 한다.

 

필자는 iOS 프로그래밍 입문 3일 차라 몰랐는데

어쩌면 당연한 방법이었을지도..?