1 00:00:00,000 --> 00:00:05,400 [Treehouse presents: Quick Tips--Test Locations on the iPhone Simulator in iOS with Amit Bijilani] ?[music]? 2 00:00:05,400 --> 00:00:09,340 Hi, I'm Amit and in this Treehouse quick tip we will learn how to test 3 00:00:09,340 --> 00:00:12,370 locations in the iPhone simulator. 4 00:00:12,370 --> 00:00:16,880 When building with location service, you want to be able to test 5 00:00:16,880 --> 00:00:21,100 various locations to make sure you're app is functioning correctly. 6 00:00:21,100 --> 00:00:25,870 And you probably want to test these locations right in the simulator 7 00:00:25,870 --> 00:00:31,480 without having to load the app on your device and walk around or run around. 8 00:00:31,480 --> 00:00:33,650 So let's find out how. 9 00:00:33,650 --> 00:00:36,610 I have created a very basic location services app, 10 00:00:36,610 --> 00:00:41,310 where I display a map with the current location highlighted with a blue dot. 11 00:00:41,730 --> 00:00:46,040 Mostly when you run a location services application in the simulator, 12 00:00:46,040 --> 00:00:50,740 it defaults to San Francisco as its current location. 13 00:00:50,740 --> 00:00:55,630 To test it with other locations, you have an option in the debug bar 14 00:00:55,630 --> 00:00:59,250 to choose from several system-generated locations. 15 00:00:59,250 --> 00:01:03,030 So if you go to Xcode and select your debug bar, 16 00:01:04,200 --> 00:01:11,240 there is a location services icon there, and you can select from several different locations. 17 00:01:11,240 --> 00:01:21,350 And there's Johannesburg. Select Russia. London. You get the idea. 18 00:01:21,350 --> 00:01:26,210 But what if you wanted to test with a location that is not on this list? 19 00:01:26,660 --> 00:01:32,850 Well it's very easy actually; all you have to do is add a GPX file to your project. 20 00:01:34,480 --> 00:01:38,470 So let's go back to Xcode and stop our project. 21 00:01:38,470 --> 00:01:47,230 To add a GPX file, you need to select file, new, and then select file once again. 22 00:01:48,010 --> 00:01:53,650 Select resource, and then make sure you have GPX file selected. 23 00:01:54,550 --> 00:01:57,820 Hit next--you will have to provide it with a name. 24 00:01:57,820 --> 00:02:02,070 I usually provide it with the name of the location that I will be adding. 25 00:02:02,070 --> 00:02:05,260 So, I will be adding Manhattan. 26 00:02:06,660 --> 00:02:11,320 Now this is a simple XML file with 3 things that you need to consider-- 27 00:02:11,320 --> 00:02:15,220 the latitude, the longitude, and the name of the place. 28 00:02:15,220 --> 00:02:19,920 So let's go ahead and change the name of the place to say Manhattan. 29 00:02:21,500 --> 00:02:24,770 And of course, then provide it with the latitude and longitude. 30 00:02:25,330 --> 00:02:32,390 Now when we run our application, Manhattan shows up as one of the options in the debug bar. 31 00:02:37,690 --> 00:02:43,640 And there you go; now you can test with Manhattan as a location for your location services app. 32 00:02:43,640 --> 00:02:47,810 Now you're not bound to any location when testing in the simulator. 33 00:02:47,810 --> 00:02:49,550 So happy testing.