[iOS] Simulating Locations

RudinP·2024년 3월 26일
0

Study

목록 보기
208/226

개발 단계에서 매번 location관련 부분이 잘 동작하는지 실제 디바이스로 디버깅하기는 쉬운 일이 아니다.
따라서 위치를 시뮬레이션 하는 방법을 공부하고자 한다.

Simulator

Custom Location

  • 고정된 위치를 시뮬레이션하고자 한다면 이용

City Run

  • 사람이 달릴 때와 비슷한 속도로 경로와 위치를 업데이트 해준다.

City Bicycle Ride

  • 도로를 따라서 자전거를 탈 때와 비슷한 속도로 경로와 위치를 업데이트 해준다.

Freeway Drive

  • 가상의 자동차가 이동하는 경로와 위치를 표시해준다.

Apple

  • 예전 애플 본사(왜?)를 표시한다.

Simulator의 한계

  • 빠르고 쉽게 테스트 가능하나, 세부적인 제어가 불가능하다.
  • i.e) city run, freeway drive 의 경로 바꾸는 것이 불가

XCode Debug - Simulate Location

  • 디버그 바의 위치 아이콘을 선택하여 설정하는 것이 빠르다.

Scheme 설정

  • 시뮬레이터와 프로젝트를 껐다 키면 설정한 Location은 유지되지 않고 휘발된다. 이를 유지하도록 하고 싶다면 Scheme 설정을 해야 한다.


Options - Default Location 설정

GPX로 원하는 위치 추가하기

GPS Exchange Format
Scheme 설정에서 Add GPS Exchange to Project를 할 때 사용

  • 파일 이름이 곧 목록에 뜨는 이름이 되기 때문에 이 점을 유의하자.
<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode">
    
    <!--
     Provide one or more waypoints containing a latitude/longitude pair. If you provide one
     waypoint, Xcode will simulate that specific location. If you provide multiple waypoints,
     Xcode will simulate a route visiting each waypoint.
     -->
    <wpt lat="37.331705" lon="-122.030237">
        <name>Cupertino</name>
        
        <!--
         Optionally provide a time element for each waypoint. Xcode will interpolate movement
         at a rate of speed based on the time elapsed between each waypoint. If you do not provide
         a time element, then Xcode will use a fixed rate of speed.
         
         Waypoints must be sorted by time in ascending order.
         -->
        <time>2014-09-24T14:55:37Z</time>
    </wpt>
    
</gpx>
  • <name>: 좌표를 대표하는 이름, XCode에서는 자주 사용하지 않으므로 삭제해도 ok
  • <time>: 날짜와 시간이 저장되어 있는데, 이동하는 좌표를 시뮬레이션 할 때 사용. 시간 차를 이용해서 속도까지 시뮬레이션 가능. 단일 위치에서는 필요 없다.

  • 이제 simulation 목록에 추가한 gpx파일이 표시된다.

경로 이동 gpx

  • <wpt> 태그를 여러개 사용하면 된다.
  • 하나하나 추가하기 힘들면 GPX Generator 을 사용한다.
  • 하단의 kmh로 속도 설정이 가능하다.
profile
곰을 좋아합니다. <a href = "https://github.com/RudinP">github</a>

0개의 댓글