<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marco Eidinger on Medium]]></title>
        <description><![CDATA[Stories by Marco Eidinger on Medium]]></description>
        <link>https://medium.com/@marcoeidinger?source=rss-c0984445ac73------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wmF596DSPiJ_RoyZwc7WuQ.jpeg</url>
            <title>Stories by Marco Eidinger on Medium</title>
            <link>https://medium.com/@marcoeidinger?source=rss-c0984445ac73------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 19:57:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcoeidinger/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Ensure safe code in your iOS app extensions]]></title>
            <link>https://marcoeidinger.medium.com/ensure-safe-code-in-your-ios-app-extensions-2e0f58069ce4?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e0f58069ce4</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Mon, 08 Jan 2024 14:11:52 GMT</pubDate>
            <atom:updated>2024-01-11T11:59:22.099Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog post, I’ll explain the “Require Only App-Extension-Safe API” ( APPLICATION_EXTENSION_API_ONLY) <a href="https://developer.apple.com/documentation/xcode/build-settings-reference#Require-Only-App-Extension-Safe-API">build setting</a> in Swift, when and why to use it, and its consequences when generating API documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*MQ1XUg8ed3u8ashgoRt2EA.png" /></figure><p>Whether you implement a widget, share, action, or custom keyboard extension, your app extension runs in a separate process and has limitations on accessing certain resources or performing certain operations. That’s why some APIs Are unavailable to app extensions, and an app extension cannot:</p><ul><li>Access a <a href="https://developer.apple.com/documentation/uikit/uiapplication/1622975-shared">sharedApplication</a> object, and so cannot use any of the methods on that object</li><li>Use any API marked in header files with the NS_EXTENSION_UNAVAILABLE macro, or similar unavailability macro, e.g. @available(iOSApplicationExtension, unavailable)</li><li>Access the camera or microphone on an iOS device</li><li>Perform long-running background tasks</li><li>Receive data using AirDrop</li></ul><p>Xcode automatically sets APPLICATION_EXTENSION_API_ONLY to YES in the extension target build settings.</p><blockquote><em>When enabled, this causes the compiler and linker to disallow use of APIs that are not available to app extensions and to disallow linking to frameworks that have not been built with this setting enabled.</em></blockquote><p>In other words, the Swift compiler will protect you and throw an error if you attempt to use an unsupported API.</p><p>Changing this build setting to NO in your app extension target will cause the error:</p><blockquote><em>Application extensions and any libraries they link to must be built with the </em><em>APPLICATION_EXTENSION_API_ONLY build setting set to YES.</em></blockquote><p>Let’s say you want to share common business logic between your app and your extension, and you start moving code into a framework used by your app and extension. Without further information, the Swift compiler cannot protect you because your framework can be used in an app or extension.</p><p>So you also must set the APPLICATION_EXTENSION_API_ONLY to YES in your framework target build settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/0*F9CvXKsseT8TSsec" /></figure><p>You might need to set certain types in your existing code as unavailable for extensions if those types use unsupported APIs.</p><pre>@available(iOS 15.0, *)<br>@available(iOSApplicationExtension, unavailable)<br>/// API to be used in app but not in extension ...<br>public class MyApi {<br>    public init() {<br>        // ... because UIApplication.shared cannot be used in extensions<br>        print(UIApplication.shared.canOpenURL(URL(string: &quot;https://www.google.com&quot;)!))<br>    }<br>}</pre><p>There is an interesting caveat: those APIs will NOT be documented when using Jazzy, Swift-DocC, or even if you check the Quick Help in Xcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6OUqHQDWp8A0POYI" /></figure><p>The Swift compiler will remove symbols with unavailable for extension annotation from the symbol graph.</p><p>Often, you might want to include those symbols in the framework’s documentation because the framework can be used in an app target.</p><p>The only solution I know is to change that build setting before generating the documentation, e.g. jazzy --build-tool-arguments APPLICATION_EXTENSION_API_ONLY=NO</p><p><em>Originally published at </em><a href="https://blog.eidinger.info/ensure-safe-code-in-your-ios-app-extensions"><em>https://blog.eidinger.info</em></a><em> on January 8, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e0f58069ce4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Test Your Command-Line Tool In Xcode]]></title>
            <link>https://medium.com/geekculture/test-your-command-line-tool-in-xcode-7800a42eead6?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/7800a42eead6</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Mon, 19 Dec 2022 20:01:49 GMT</pubDate>
            <atom:updated>2022-12-19T20:01:49.949Z</atom:updated>
            <content:encoded><![CDATA[<p>Manual testing in the terminal is straightforward, but you might struggle with one of the following challenges when running your program from Xcode.</p><h3>Challenges</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AzBXoeTabN24kRxO" /></figure><p>If your command-line tool defines mandatory arguments, you might feel stuck as no arguments are passed per default. Another challenge you might face is that you want to simulate that the program was started from a specific directory.</p><p>No worries. In this blog post, I will show you how to</p><ol><li>Pass Arguments On Launch</li><li>Set a Custom Working Directory</li></ol><h3>Pass Arguments On Launch</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4aEhzW0rizs8kTq9" /></figure><p>Open “Edit Scheme”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4BXCps_36OoNRRFl" /></figure><p>You can specify the arguments passed on launch in the “Arguments” tab of the Run phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gRdgWbPQKXR_hnOj" /></figure><h3>Set Custom Working Directory</h3><p>The $(BUILD_PRODUCTS_DIR) is used as the working directory per default. To change that, open &quot;Edit Scheme&quot;. You can specify a custom working directory in the &quot;Options&quot; tab of the Run phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CAZXYXk0tGvF7IH6" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Oy7jbuU-80aFh_QJ" /></figure><h3>Demo</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FqeP4YgzWmjY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqeP4YgzWmjY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqeP4YgzWmjY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3f1820cb12a4388a961dde60faf6116/href">https://medium.com/media/f3f1820cb12a4388a961dde60faf6116/href</a></iframe><p><em>Originally published at </em><a href="https://blog.eidinger.info/test-your-command-line-tool-in-xcode"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7800a42eead6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/test-your-command-line-tool-in-xcode-7800a42eead6">Test Your Command-Line Tool In Xcode</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Find the Evil Commit in Your iOS Application With Git Bisect]]></title>
            <link>https://medium.com/better-programming/find-the-evil-commit-in-your-ios-application-with-git-bisect-488b1f414d98?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/488b1f414d98</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 21:19:28 GMT</pubDate>
            <atom:updated>2022-10-17T21:19:28.150Z</atom:updated>
            <content:encoded><![CDATA[<h4>Save time with this fantastic feature</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n2N7_2vcC9nb2Y19" /><figcaption>Photo by <a href="https://unsplash.com/@jeshoots?utm_source=medium&amp;utm_medium=referral">JESHOOTS.COM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Motivation</h3><p>Learn how you can easily find a commit that introduced a bug in an iOS application.</p><p>The following technique is helpful if you work with many developers on a large repository with daily complex commits. Once you find the commit, you can analyze the file changes to determine the root cause of the bug.</p><h3>Technique</h3><p>Git, a source-control management (SCM) system, provides a helpful command called git bisect.</p><blockquote><em>This command uses a binary search algorithm to find which commit in your project’s history introduced a bug. You use it by first telling it a “bad” commit that is known to contain the bug, and a “good” commit that is known to be before the bug was introduced.</em></blockquote><blockquote><em>Then git bisect picks a commit between those two endpoints and asks you whether the selected commit is “good” or “bad.” It continues narrowing down the range until it finds the exact commit that introduced the change.</em></blockquote><p>You could perform a manual test to check if it is a “good” or “bad” commit for every iteration, but this is very tedious. Instead, can you write a test or script to detect the bug? Often this is possible even if you don’t know what code caused the problem.</p><blockquote><em>If you have a script that can tell if the current source code is good or bad, you can bisect by issuing the command </em><em>$ git bisect run my_script arguments</em></blockquote><p>You can use git bisect run xcodebuild test ... once you have enhanced an existing XCTestCase to detect the bug through UI tests. Then Git can perform every iteration automatically and will spill out the information which was the first &quot;bad&quot; commit.</p><p>I recommend outsourcing the xcodebuild command in a Makefile for readability.</p><p>Here’s an example for a Makefile:</p><pre>uitest:<br>    xcodebuild test \<br>      -project FlakyApp.xcodeproj \<br>      -scheme FlakyAppUITests \<br>      -sdk iphonesimulator \<br>      -destination &#39;platform=iOS Simulator,name=iPhone 13&#39;</pre><p>Now you can call git bisect run make uitest :).</p><p>Another advantage of outsourcing is that you can tweak the xcodebuild command and still stably trigger git bisect run. For example, let&#39;s run only one test to detect the bug by specifying -only-testing option.</p><pre>uitest:<br>    xcodebuild test \<br>      -project FlakyApp.xcodeproj \<br>      -scheme FlakyAppUITests \<br>      -sdk iphonesimulator \<br>      -destination &#39;platform=iOS Simulator,name=iPhone 13&#39; \<br>      -only-testing &quot;FlakyAppUITests/FlakyAppUITests/testExample&quot;</pre><p>This change will make the bisection execution faster, and you can still trigger it with git bisect run make uitest.</p><h3>Example</h3><p>The following simplified repository contains an iOS application, and a bug was introduced at some point.</p><p><a href="https://github.com/MarcoEidinger/GitBisectXcodebuild">GitHub - MarcoEidinger/GitBisectXcodebuild: Demo on how to use git bisect with xcodebuild test</a></p><p>We only know the last “good” commit ( 2de359e) and one &quot;bad&quot; commit for which the app does not work as expected ( 6e02ff9).</p><p>In this example, the bug is that the value of a SwiftUI Toggle is no longer true. We can update the UI Test in FlakyAppUITests.swift to check for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfdHU9gb3Tp-BIMeoIeS-g.png" /></figure><p>Now, let’s start bisecting the commits.</p><pre>git bisect start 6e02ff9f1e319fe095a9dcfec092f76c3005355c 2de359e2ce524d9d4e8276595cc3c70ae9311996</pre><p>Git tells us that roughly two steps are necessary to find the culprit.</p><pre>Bisecting: 3 revisions left to test after this (roughly 2 steps)<br>[7e68c4102f3d68310285fe58acbcf9d21503ff51] maybe</pre><p>Then, we tell Git to run make uitest for every iteration.</p><pre>git bisect run make uitest</pre><p>Git starts processing…</p><pre>** TEST SUCCEEDED ** [9.950 sec]</pre><pre>Bisecting: 1 revision left to test after this (roughly 1 step)<br>[65c0d1ac4489241306692be4a7addbb38703aff3] maybe !</pre><pre>...</pre><pre>** TEST FAILED **</pre><pre>make: *** [uitest] Error 65<br>Bisecting: 0 revisions left to test after this (roughly 0 steps)<br>[c8da8ee9fa48736b63bdbec0e1e1a179612396b3] maybe</pre><pre>...</pre><pre>65c0d1ac4489241306692be4a7addbb38703aff3 is the first bad commit<br>commit 65c0d1ac4489241306692be4a7addbb38703aff3<br>Author: Marco Eidinger &lt;<a href="/service/mailto:eidingermarco@gmail.com">eidingermarco@gmail.com</a>&gt;<br>Date:   Wed Apr 20 08:45:34 2022 +0200</pre><pre>maybe !</pre><pre>FlakyApp/ContentView.swift | 2 +-<br> 1 file changed, 1 insertion(+), 1 deletion(-)</pre><p>Voila, we know the first bad commit is 65c0d1a !</p><p>Now that we know which commit is the culprit, we call the following commit to return to the original HEAD.</p><pre>git bisect reset</pre><p>Note: In this simplified example, we could have used git blame to identify the commit and root cause because there are few commits and the commits are very small. But imagine there are fifty commits with each for more than ten file changes of hundred lines!</p><ul><li>git bisect is perfect when you don&#39;t know what code caused a problem and are working on a large and frequently updated project.</li><li>Leverage tests to automate git bisect.</li><li>For iOS app use xcodebuild test.</li><li>For a Swift package, you can use xcodebuild as well or swift test.</li></ul><p><em>Originally published at </em><a href="https://blog.eidinger.info/git-bisect-run-xcodebuild"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=488b1f414d98" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/find-the-evil-commit-in-your-ios-application-with-git-bisect-488b1f414d98">Find the Evil Commit in Your iOS Application With Git Bisect</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Apple’s DeveloperToolsSupport Framework]]></title>
            <link>https://medium.com/better-programming/exploring-apples-developertoolssupport-framework-fe6bbee6bc3c?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe6bbee6bc3c</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 13:52:11 GMT</pubDate>
            <atom:updated>2022-08-23T13:52:11.729Z</atom:updated>
            <content:encoded><![CDATA[<h4>A look at the lesser-known framework</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TdETJ368u98qPomn" /><figcaption>Photo by <a href="https://unsplash.com/@miabaker?utm_source=medium&amp;utm_medium=referral">Mia Baker</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://developer.apple.com/documentation/developertoolssupport">DeveloperToolsSupport</a> is a little framework introduced in iOS 14+ / macOS 11+. It contains only one protocol and one structure. It enables developers to add custom SwiftUI views and view modifiers to the Xcode library.</p><h3>Xcode Library</h3><p>Open the Xcode library with keyboard shortcut shift-command-L (⇧⌘L)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U3CnDPz-7-khXo86" /></figure><p><strong>Important</strong>: The views and modifier tabs in the Xcode library are only visible if the Canvas is opened (⌥⌘↵)</p><h3>Adding your SwiftUI views and modifiers to the Xcode library</h3><blockquote><em>To add items to the library, create a structure that conforms to the LibraryContentProvider protocol and encapsulate any items you want to add as LibraryItem instances. Implement the views computed property to add library items containing views. Implement the modifiers(base:) method to add items containing view modifiers. Xcode harvests items from all of the library content providers in your project as you work, and makes them available to you in its library.</em></blockquote><p>Unfortunately, Xcode will not generate a default implementation when using the SwiftUI View file template. Instead you can use the menu option in Xcode to create a default implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HZ24E19vpaa20_qQ" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dda716fb930025151344171cdc17709/href">https://medium.com/media/5dda716fb930025151344171cdc17709/href</a></iframe><p>You can provide additional characteristics, like an alternative, through the LibraryItem initializer.</p><p><em>Note</em>: You don’t have to write an additional import statement for this framework. DeveloperToolsSupport is imported under the hood when you write the import SwiftUI statement.</p><p>Opening the Xcode library (⇧⌘L) will list this custom view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0wiBvVjKsDWOWlDg" /></figure><h3>Shortcomings</h3><p>I was pretty excited when I heard first about this feature. Quickly I realized that there are significant caveats:</p><ul><li>Xcode will not use your markdown documentation for your SwiftUI view as the description of the library item 😭 there is also no other way to add a description.</li><li>You cannot add an image or thumbnail to the library item.</li><li>Limited formatting options for the code snippet in your library item. This is only relevant if your init function takes multiple parameters and their types require deeply nested initialization. I recommend you specify everything inline.</li></ul><p>I still believe it makes sense to create library content providers for your reusable SwiftUI views because I hope that Apple and the Xcode team will overcome these shortcomings in the long run.</p><p>In my next blog post, I’ll show you how to add a custom file template to Xcode, which allows you to create a new SwiftUI file with a view, preview, and library content provider implementation in one shot.</p><p><em>Originally published at </em><a href="https://blog.eidinger.info/apples-developertoolssupport-framework"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe6bbee6bc3c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/exploring-apples-developertoolssupport-framework-fe6bbee6bc3c">Exploring Apple’s DeveloperToolsSupport Framework</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hot Reloading a SceneDelegate in Swift]]></title>
            <link>https://levelup.gitconnected.com/hot-reloading-a-scenedelegate-in-swift-cd9c23fcdf5e?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9c23fcdf5e</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Tue, 19 Jul 2022 14:58:05 GMT</pubDate>
            <atom:updated>2022-07-19T14:58:05.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v2lGni4wx53--fhz" /></figure><p>I told you about <a href="https://blog.eidinger.info/hot-reloading-a-swiftui-app">Hot Reloading a SwiftUI App</a> in my previous blog post.</p><p>In this blog post, I will tell you how to inject code that is not bound to a UI representation. Example: you need to change code in your scene delegate when testing the handling of custom URLs in a UIKit-based app.</p><p>You need the same tooling:</p><ul><li>Inject, a Swift Package created by Krzysztof Zabłocki</li><li>InjectionIII, a macOS application for the heavy lifting (i.e. watching for modified source code and interposing the new function as if it had been compiled into the SwiftUI app)</li></ul><p>I assume you made the necessary configurations in the Build Settings of your App (-Xlinker -interposable) and that you run the InjectIII.app on your Mac.</p><p>The critical difference is that we don’t use Inject.ViewControllerHost(...) or Inject.ViewHost(...). Instead we call the lazy property Inject.load in the AppDelegate so that InjectIII.app will watch for file changes right from the application start.</p><pre>import UIKit<br>import Inject</pre><pre><a href="http://twitter.com/main">@main</a><br>class AppDelegate: UIResponder, UIApplicationDelegate {</pre><pre>func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>        Inject.load // connects running iOS simulator with InjectIII.app<br>        return true<br>    }<br>    // ...<br>}</pre><p>That’s it !</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJIfip0s3KX8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJIfip0s3KX8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJIfip0s3KX8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e45cafaf71a4ae66f4902ed41160921/href">https://medium.com/media/8e45cafaf71a4ae66f4902ed41160921/href</a></iframe><p>In my video, I also prove that changes to SceneDelegate.swift will be injected and eventually executed when called by the iOS lifecycle handling.</p><p>For my video I <a href="https://developer.apple.com/documentation/xcode/defining-a-custom-url-scheme-for-your-app">registered a URL scheme</a> in the Info.plist.</p><p>I added the following function to the SceneDelegate class <em>before</em> running the app.</p><pre>func scene(_ scene: UIScene, openURLContexts URLContexts: Set&lt;UIOpenURLContext&gt;) {<br>    for context in URLContexts {<br>        print(&quot;url: \(context.url.absoluteURL)&quot;)<br>        print(&quot;scheme: \(String(describing: context.url.scheme))&quot;)<br>        print(&quot;host: \(String(describing: context.url.host))&quot;)<br>        print(&quot;path: \(context.url.path)&quot;)<br>        print(&quot;components: \(context.url.pathComponents)&quot;)<br>    }<br>}</pre><p>Once the app starts running in the iOS simulator, I change the implementation of scene(_:openURLContexts:)</p><p>Using the terminal command xcrun simctl openurl booted &lt;myCustomURLScheme&gt;, I invoke a custom URL in the running iOS simulator, and I witness that the injected code gets executed.</p><p><em>Originally published at </em><a href="https://blog.eidinger.info/hot-reloading-a-scenedelegate-in-swift"><em>https://blog.eidinger.info</em></a><em>.</em></p><h3>Level Up Coding</h3><p>Thanks for being a part of our community! Before you go:</p><ul><li>👏 Clap for the story and follow the author 👉</li><li>📰 View more content in <a href="https://levelup.gitconnected.com/">Level Up Coding</a></li><li>🔔 Follow us: <a href="https://twitter.com/gitconnected">Twitter</a> | <a href="https://www.linkedin.com/company/gitconnected">LinkedIn</a></li><li>🚀👉 <a href="https://jobs.levelup.dev/"><strong>Top jobs for software engineers</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9c23fcdf5e" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/hot-reloading-a-scenedelegate-in-swift-cd9c23fcdf5e">Hot Reloading a SceneDelegate in Swift</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best practices for open-source projects]]></title>
            <link>https://medium.com/geekculture/best-practices-for-open-source-projects-d447e2b235fe?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/d447e2b235fe</guid>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 05:02:32 GMT</pubDate>
            <atom:updated>2022-07-01T05:02:32.522Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you work on an open-source project, and do you want to give your consumers confidence in the quality and management of your project? You can achieve this, at no cost, by getting and showing off the <a href="https://bestpractices.coreinfrastructure.org/en">OpenSSF Best Practices Badge</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*gHj1W2GR9ds-EPDCsFmGKA.png" /></figure><p>The Open Source Security Foundation (OpenSSF) Best Practices Badge Program allows you to self-certify how well it follows best practices.</p><blockquote><em>The real goal of the OpenSSF Best Practices Badge project is to encourage projects to apply best practices, and to help users determine which FLOSS projects do so. We believe that FLOSS projects that implement best practices are more likely to produce better software, including more secure software.</em></blockquote><p>You can earn one of three badges:</p><ul><li><strong>Passing</strong> focuses on best practices that well-run FLOSS projects typically already follow. Getting the passing badge is an achievement; only about 10% of projects pursuing a badge achieve the passing level at any one time.</li><li><strong>Silver</strong> is a more stringent set of criteria than passing but is expected to be achievable by small and single-organization projects.</li><li><strong>Gold</strong> is even more stringent than silver and includes criteria not achievable by small or single-organization projects.</li></ul><p>More than 700 projects reached at least the <strong>passing</strong> level. <a href="https://bestpractices.coreinfrastructure.org/en/criteria">Here</a> is the complete set of criteria for all badge levels.</p><p>You can add the badge either through Markdown or HTML to your project page once you have answered the questions and fulfilled the requirements for the desired badge level.</p><p>You can find my open-source project <a href="https://bestpractices.coreinfrastructure.org/en/projects/5206">SwiftPlantUML</a> as one of the projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uNI1pq-5nCoZGHy7" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ptYwoh7uF3enQjM" /></figure><p>It took me about 30min to complete the questionnaire. I automatically fulfilled some requirements already by hosting my open-source project on GitHub. I also learned some new practices. Overall this exercise is valuable</p><ul><li>for you as a developer to learn</li><li>for your project consumers to gain confidence and trust</li></ul><p><em>Originally published at </em><a href="https://blog.eidinger.info/best-practices-for-open-source-projects"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d447e2b235fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/best-practices-for-open-source-projects-d447e2b235fe">Best practices for open-source projects</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hot Reloading a SwiftUI App]]></title>
            <link>https://levelup.gitconnected.com/hot-reloading-a-swiftui-app-77ba6ade1df7?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/77ba6ade1df7</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Tue, 14 Jun 2022 11:56:44 GMT</pubDate>
            <atom:updated>2022-06-14T11:56:44.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mdDUOqHR9OLw6zdX" /></figure><p>Change code and instantly see the updates in the iOS simulator without compiling your SwiftUI app!</p><p>You need</p><ul><li><a href="https://github.com/krzysztofzablocki/Inject">Inject</a>, a Swift Package created by <a href="https://twitter.com/merowing_">Krzysztof Zabłocki</a></li><li><a href="https://github.com/johnno1962/InjectionIII">InjectionIII</a>, a macOS application for the heavy lifting (i.e. watching for modified source code and interposing the new function as if it had been compiled into the SwiftUI app)</li></ul><p>You can read more about the Swift Package in the following article.</p><p><a href="https://www.merowing.info/2022/04/hot-reloading-in-swift/">Hot Reloading in Swift</a></p><p>I also recommend reading the book “Swift Secrets” by John Holdsworth. He is the creator of InjectionIII (also known as &quot;Injection for Xcode) and shares the concept of how hot reloading for iOS development is possible in the first place!</p><p><a href="https://books.apple.com/us/book/swift-secrets/id1551005489">‎Swift Secrets</a></p><p>There is plenty of reading material, so I want to show you hot reloading in action! I show you all the steps needed to instrument your SwiftUI app in my YouTube video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FamBkjVfgFL8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DamBkjVfgFL8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FamBkjVfgFL8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff3dcd883357b2ca251ebb697bb59b26/href">https://medium.com/media/ff3dcd883357b2ca251ebb697bb59b26/href</a></iframe><ol><li>Add the Swift Package</li><li>Import its module in the source file containing your SwiftUI view</li><li>Add @ObservedObject private var iO = Inject.observer variable to your SwiftUI View</li><li>call .enableInjection() at the end of your view&#39;s body definition</li></ol><p>The video skips how to install InjectionIII.app (see <a href="https://github.com/krzysztofzablocki/Inject#individual-developer-setup-once-per-machine">here</a> for details) but I&#39;ll show you how to use macOS application.</p><p>I also share some observations and tricks and tips!</p><p>You can find the test app on my GitHub and the commit history visualizes each step done for instrumenting the SwiftUI app for hot reloading.</p><p><a href="https://github.com/MarcoEidinger/InjectSwiftUIExample">GitHub - MarcoEidinger/InjectSwiftUIExample: Example how to use krzysztofzablocki/Inject in a SwiftUI application</a></p><p><em>Originally published at </em><a href="https://blog.eidinger.info/hot-reloading-a-swiftui-app"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77ba6ade1df7" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/hot-reloading-a-swiftui-app-77ba6ade1df7">Hot Reloading a SwiftUI App</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Dump SwiftUI Environment Efficiently]]></title>
            <link>https://medium.com/better-programming/how-to-dump-swiftui-environment-efficiently-1bdf12ef37ed?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bdf12ef37ed</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Thu, 26 May 2022 18:29:56 GMT</pubDate>
            <atom:updated>2022-05-26T18:29:56.756Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to print environment values efficiently for debugging purposes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E6MaUeNFBjzkeHMv" /></figure><p>This blog post will explain how to print environment values efficiently for debugging purposes. Therefore, you can inspect which actual value is used on a specific view hierarchy level.</p><h3>A quick recap about SwiftUI Environment</h3><p>SwiftUI uses the environment to pass values for <a href="https://www.fivestars.blog/articles/swiftui-environment-values/">pre-defined types</a> down the view hierarchy.</p><p>By using @Environment property wrapper, we can read and subscribe on changes for the selected value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e71bbbb4f365e12c81313c4413deaca2/href">https://medium.com/media/e71bbbb4f365e12c81313c4413deaca2/href</a></iframe><p>We can also <a href="https://useyourloaf.com/blog/swiftui-custom-environment-values/">create your custom environment values</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99292efb60ef3d1e4d0084caa87e8734/href">https://medium.com/media/99292efb60ef3d1e4d0084caa87e8734/href</a></iframe><p>We are using the environment view modifier to inject our custom environment value into the SwiftUI environment. Values can be overridden on a lower view hierarchy level. Here is an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bba8be6337f7b96be7b00ff28829ad1b/href">https://medium.com/media/bba8be6337f7b96be7b00ff28829ad1b/href</a></iframe><h3>Dump a simple value</h3><p>The low-key debugging option is to use the transformEnvironment function in combination with the dump function from the Swift Standard Library.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de8d63a9878351720b9df2c35fa2b37e/href">https://medium.com/media/de8d63a9878351720b9df2c35fa2b37e/href</a></iframe><p>Dump will print the given object&#39;s contents using its mirror to the standard output. The printed result in the Xcode debug console shows, that on this view hierarchy level, the magic color is blue (as expected).</p><pre>▿ blue<br>  ▿ provider: SwiftUI.(unknown context at $7fff5dc005b0).ColorBox&lt;SwiftUI.SystemColorType&gt; #0<br>    - super: SwiftUI.AnyColorBox<br>      - super: SwiftUI.AnyShapeStyleBox<br>    - base: SwiftUI.SystemColorType.blue</pre><h3>Dump all values</h3><p>Chris Eidhoff shares a code snippet in his article <a href="https://www.objc.io/blog/2019/10/29/swiftui-environment/">SwiftUI: Setting Environment Values </a>to inspect the current environment for a view using the following utility wrapper view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd0a05c010caf801a8a06d4a2588a476/href">https://medium.com/media/bd0a05c010caf801a8a06d4a2588a476/href</a></iframe><p>For example, we could dump the environment for a leaf node of the view above:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff5402240d02e82c8c62712ea32e0c57/href">https://medium.com/media/ff5402240d02e82c8c62712ea32e0c57/href</a></iframe><p>This solution works fine and can easily be copied and used in other projects. But when we run the code, it prints a colossal tree of a serialized property list.</p><pre>▿ _plist: [EnvironmentPropertyKey&lt;MagicColorKey&gt; = blue, EnvironmentPropertyKey&lt;MagicColorKey&gt; = red, EnvironmentPropertyKey&lt;RedactionReasonsKey&gt; = RedactionReasons(rawValue: 2), EnvironmentPropertyKey&lt;SceneStorageValuesKey&gt; = Optional(SwiftUI.WeakBox&lt;SwiftUI.SceneStorageValues&gt;(base: Optional(SwiftUI.SceneStorageValues))), EnvironmentPropertyKey&lt;StoreKey&lt;SceneBridge&gt;&gt; = Optional(SceneBridge: rootViewController = Optional(&lt;_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x7f915800c530&gt;)), EnvironmentPropertyKey&lt;AppNavigationAuthorityKey&gt; = Optional(SwiftUI.WeakBox&lt;SwiftUI.AppNavigationAuthority&gt;(base: Optional(SwiftUI.AppNavigationAuthority))), EnvironmentPropertyKey&lt;EditModeKey&gt; = Optional(SwiftUI.Binding&lt;SwiftUI.EditMode&gt;(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.StoredLocation&lt;SwiftUI.EditMode&gt;, _value: SwiftUI.EditMode.inactive)), EnvironmentPropertyKey&lt;InputAccessoryKey&gt; = WeakBox&lt;InputAccessoryGenerator&lt;SwiftUIToolbar&gt;&gt;(base: nil), EnvironmentPropertyKey&lt;CanTakeFocusKey&gt; = false, EnvironmentPropertyKey&lt;IsPlatformFocusSystemEnabled&gt; = false, EnvironmentPropertyKey&lt;IsFocusedKey&gt; = false, EnvironmentPropertyKey&lt;FocusBridgeKey&gt; = WeakBox&lt;FocusBridge&gt;(base: Optional(SwiftUI.FocusBridge)), EnvironmentPropertyKey&lt;AllowedBehaviorsKey&gt; = HostingControllerAllowedBehaviors(rawValue: 16), EnvironmentPropertyKey&lt;ActiveContextMenuKey&gt; = ViewIdentity(seed: 0), EnvironmentPropertyKey&lt;Key&gt; = Optional(SwiftUI.NavigationAuthority(host: Optional(&lt;_TtGC7SwiftUI14_UIHostingViewGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x7f91581066f0; frame = (0 0; 390 844); autoresize = W+H; gestureRecognizers = &lt;NSArray: 0x600003b52fa0&gt;; layer = &lt;CALayer: 0x6000035073c0&gt;&gt;))), EnvironmentPropertyKey&lt;PresentationModeKey&gt; = Binding&lt;PresentationMode&gt;(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.LocationBox&lt;SwiftUI.FunctionalLocation&lt;SwiftUI.PresentationMode&gt;&gt;, _value: SwiftUI.PresentationMode(isPresented: false)), EnvironmentPropertyKey&lt;AccessibilityRequestFocusKey&gt; = AccessibilityRequestFocusAction(onAccessibilityFocus: nil), EnvironmentPropertyKey&lt;AccentColorKey&gt; = Optional(#007AFFFF), EnvironmentPropertyKey&lt;HostingViewOpenURLActionKey&gt; = Optional(SwiftUI.OpenURLAction(handler: SwiftUI.OpenURLAction.Handler.system((Function)), isDefault: false)), EnvironmentPropertyKey&lt;UndoManagerKey&gt; = Optional(&lt;NSUndoManager: 0x60000161a620&gt;), EnvironmentPropertyKey&lt;SceneSessionKey&gt; = Optional(SwiftUI.WeakBox&lt;__C.UISceneSession&gt;(base: Optional(&lt;UISceneSession: 0x600002066140; scene = &lt;UIWindowScene: 0x7f9158008d60; sceneIdentifier: &quot;sceneID:us.eidinger.DateExample-F8369E9A-67DA-48FC-BAB6-EC1A5D8D56CC&quot;&gt;; role = UIWindowSceneSessionRoleApplication; sceneConfiguration = &lt;UISceneConfiguration: 0x600002066240&gt;; persistentIdentifier = F8369E9A-67DA-48FC-BAB6-EC1A5D8D56CC; userInfo = &lt;(null): 0x0&gt;))), EnvironmentPropertyKey&lt;SystemColorSchemeKey&gt; = light, EnvironmentPropertyKey&lt;ExplicitPreferredColorSchemeKey&gt; = nil, EnvironmentPropertyKey&lt;AccessibilityLargeContentViewerKey&gt; = false, EnvironmentPropertyKey&lt;EnabledTechnologiesKey&gt; = AccessibilityTechnologies(technologySet: SwiftUI.(unknown context at $7fff5dc3e438).AccessibilityTechnologySet(rawValue: 0)), EnvironmentPropertyKey&lt;AccessibilityButtonShapesKey&gt; = false, EnvironmentPropertyKey&lt;AccessibilityPrefersCrossFadeTransitionsKey&gt; = false, EnvironmentPropertyKey&lt;AccessibilityInvertColorsKey&gt; = false, EnvironmentPropertyKey&lt;AccessibilityReduceMotionKey&gt; = false, EnvironmentPropertyKey&lt;AccessibilityReduceTransparencyKey&gt; = false, EnvironmentPropertyKey&lt;AccessibilityDifferentiateWithoutColorKey&gt; = false, EnvironmentPropertyKey&lt;BackgroundInfoKey&gt; = BackgroundInfo(layer: 0, groupCount: 0), EnvironmentPropertyKey&lt;VerticalUserInterfaceSizeClassKey&gt; = Optional(SwiftUI.UserInterfaceSizeClass.regular), EnvironmentPropertyKey&lt;HorizontalUserInterfaceSizeClassKey&gt; = Optional(SwiftUI.UserInterfaceSizeClass.compact), EnvironmentPropertyKey&lt;DisplayScaleKey&gt; = 3.0, EnvironmentPropertyKey&lt;ColorSchemeKey&gt; = light, EnvironmentPropertyKey&lt;ColorSchemeContrastKey&gt; = standard, EnvironmentPropertyKey&lt;DisplayGamutKey&gt; = displayP3, EnvironmentPropertyKey&lt;LegibilityWeightKey&gt; = Optional(SwiftUI.LegibilityWeight.regular), EnvironmentPropertyKey&lt;DynamicTypeSizeKey&gt; = large, EnvironmentPropertyKey&lt;LayoutDirectionKey&gt; = leftToRight, EnvironmentPropertyKey&lt;ScenePhaseKey&gt; = inactive, EnvironmentPropertyKey&lt;TimeZoneKey&gt; = America/Los_Angeles (fixed (equal to current)), EnvironmentPropertyKey&lt;CalendarKey&gt; = gregorian (current), EnvironmentPropertyKey&lt;LocaleKey&gt; = en_US (current)]<br>    ▿ elements: Optional(EnvironmentPropertyKey&lt;MagicColorKey&gt; = blue)<br>      ▿ some: EnvironmentPropertyKey&lt;MagicColorKey&gt; = blue #0<br>        ▿ super: SwiftUI.PropertyList.Element<br>          - keyType: SwiftUI.(unknown context at $7fff5dca9ff0).EnvironmentPropertyKey&lt;DateExample.(unknown context at $1011eaf88).MagicColorKey&gt; #1<br>          - before: nil<br>          ▿ after: Optional(EnvironmentPropertyKey&lt;MagicColorKey&gt; = red)<br>            ▿ some: EnvironmentPropertyKey&lt;MagicColorKey&gt; = red #2<br>              ▿ super: SwiftUI.PropertyList.Element<br>                - keyType: SwiftUI.(unknown context at $7fff5dca9ff0).EnvironmentPropertyKey&lt;DateExample.(unknown context at $1011eaf88).MagicColorKey&gt; #1<br>                - before: nil<br>                ▿ after: Optional(EnvironmentPropertyKey&lt;RedactionReasonsKey&gt; = RedactionReasons(rawValue: 2))<br>                  ▿ some: EnvironmentPropertyKey&lt;RedactionReasonsKey&gt; = RedactionReasons(rawValue: 2) #3<br>                    ▿ ...</pre><p>Too huge!</p><p>The complete environment with all its values across all hierarchy levels is dumped.</p><p>We need to read the output from top to bottom and ignore subsequent entries for the same EnvironmentPropertyKey (as the top-level value for a EnvironmentPropertyKey is the used one)</p><p>In most cases, a more efficient way is to use a custom function to print out the environment values.</p><p>My initial approach was to split(separator: &quot;,&quot;) the description of EnvironmentValues as EnvironmentValues conforms to CustomStringConvertible.</p><p>However, this does not work correctly for value descriptions containing a comma and also the printout still contains multiple entries for the same key.</p><p>I ended up with the following “good enough” implementation</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/261063aa88aaf802cbb4909cd527ac57/href">https://medium.com/media/261063aa88aaf802cbb4909cd527ac57/href</a></iframe><p>Now ~ 50 lines (instead of ~ 1160 lines !!!) are printed.</p><p>Example:</p><pre>--- Environment Values - BEGIN ---<br>EnvironmentPropertyKey&lt;MagicColorKey&gt; = blue<br>EnvironmentPropertyKey&lt;SceneStorageValuesKey&gt; = Optional(SwiftUI.WeakBox&lt;SwiftUI.SceneStorageValues&gt;(base: Optional(SwiftUI.SceneStorageValues)))<br>EnvironmentPropertyKey&lt;StoreKey&lt;SceneBridge&gt;&gt; = Optional(SceneBridge: rootViewController = Optional(&lt;_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x7f97bcb0aef0&gt;))<br>EnvironmentPropertyKey&lt;AppNavigationAuthorityKey&gt; = Optional(SwiftUI.WeakBox&lt;SwiftUI.AppNavigationAuthority&gt;(base: Optional(SwiftUI.AppNavigationAuthority)))<br>EnvironmentPropertyKey&lt;EditModeKey&gt; = Optional(SwiftUI.Binding&lt;SwiftUI.EditMode&gt;(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.StoredLocation&lt;SwiftUI.EditMode&gt;, _value: SwiftUI.EditMode.inactive))<br>EnvironmentPropertyKey&lt;InputAccessoryKey&gt; = WeakBox&lt;InputAccessoryGenerator&lt;SwiftUIToolbar&gt;&gt;(base: nil)<br>EnvironmentPropertyKey&lt;CanTakeFocusKey&gt; = true<br>EnvironmentPropertyKey&lt;IsPlatformFocusSystemEnabled&gt; = false<br>EnvironmentPropertyKey&lt;IsFocusedKey&gt; = false<br>EnvironmentPropertyKey&lt;FocusBridgeKey&gt; = WeakBox&lt;FocusBridge&gt;(base: Optional(SwiftUI.FocusBridge))<br>EnvironmentPropertyKey&lt;AllowedBehaviorsKey&gt; = HostingControllerAllowedBehaviors(rawValue: 16)<br>EnvironmentPropertyKey&lt;ActiveContextMenuKey&gt; = ViewIdentity(seed: 0)<br>EnvironmentPropertyKey&lt;Key&gt; = Optional(SwiftUI.NavigationAuthority(host: Optional(&lt;_TtGC7SwiftUI14_UIHostingViewGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x7f97bcb0b670; frame = (0 0; 390 844); autoresize = W+H; gestureRecognizers = &lt;NSArray: 0x600000d47cf0&gt;; layer = &lt;CALayer: 0x60000032e980&gt;&gt;)))<br>EnvironmentPropertyKey&lt;PresentationModeKey&gt; = Binding&lt;PresentationMode&gt;(transaction: SwiftUI.Transaction(plist: []), location: SwiftUI.LocationBox&lt;SwiftUI.FunctionalLocation&lt;SwiftUI.PresentationMode&gt;&gt;, _value: SwiftUI.PresentationMode(isPresented: false))<br>EnvironmentPropertyKey&lt;AccessibilityRequestFocusKey&gt; = AccessibilityRequestFocusAction(onAccessibilityFocus: nil)<br>EnvironmentPropertyKey&lt;AccentColorKey&gt; = Optional(#007AFFFF)<br>EnvironmentPropertyKey&lt;HostingViewOpenURLActionKey&gt; = Optional(SwiftUI.OpenURLAction(handler: SwiftUI.OpenURLAction.Handler.system((Function)), isDefault: false))<br>EnvironmentPropertyKey&lt;UndoManagerKey&gt; = Optional(&lt;NSUndoManager: 0x600002039270&gt;)<br>EnvironmentPropertyKey&lt;SceneSessionKey&gt; = Optional(SwiftUI.WeakBox&lt;__C.UISceneSession&gt;(base: Optional(&lt;UISceneSession: 0x600001641200; scene = &lt;UIWindowScene: 0x7f97bcb0a040; sceneIdentifier: &quot;sceneID:us.eidinger.DateExample-F8369E9A-67DA-48FC-BAB6-EC1A5D8D56CC&quot;&gt;; role = UIWindowSceneSessionRoleApplication; sceneConfiguration = &lt;UISceneConfiguration: 0x600001641300&gt;; persistentIdentifier = F8369E9A-67DA-48FC-BAB6-EC1A5D8D56CC; userInfo = &lt;(null): 0x0&gt;)))<br>EnvironmentPropertyKey&lt;SystemColorSchemeKey&gt; = light<br>EnvironmentPropertyKey&lt;ExplicitPreferredColorSchemeKey&gt; = nil<br>EnvironmentPropertyKey&lt;AccessibilityLargeContentViewerKey&gt; = false<br>EnvironmentPropertyKey&lt;EnabledTechnologiesKey&gt; = AccessibilityTechnologies(technologySet: SwiftUI.(unknown context at $7fff5dc3e438).AccessibilityTechnologySet(rawValue: 0))<br>EnvironmentPropertyKey&lt;AccessibilityButtonShapesKey&gt; = false<br>EnvironmentPropertyKey&lt;AccessibilityPrefersCrossFadeTransitionsKey&gt; = false<br>EnvironmentPropertyKey&lt;AccessibilityInvertColorsKey&gt; = false<br>EnvironmentPropertyKey&lt;AccessibilityReduceMotionKey&gt; = false<br>EnvironmentPropertyKey&lt;AccessibilityReduceTransparencyKey&gt; = false<br>EnvironmentPropertyKey&lt;AccessibilityDifferentiateWithoutColorKey&gt; = false<br>EnvironmentPropertyKey&lt;BackgroundInfoKey&gt; = BackgroundInfo(layer: 0, groupCount: 0)<br>EnvironmentPropertyKey&lt;VerticalUserInterfaceSizeClassKey&gt; = Optional(SwiftUI.UserInterfaceSizeClass.regular)<br>EnvironmentPropertyKey&lt;HorizontalUserInterfaceSizeClassKey&gt; = Optional(SwiftUI.UserInterfaceSizeClass.compact)<br>EnvironmentPropertyKey&lt;DisplayScaleKey&gt; = 3.0<br>EnvironmentPropertyKey&lt;ColorSchemeKey&gt; = light<br>EnvironmentPropertyKey&lt;ColorSchemeContrastKey&gt; = standard<br>EnvironmentPropertyKey&lt;DisplayGamutKey&gt; = displayP3<br>EnvironmentPropertyKey&lt;LegibilityWeightKey&gt; = Optional(SwiftUI.LegibilityWeight.regular)<br>EnvironmentPropertyKey&lt;DynamicTypeSizeKey&gt; = large<br>EnvironmentPropertyKey&lt;LayoutDirectionKey&gt; = leftToRight<br>EnvironmentPropertyKey&lt;ScenePhaseKey&gt; = active<br>EnvironmentPropertyKey&lt;TimeZoneKey&gt; = America/Los_Angeles (fixed (equal to current))<br>EnvironmentPropertyKey&lt;CalendarKey&gt; = gregorian (current)<br>--- Environment Values - END ---</pre><p>The inner works of the SwiftUI environment handling are hidden. This is ok for most situations. One noticeable drawback is that the printed result for Font is not helpful as its description does not contain the font name/style information.</p><pre><strong>Want to Connect?</strong></pre><pre>Originally published at <a href="https://blog.eidinger.info/dump-swiftui-environment-efficiently">https://blog.eidinger.info</a>.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bdf12ef37ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-dump-swiftui-environment-efficiently-1bdf12ef37ed">How to Dump SwiftUI Environment Efficiently</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate a complex Swift Package into your iOS app]]></title>
            <link>https://marcoeidinger.medium.com/integrate-a-complex-swift-package-into-your-ios-app-6690d77958c1?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/6690d77958c1</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-package-manager]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Thu, 26 May 2022 12:06:21 GMT</pubDate>
            <atom:updated>2022-05-26T12:06:21.202Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog post I help app developers to understand the terminology of a Swift Package and how to integrate a more complex structured Swift Package in an iOS application.</p><p>The simplest package structure, created by the swift package init command, consists of</p><ul><li>a package</li><li>with a single product (type: library)</li><li>using a single target (+ a test target)</li></ul><p>The names of all those package/product/target is identical.</p><p>Let’s look at a more complex example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5izxw_x6dYkvCz4iOgc7Hg.png" /></figure><p>This package (named Package2 here) offers two <em>library</em> products. Each product has its own target. Each target makes use of a library offered by a package dependency.</p><p>Let me start explaining the different building blocks from the view of an <em>app developer</em>.</p><ul><li>You want to use functionality from a package =&gt; you add the <em>package</em> to your Xcode project.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bUTsG1HW4OLw9iV4" /></figure><ul><li>You want to use a library =&gt; <strong>you add a library <em>product</em> to your app target in Xcode</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HZRrFy-_C1-8spuA" /></figure><ul><li>Finally, when importing related code from the library =&gt; you <strong>you are using the </strong><strong>import &lt;target/module&gt; statement</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hgJLM02AOlXoc6Nm" /></figure><p>In this example the module Package2TargetB offers a public struct API_B.</p><blockquote><em>A Swift target is pretty much equal to a Swift module, so they are often used interchangeably. A module specifies a namespace and enforces access controls on which parts of that code can be used outside of the module.</em></blockquote><p>I highly recommend reading the definition given by Jeremy David Giesbrecht in the <a href="https://forums.swift.org/t/module-vs-product-vs-target/27640/2">Swift Forum</a>. It speaks more to package developers.</p><p><em>Originally published at </em><a href="https://blog.eidinger.info/integrate-a-complex-swift-package-into-your-ios-app"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6690d77958c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What can go wrong when using custom fonts in SwiftUI]]></title>
            <link>https://levelup.gitconnected.com/what-can-go-wrong-when-using-custom-fonts-in-swiftui-93d6252600e6?source=rss-c0984445ac73------2</link>
            <guid isPermaLink="false">https://medium.com/p/93d6252600e6</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Marco Eidinger]]></dc:creator>
            <pubDate>Mon, 23 May 2022 17:59:36 GMT</pubDate>
            <atom:updated>2022-05-25T23:05:24.455Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog post is targeting SDK developers who bundle custom fonts in their package/library/framework and these <a href="https://developer.apple.com/documentation/swiftui/applying-custom-fonts-to-text">fonts shall be used in reusable SwiftUI views</a>.</p><p>I will explain an issue observable when using font weight related view modifiers (like bold) on a non-registered custom font.</p><p>Let’s assume you added the <a href="https://fonts.google.com/specimen/Open+Sans">Open Sans</a> true type font files to your bundle</p><ul><li>OpenSans-Regular.ttf</li><li>OpenSans-Bold.ttf</li><li>…</li></ul><p>You also provide reusable SwiftUI views which shall automatically leverage the custom font. To do so you can pass the result of Font.custom(:size) to the font view modifier.</p><pre>struct ReusableView: View {<br>    var body: some View {<br>        Text(&quot;Use Font.custom directly&quot;)<br>            .font(.custom(&quot;OpenSans-Regular&quot;, size: 17))<br>            .bold()<br>    }<br>}</pre><p>If you use the bold view modifier then SwiftUI is smart enough to load OpenSans-Bold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/0*QbehgEhRnFIa87Xn" /></figure><p>This all works well as long as the app developer did not forget to register the font in the app for use.</p><pre>Font.registerOpenSans()</pre><pre>extension Font {<br>    static func registerOpenSans() {<br>        self.register(name: &quot;OpenSans-Regular&quot;, withExtension: &quot;ttf&quot;)<br>        self.register(name: &quot;OpenSans-Bold&quot;, withExtension: &quot;ttf&quot;)<br>        // ...<br>    }</pre><pre>    static func register(name: String, withExtension: String) {<br>        let fontURL = Bundle.main.url(/service/forresource: name, withExtension: withExtension)!<br>        var error: Unmanaged&lt;CFError&gt;?<br>        CTFontManagerRegisterFontsForURL(fontURL as CFURL, .process, &amp;error)<br>        if let error = error {<br>            print(error.takeUnretainedValue())<br>        }<br>    }<br>}</pre><p>So what if the app developer forgot to register the font?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*ppOMw6kBcJVK2bzp" /></figure><p>You might expected that the <strong>bold</strong> font weight would still gets applied. But this is not the case. Apple Bug ?</p><p>To ensure that the font weight gets applied, no matter what, I recommend to use an extension. This extension either loads the font or fallbacks to the system font.</p><pre>extension Font {<br>    /// get &quot;Open Sans&quot; font or fallbacks to the system font in case the custom font was not registered<br>    /// - Parameter size: size of font<br>    /// - Returns: &quot;Open Sans&quot; font (or sytem font as fallback)<br>    static func openSans(size: CGFloat) -&gt; Font {<br>        guard UIFont.familyNames.contains(&quot;Open Sans&quot;) else {<br>            return Font.system(size: size)<br>        }<br>        return .custom(&quot;OpenSans-Regular&quot;, size: size)<br>    }<br>}</pre><p>This will ensure that SwiftUI will be able to apply font weight even to a fallback font.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*3Bfj15aKztbMW9Y3" /></figure><pre>struct ReusableView: View {<br>    var body: some View {<br>        VStack(alignment: .leading) {<br>            Text(&quot;Use extension with fallback handling&quot;)<br>                .font(.openSans(size: 17))<br>                .bold()</pre><pre>        Text(&quot;Use Font.custom directly&quot;)<br>                .font(.custom(&quot;OpenSans-Regular&quot;, size: 17))<br>                .bold()<br>        }<br>    }<br>}</pre><p>Of course the result is the same in case the font was registered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*7lDSTvHI9q6QaMx4" /></figure><p><em>Originally published at </em><a href="https://blog.eidinger.info/what-can-go-wrong-when-using-custom-fonts-in-swiftui"><em>https://blog.eidinger.info</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93d6252600e6" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/what-can-go-wrong-when-using-custom-fonts-in-swiftui-93d6252600e6">What can go wrong when using custom fonts in SwiftUI</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>