<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Package Archives - Forest and the Trees</title>
	<atom:link href="https://www.forestandthetrees.com/tag/package/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.forestandthetrees.com/tag/package/</link>
	<description>iOS Development</description>
	<lastBuildDate>Sun, 02 Jan 2022 22:58:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://www.forestandthetrees.com/wp-content/uploads/2021/11/cropped-fatt-32x32.png</url>
	<title>Package Archives - Forest and the Trees</title>
	<link>https://www.forestandthetrees.com/tag/package/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Asset Colors in Packages</title>
		<link>https://www.forestandthetrees.com/ios/asset-colors-in-packages/</link>
					<comments>https://www.forestandthetrees.com/ios/asset-colors-in-packages/#comments</comments>
		
		<dc:creator><![CDATA[Doug Marttila]]></dc:creator>
		<pubDate>Sun, 02 Jan 2022 22:53:41 +0000</pubDate>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Package]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[Xcode]]></category>
		<guid isPermaLink="false">https://www.forestandthetrees.com/?p=131</guid>

					<description><![CDATA[<p>Xcode allows you to easily add custom colors to the Assets file in your project. Add a Color Set, then use the Inspector to modify the color. To use your new color in your project, adding a color extension with the custom color&#8217;s name makes your life easier. Example below&#8230; Then you can do things [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.forestandthetrees.com/ios/asset-colors-in-packages/">Asset Colors in Packages</a> appeared first on <a rel="nofollow" href="https://www.forestandthetrees.com">Forest and the Trees</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Xcode allows you to easily add custom colors to the Assets file in your project. Add a Color Set, then use the Inspector to modify the color. </p>



<p>To use your new color in your project, adding a color extension with the custom color&#8217;s name makes your life easier. Example below&#8230;</p>



<pre class="wp-block-code"><code lang="swift" class="language-swift">extension Color {
    static let myAwesomeClr = Color("theNameOfMyColorInAssets")
}</code></pre>



<p>Then you can do things like&#8230;</p>



<pre class="wp-block-code"><code lang="swift" class="language-swift">Color(.myAwesomeClr)</code></pre>



<p>If you want to include that color in a Package, you need to..</p>



<ul><li>Declare your extension public (like everything in a Package) </li><li>Create a UIColor and cast that as a Color. (This took me a while to figure out which is why I am posting this.) See below&#8230;</li></ul>



<pre class="wp-block-code"><code lang="swift" class="language-swift">public extension Color {
    static let <meta charset="utf-8">myAwesomeClr = Color(UIColor(named: "<meta charset="utf-8">theNameOfMyColorInAssets", in: .module, compatibleWith: nil)!)
}</code></pre>



<ul><li>And, you need to add a resource target to your Package file&#8230;</li></ul>



<pre class="wp-block-code"><code lang="swift" class="language-swift">let package = Package(
    name: "YourPackageName",
    
... some common package info here omitted for this example ....

    targets: [
        .target(
            name: "YourPackageName",
            dependencies: [],
            resources: [
                .process("Assets.xcassets"),
            ]
            ),
        .testTarget(
...  more code here ....
</code></pre>



<p>Where Assets is the name of the media file that has your color.</p>
<p>The post <a rel="nofollow" href="https://www.forestandthetrees.com/ios/asset-colors-in-packages/">Asset Colors in Packages</a> appeared first on <a rel="nofollow" href="https://www.forestandthetrees.com">Forest and the Trees</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.forestandthetrees.com/ios/asset-colors-in-packages/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Dynamic Alert Package for iOS 13 &#8211; 14</title>
		<link>https://www.forestandthetrees.com/uncategorized/dynamic-alert-package-for-ios-13-14/</link>
					<comments>https://www.forestandthetrees.com/uncategorized/dynamic-alert-package-for-ios-13-14/#respond</comments>
		
		<dc:creator><![CDATA[Doug Marttila]]></dc:creator>
		<pubDate>Mon, 27 Dec 2021 19:36:37 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Package]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[Xcode]]></category>
		<guid isPermaLink="false">https://www.forestandthetrees.com/?p=115</guid>

					<description><![CDATA[<p>If you need to create a simple alert popup, read Paul Hudson&#8217;s post. (The post also covers how to create alerts in the newer, iOS-15 way.) I needed a way for a single view to show alerts with one button, with two buttons, and with two buttons and a destructive action (destructive actions are shown [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.forestandthetrees.com/uncategorized/dynamic-alert-package-for-ios-13-14/">Dynamic Alert Package for iOS 13 &#8211; 14</a> appeared first on <a rel="nofollow" href="https://www.forestandthetrees.com">Forest and the Trees</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you need to create a simple alert popup, <a href="https://www.hackingwithswift.com/quick-start/swiftui/how-to-show-an-alert" data-type="URL" data-id="https://www.hackingwithswift.com/quick-start/swiftui/how-to-show-an-alert">read Paul Hudson&#8217;s post</a>. (The post also covers how to create alerts in the newer, iOS-15 way.)</p>



<p>I needed a way for a single view to show alerts with one button, with two buttons, and with two buttons and a destructive action (destructive actions are shown in red). I came up with a solution for <a href="https://www.forestandthetrees.com/fasty-mcfastface/" data-type="URL" data-id="https://www.forestandthetrees.com/fasty-mcfastface/">Fasty</a>, then I wanted to use it in another project, <a href="https://github.com/dmarttila/AlertPopUp-iOS13" data-type="URL" data-id="https://github.com/dmarttila/AlertPopUp-iOS13">so I put it in a package.</a></p>



<p>To use:</p>



<ol><li>Import the package</li><li>Add &#8220;@State private var alertParams: AlertParams?&#8221; to the view that you want to have the Alert.</li><li>At the bottom of that view, add: &#8220;.modifier(AlertModifier(alertParams: $alertParams))&#8221;</li><li>Add the following (or something similar) to the view: Button(&#8220;Pop up an alert with one button and an action&#8221;) { alertParams = AlertParams(title: &#8220;One Button&#8221;, message: &#8220;One button that calls an action&#8221;, primaryButtonLabel: &#8220;The button label&#8221;) { print(&#8220;The user clicked the Alert button&#8221;) } }</li></ol>



<pre class="wp-block-code"><code lang="swift" class="language-swift line-numbers">import SwiftUI
import AlertPopUp_iOS13

struct ContentView: View {
    @State private var alertParams: AlertParams?
    
    var body: some View {
        VStack {
            Button("Pop up an alert with one button and an action") {
                alertParams = AlertParams(title: "One Button", message: "One button that calls an action", primaryButtonLabel: "The button label") { print("The user clicked the Alert button") }
            }
        }
        .modifier(AlertModifier(alertParams: $alertParams))
        .padding()
    }
}</code></pre>



<p>The <a href="https://github.com/dmarttila/AlertPopUp-iOS13#readme">readMe</a> gives more details. </p>



<p><a href="https://github.com/dmarttila/AlertPopupsUsingPackage">Here&#8217;s a sample project that uses the package.</a></p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.forestandthetrees.com/uncategorized/dynamic-alert-package-for-ios-13-14/">Dynamic Alert Package for iOS 13 &#8211; 14</a> appeared first on <a rel="nofollow" href="https://www.forestandthetrees.com">Forest and the Trees</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.forestandthetrees.com/uncategorized/dynamic-alert-package-for-ios-13-14/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
