<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>IOS Development on Stay Frosty</title><link>https://frosty.blog/tags/ios-development/</link><description>Recent content in IOS Development on Stay Frosty</description><generator>Hugo -- gohugo.io</generator><language>en-gb</language><copyright>© James Frost</copyright><lastBuildDate>Sun, 28 Jul 2019 08:06:19 +0000</lastBuildDate><atom:link href="https://frosty.blog/tags/ios-development/index.xml" rel="self" type="application/rss+xml"/><item><title>Hacking with Swift: Live!</title><link>https://frosty.blog/2019/07/28/hacking-with-swift-live/</link><pubDate>Sun, 28 Jul 2019 08:06:19 +0000</pubDate><guid>https://frosty.blog/2019/07/28/hacking-with-swift-live/</guid><description>&lt;p&gt;A couple of weeks ago, I attended the first ever &lt;a href="https://www.hackingwithswift.com/live"&gt;Hacking with Swift: Live!&lt;/a&gt; conference in Bath, England. Helpfully, Bath is less than an hour away from where I live so it seemed like a great opportunity to attend a conference while still getting to see my family. And it was fantastic!&lt;/p&gt;
&lt;figure&gt;
 &lt;img src="https://www.hackingwithswift.com/uploads/hws-live.jpg" alt="" loading="lazy"&gt;
