SwiftUI HTTP 접근 허용하기 : App Transport Security policy requires the use of a secure connection.
by Steady OnHTTP 서버 혹은 open API에 접근할 때 뜨는 오류
// Fatal error 메세지
Thread 2: Fatal error: Unable to parse data : Error Domain=NSURLErrorDomain Code=-1022
"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.,
NSErrorFailingURLStringKey="문제가 되는 url주소", NSErrorFailingURLKey="문제가 되는 url주소"
// 터미널에 쓰는 메세지
Cannot start load of Task <3B8EBA29-98AB-48D9-A801-40A3B305F588>.<1> since it does not conform to ATS policy
원인
- App Transport Security policy requires the use of a secure connection.
- ATS policy란?
- iOS9버전부터 적용된 보안 정책으로 개인정보보호 기능
- HTTP는 안전하지 않다고 여겨서 접근을 막음
해결방법
- 네비게이터에서 최상단에 위치한 프로젝트 클릭(이런저런 설정을 모아둔 곳)
- Targets → Info 탭 클릭
- Bundle name에 커서를 갖다대면 나오는 +버튼 클릭
- App Transport Security Settings 를 찾아 추가하고 그 줄에서 + 버튼 한번 더 클릭
- Allow Arbitary Loads 를 찾아 추가 하고 오른쪽에서 No → Yes로 변경
주의사항
- 결국 보안에 관련된 것이므로 검증된게 아니라면 이 설정을 건드리지 않는것이 좋음
'iOS > Error&Issue Log' 카테고리의 다른 글
modal을 닫지 않고 탭을 이동했다가 다시 돌아와 modal을 닫으면, view가 보이지 않는 문제 (1) | 2023.08.17 |
---|---|
whose view is not in the window hierarchy 로그의 원인과 해결 (0) | 2023.08.17 |
NoBuildableEntriesError: active scheme does not build this file select a scheme (Xcode에서 아무 이유없이 Preview가 안뜰때) (0) | 2022.11.18 |
Git merge시 project.pbxproj conflict 방지 (0) | 2022.11.18 |
Swift : signal: illegal instruction (core dumped) (0) | 2022.09.28 |
블로그의 정보
Roen의 iOS 개발로그
Steady On