iOS Development tips weekly is a series you can find at the Lynda.com and LinkedIn Learning libraries. The first week of a week’s tip will be available to the public. After that, you will need a subscription to get access to it. Click the image below to view. Below the image you’ll find a transcript.
You can find the finished project here on GitHub
One very welcome change to Xcode 9 is the revamped simulators. Let’s look at some of the new features and issues with the new simulators.
I like to pre-load my simulators before running apps in Xcode. You’ll need Xcode running and showing in the dock. Right click Xcode in the dock, and select Open Developer Tool> Simulator. I have a iPhone X launched, yours may be different. I usually add this to my dock with Keep in dock for easy pre-launch.
You can add more devices by going to HardWare>Device and selecting the device group. I’ll add an iPad pro 9.7inch. Try again with an iPhone SE. You can also add an Apple TV or Apple Watch to the simulator the same way.
Click and hold on the dark bezel of the iPad. Drag and the tablet drags to position wherever you want. Click on a corner of the bezel, and you can then scale to exactly the size you want. Side and arrange what works for you
Once you are done with the simulators, you can clean up your screen. There’s two ways to do this. You can shut off the bezel in Window>Show device bezels. You’ll get the traditional looking simulators. From here you can close the simulator with the X like any other window.. I’ll close the SE then put back the bezels. Alternatively you can select the simulator and use Command-W from the keyboard. Try that on the iPad.
Now here’s the cool thing about the bezels: the buttons work. Select the settings app on the phone. Now click the home button and it works like a home buttons. While you might have Command-L memorized to lock your phone, you can also click the lock button on the side to lock, and click home to open. The volume buttons also work. You use the simulator the way the user would on a real device. The one exception is the iPhone 10, where the swipe from the bottom as of this writing isn’t working. You’ll have to use Command-Shift-H for this.
You also get Siri on both Phone and watch. Hold down the home button siri appears.
“What is the airspeed velocity of an unladen swallow?”
With two simulators up, you can look at the same app on different devices. Open the iPad 9.7 inch again. I have set in Xcode a Label on a storyboard .I’ll vary the font by size class.
Build and run. You get the app running in an iPad.
You can run this on the iPhone without switching simulators. Open the products folder on the bottom of the navigator view. You’ll find the app there, and drag it to the iPad. It loads, and you can now run it there too. This app is set for simulator use because we built and ran it on the iPhone first. If you’re switching between a live phone and the simulators, remember to rebuild and run on the simulator after running on the phone. Copying a phone app to a simulator won’t work.
You can now run the app on both devices.
The last feature that been there for a while, but you’ll want to use is Hardware>Erase all content and settings. Simulators are memory hogs, and they can eat your hard drive in gigabytes. when you’ve finished a project, you may want to clean them this way.
You’ve learned how to run an app on two simulators, and how to use the new bezel feature and the buttons. For more on the simulator, check out the help feature.