&lt;/figure&gt;
&lt;p&gt;If you&amp;rsquo;re not familiar with &lt;a href="Https://www.hackingwithswift.com"&gt;Hacking with Swift&lt;/a&gt;, it&amp;rsquo;s a website run by &lt;a href="https://twitter.com/twostraws"&gt;Paul Hudson&lt;/a&gt;. Paul is a one-man tutorial &lt;em&gt;machine&lt;/em&gt;. I have no idea how he produces so much content. He&amp;rsquo;s written 15 books on Swift and Apple&amp;rsquo;s platforms, and his website contains a &lt;em&gt;ton&lt;/em&gt; of free articles, tutorials, and videos all about Swift. His SwiftUI content has been really helpful, and again I don&amp;rsquo;t know how he created so much of it so soon after WWDC.&lt;/p&gt;</description><content:encoded><![CDATA[<p>A couple of weeks ago, I attended the first ever <a href="https://www.hackingwithswift.com/live">Hacking with Swift: Live!</a> conference in Bath, England. Helpfully, Bath is less than an hour away from where I live so it seemed like a great opportunity to attend a conference while still getting to see my family. And it was fantastic!</p>
<figure>
  <img src="https://www.hackingwithswift.com/uploads/hws-live.jpg" alt="" loading="lazy">
</figure>
<p>If you&rsquo;re not familiar with <a href="Https://www.hackingwithswift.com">Hacking with Swift</a>, it&rsquo;s a website run by <a href="https://twitter.com/twostraws">Paul Hudson</a>. Paul is a one-man tutorial <em>machine</em>. I have no idea how he produces so much content. He&rsquo;s written 15 books on Swift and Apple&rsquo;s platforms, and his website contains a <em>ton</em> of free articles, tutorials, and videos all about Swift. His SwiftUI content has been really helpful, and again I don&rsquo;t know how he created so much of it so soon after WWDC.</p>
<p>Hacking with Swift: Live was Paul&rsquo;s first attempt at running this conference and I think it was a huge success. The venue was modern, clean, and bright, the wifi worked excellently, and the food was really good. There were around 200 attendees which felt like just the right number to me. The format of the event was a little different than other conferences I&rsquo;ve attended before.</p>
<h3 id="day-1">Day 1</h3>
<p><strong>Day 1</strong> was quite standard conference fare, with 8 talks from some fantastic speakers: Cory Benfield (Apple), Kelly Hutchinson, Kilo Loco, Ellen Shapiro, Sally Shepard, Daniel Steinberg, John Sundell, and James Thomson. I particularly enjoyed:</p>
<ul>
<li>Cory&rsquo;s explanation of an easy place to get caught out in terms of performance with Swift&rsquo;s copy-on-write behaviour.</li>
<li>Ellen&rsquo;s talk about the Swift package manager, and using Swift scripts and tools to improve your development life.</li>
<li>Daniel&rsquo;s talk, which cleverly walked through a SwiftUI example by calling out which Swift Evolution proposals were responsible for which pieces of syntax, and explained how they worked.</li>
<li>James&rsquo;s history of easter eggs in Apple&rsquo;s software.</li>
</ul>
<p>But they were all great! The videos are all available on YouTube, and you can find links in <a href="https://www.hackingwithswift.com/articles/197/hacking-with-swift-live-2019-raises-30-000-for-charity">this post on hackingwithswift.com</a>.</p>
<h3 id="day-2">Day 2</h3>
<p><strong>Day 2</strong> was one big workshop. Paul literally <em>wrote a book</em> just for the conference, with 3 large example apps covering most of the big iOS 13 features. We then spent the day following along on our laptops as he led us through each tutorial. It was great to get a chunk of dedicated time working through a real example using the new features.</p>
<div class="gallery">
<figure>
  <a href="/images/2019/07/img_5053.jpeg"><img src="/images/2019/07/img_5053-1600.jpeg" alt="" loading="lazy"></a>
</figure>
<figure>
  <a href="/images/2019/07/img_5054.jpeg"><img src="/images/2019/07/img_5054-1600.jpeg" alt="" loading="lazy"></a>
</figure>
</div>
<p>I particularly enjoyed the morning, which was all SwiftUI. I have to say I have been somewhat skeptical about SwiftUI up until this point (these kids and their new-fangled technologies, what&rsquo;s wrong with the way we do it now? grumble mumble), but using it for a couple of hours&hellip; <strong>wow</strong> is it quick and convenient to build a UI and preview it.</p>
<figure>
  <a href="/images/2019/07/simulator-screen-shot-iphone-xca80-2019-07-10-at-17.18.42.png"><img src="/images/2019/07/simulator-screen-shot-iphone-xca80-2019-07-10-at-17.18.42-1600.png" alt="" loading="lazy"></a>
  <figcaption><p>The SwiftUI demo app we built</p></figcaption>
</figure>
<p>The other standout new pieces of API were diffable data sources (they clean up so much code!) and compositional collection view layouts.</p>
<h3 id="a-good-cause">A good cause</h3>
<p>All of the proceeds from Hacking with Swift: Live went to charity. The conference supported <a href="https://www.specialeffect.org.uk">Special Effect</a>, a charity that &ldquo;puts fun and inclusion back into the lives of people with physical disabilities by helping them to play video games&rdquo;. It seemed like a great cause, and the conference was able to donate $30,000!</p>
<h3 id="summary">Summary</h3>
<p>Paul ended the conference by talking about &rsquo;the bigger picture&rsquo;. How code brought us all together, but it&rsquo;s not the most important thing in any of our lives, and how we should think about the difference we can all make in the wider world. He also said how proud he was to bring everybody together to his home town, and brought his family onstage to say they were his reason for doing everything he does. I may have cried a little 😅.</p>
<p>I really enjoyed the event and felt like it could&rsquo;ve easily been a few days longer (although just two days was quite nice as it limited time away from home). I&rsquo;m keen to go back next year if they hold it again!</p>
]]></content:encoded></item><item><title>Inspecting iOS State Restoration Data</title><link>https://frosty.blog/2017/05/10/inspecting-ios-state-restoration-data/</link><pubDate>Wed, 10 May 2017 20:49:34 +0000</pubDate><guid>https://frosty.blog/2017/05/10/inspecting-ios-state-restoration-data/</guid><description>&lt;p&gt;State preservation and restoration allows iOS apps to save state when they&amp;rsquo;re sent into the background, and restore that state if the app is killed and then relaunched. If you&amp;rsquo;ve ever implemented state restoration yourself, you may have run into a case where it&amp;rsquo;d be helpful to see exactly what state iOS was storing.&lt;/p&gt;
&lt;p&gt;It turns out that Apple actually provides a tool to help you do just this, but it&amp;rsquo;s kind of hidden away and documentation is relatively sparse. Fortunately, it&amp;rsquo;s pretty easy to use. When you run it, it&amp;rsquo;ll output a structured plist showing all of your encoded objects, their restoration identifiers, and restoration class information. Here&amp;rsquo;s a step by step guide.&lt;/p&gt;</description><content:encoded><![CDATA[<p>State preservation and restoration allows iOS apps to save state when they&rsquo;re sent into the background, and restore that state if the app is killed and then relaunched. If you&rsquo;ve ever implemented state restoration yourself, you may have run into a case where it&rsquo;d be helpful to see exactly what state iOS was storing.</p>
<p>It turns out that Apple actually provides a tool to help you do just this, but it&rsquo;s kind of hidden away and documentation is relatively sparse. Fortunately, it&rsquo;s pretty easy to use. When you run it, it&rsquo;ll output a structured plist showing all of your encoded objects, their restoration identifiers, and restoration class information. Here&rsquo;s a step by step guide.</p>
<h3 id="1-download-the-tool">1. Download the tool</h3>
<p>Head over to the Apple &ldquo;<a href="https://developer.apple.com/download/more/">Downloads for Apple Developers</a>&rdquo; site and expand the <strong>restorationArchiveTool for iOS</strong> download. You&rsquo;ll want the <code>restorationArchiveTool.dmg</code> file right at the bottom of the list on the right.</p>
<p>Open the dmg, and drag the <code>restorationArchiveTool</code> binary out to somewhere you can easily access it. I placed mine in my <code>~/bin</code> directory.</p>
<h3 id="2-find-your-apps-library-directory">2. Find your app&rsquo;s Library directory</h3>
<p>Next, you need to know the location of your app&rsquo;s <code>Library</code> directory in the simulator. This is where the restoration data gets saved, which you&rsquo;ll inspect with the archive tool. The easiest way to find this is to add a line to your app delegate&rsquo;s <code>application:didFinishLaunchingWithOptions:</code> (or via a breakpoint). Something like this should do the trick:</p>
<p><strong>Objective-C:</strong></p>





<pre tabindex="0"><code>NSLog(@&#34;Library: %@&#34;, [[[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] firstObject] path]);</code></pre><p><strong>Swift:</strong></p>





<pre tabindex="0"><code>print(&#34;Library: \(FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!.path)&#34;)</code></pre><p>The path should get logged out to the console when your app launches. It&rsquo;ll be something like this:</p>





<pre tabindex="0"><code>/Users/bob/Library/Developer/CoreSimulator/Devices/1FF2D964-C615-499E-B1D0-8A7DF7343AE5/data/Containers/Data/Application/D6FE3A2C-9553-4270-8262-A94376EF4E5B/Library</code></pre><h3 id="3-get-some-data">3. Get some data</h3>
<p>This part&rsquo;s simple. Launch the app in the simulator, navigate to the part of the app you&rsquo;re interested in, send the app into the background, and stop the app in Xcode. If you open up the library folder you found in the last step, you&rsquo;ll see a folder named <strong>Saved Application State</strong>. Within that, you&rsquo;ll find a <code>data.data</code> file.</p>
<figure>
  <img src="/images/2017/05/Screen-Shot-2017-05-10-at-21.14.38.png" alt="Screen Shot 2017-05-10 at 21.14.38" loading="lazy">
</figure>
<h3 id="4-run-the-tool">4. Run the tool</h3>
<p>Now you need to run the archive tool and point it at the <code>data.data</code> file you just found. In Terminal, enter the following command, but switch out the location of your <code>restorationArchiveTool</code> binary and your app&rsquo;s <code>data.data</code> as required:</p>





<pre tabindex="0"><code>~/bin/restorationArchiveTool --plist --structured -o output.plist /path/to/your/data/file/data.data</code></pre><p>And you&rsquo;re done! You can then open up the generated plist in Xcode. Amongst other things, you&rsquo;ll see a list of top level objects, keyed by their restoration identifiers. You should notice that the restoration identifiers form a path based upon your view controller hierarchy. You can expand any object to see any extra data it&rsquo;s encoded.</p>
<figure>
  <a href="/images/2017/05/Screen-Shot-2017-05-10-at-20.44.26.png"><img src="/images/2017/05/Screen-Shot-2017-05-10-at-20.44.26-1600.png" alt="Screen Shot 2017-05-10 at 20.44.26" loading="lazy"></a>
</figure>
<p>At the bottom of the file, you&rsquo;ll find a list of restoration classes used by each of the encoded objects.</p>
<figure>
  <a href="/images/2017/05/Screen-Shot-2017-05-10-at-20.44.45.png"><img src="/images/2017/05/Screen-Shot-2017-05-10-at-20.44.45-1600.png" alt="Screen Shot 2017-05-10 at 20.44.45" loading="lazy"></a>
</figure>
<p>If you&rsquo;re having some problems with state restoration, then at the very least being able to see this information can give you some hints about whether your issue is with encoding or decoding. Good luck!</p>
]]></content:encoded></item></channel></rss>