<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Thomas Prezioso Jr.</title>
    <description>The latest articles on Forem by Thomas Prezioso Jr. (@tprezioso).</description>
    <link>https://forem.com/tprezioso</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F113992%2F891cf630-0a96-4044-9d10-f86d7ca1e2ef.jpg</url>
      <title>Forem: Thomas Prezioso Jr.</title>
      <link>https://forem.com/tprezioso</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/tprezioso"/>
    <language>en</language>
    <item>
      <title>How to Know When Your App Becomes Active or Inactive in SwiftUI</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Sat, 02 Oct 2021 16:46:29 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-know-when-your-app-becomes-active-or-inactive-in-swiftui-52n2</link>
      <guid>https://forem.com/tprezioso/how-to-know-when-your-app-becomes-active-or-inactive-in-swiftui-52n2</guid>
      <description>&lt;p&gt;Recently I was working on a SwiftUI project were I needed to know when my app became active from being in the background. Like most things in SwiftUI, I found out that this was really simple to implement in my project. &lt;/p&gt;

&lt;p&gt;In SwiftUI we have a environment element called &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/scenephase"&gt;scenePhase&lt;/a&gt;&lt;/strong&gt;. What &lt;strong&gt;&lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/scenephase"&gt;scenePhase&lt;/a&gt;&lt;/strong&gt;&lt;/strong&gt; allows us to do is monitor if the app is Active, Inactive, or in the Background. Lets take a look at how we can use this in our project. &lt;/p&gt;

&lt;p&gt;The first thing we will need to do is add the following variable to your code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@Environment(\.scenePhase) var scenePhase&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This Environment variable is the key to monitoring what state your app is in. Next we will add an &lt;strong&gt;.onChange&lt;/strong&gt; modifier to our view. This will allow us to see when our apps state has changed and then act on that change. Let’s now take a look at how I used the &lt;strong&gt;&lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/scenephase"&gt;scenePhase&lt;/a&gt;&lt;/strong&gt;&lt;/strong&gt; variable to reload a specific view when my app became active again.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;struct TodayWatchView: View {
    @StateObject var viewModel = TodayWatchViewModel()
    
    // 1) added scenePhase variable
    @Environment(\.scenePhase) var scenePhase
    
    var body: some View {
        ZStack {
            VStack {
                if !viewModel.isHolidaysEmpty {
                    List(viewModel.holidays) { holiday in
                        if holiday.url == "" {
                            Text("\(holiday.name)")
                                .font(.headline)
                                .bold()
                        } else {
                            NavigationLink(holiday.name, destination: HolidayWatchDetailView(holiday: holiday))
                        }
                    }
                } else {
                    EmptyState(message: "There was an issue loading Today's Holidays!\n Try again later")
                }
            }
            
            // 2)
            // Reload data when app becomes active!!
            .onChange(of: scenePhase) { newPhase in
                if newPhase == .inactive {
                    print("Inactive")
                } else if newPhase == .active {
                    viewModel.getHolidays()
                } else if newPhase == .background {
                    print("Background")
                }
            }
            .navigationTitle("Today Is....")
            .alert(item: $viewModel.alertItem) { alertItem in
                Alert.init(title: alertItem.title, message: alertItem.message, dismissButton: alertItem.dismissButton)
            }
            .onAppear {
                viewModel.getHolidays()
            }
            if viewModel.isLoading {
                ProgressView()
                    .progressViewStyle(CircularProgressViewStyle(tint: .gray))
                    .scaleEffect(2, anchor: .center)
            }
        }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I hope this gives you a better understanding of how you can monitor your app and run functions depending on your apps state. &lt;/p&gt;

&lt;p&gt;Thanks for reading and happy coding!!! 👨🏻‍💻👨🏻‍💻👨🏻‍💻&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>swiftui</category>
    </item>
    <item>
      <title>"Failed to initialize client context with error": A Error When Trying to Run a Widget in the Xcode Simulator (M1 Macs)</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Sat, 18 Sep 2021 00:05:58 +0000</pubDate>
      <link>https://forem.com/tprezioso/failed-to-initialize-client-context-with-error-a-error-when-trying-to-run-a-widget-in-the-xcode-simulator-m1-macs-1b6g</link>
      <guid>https://forem.com/tprezioso/failed-to-initialize-client-context-with-error-a-error-when-trying-to-run-a-widget-in-the-xcode-simulator-m1-macs-1b6g</guid>
      <description>&lt;p&gt;This is a short post about an issue I recently had with updating a widget for a SwiftUI project. I kept getting a weird error every time I tried to run a widget target in the simulator. The error read "&lt;strong&gt;Failed to initialize client context with error&lt;/strong&gt;". This was followed by a crazy long error message spit out by the debug console in Xcode. I googled everything and I finally found the solution! (&lt;strong&gt;Note: This only happened on my M1 Mac&lt;/strong&gt;) &lt;/p&gt;

&lt;p&gt;What you need to do to fix this error is toggle off the "&lt;strong&gt;Open using Rosetta&lt;/strong&gt;" button. To do that you need to right click on the Xcode app icon and go to &lt;strong&gt;"Get Info"&lt;/strong&gt;. In the Get Info window you are going to want to toggle off the "&lt;strong&gt;Open using Rosetta&lt;/strong&gt;" button. Now if you quit Xcode and reopen, you shouldn't see that error pop up again. Go re-run the widget in the simulator and VOILÀ! &lt;/p&gt;

&lt;p&gt;Until Apple fixes all the weird errors with supporting both &lt;strong&gt;Intel&lt;/strong&gt; and &lt;strong&gt;M1&lt;/strong&gt; chips for Xcode, you might need to toggle on and off "&lt;strong&gt;Open using Rosetta&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;I really hope this helps you from losing your mind googling for an answer to this solution!&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3SjzAMZN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/09/Screen-Shot-2021-09-17-at-7.35.52-PM-444x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3SjzAMZN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/09/Screen-Shot-2021-09-17-at-7.35.52-PM-444x1024.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>xcode</category>
    </item>
    <item>
      <title>How to Use AsyncImage in SwiftUI 3</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Thu, 24 Jun 2021 17:01:25 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-use-asyncimage-in-swiftui-3-3ih2</link>
      <guid>https://forem.com/tprezioso/how-to-use-asyncimage-in-swiftui-3-3ih2</guid>
      <description>&lt;p&gt;Recently Apple has announced &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/asyncimage?changes=__5"&gt;AsyncImage&lt;/a&gt;&lt;/strong&gt; at WWDC 2021. This makes loading images from a URL very easy in SwiftUI projects supporting iOS 15 and above. Let's take a look at an example below. &lt;/p&gt;

&lt;p&gt;If we want to load an image from a URL, all we need to do is add the following line of code.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;AsyncImage(url: https://i1.wp.com/swifttom.com/wp-content/uploads/2019/10/img_8186-2.jpg?resize=338%2C452&amp;amp;ssl=1)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's it! This is all the work we have to do to load an image from a URL! The only problem here is the URL image will most likely take up the whole screen because we didn't set the image modifiers. We also would want some sort of placeholder image while the URL image loads. No worries, &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/asyncimage?changes=__5"&gt;AsyncImage&lt;/a&gt;&lt;/strong&gt; has us covered. &lt;/p&gt;

&lt;p&gt;By adding initializers to our &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/asyncimage?changes=__5"&gt;AsyncImage&lt;/a&gt;&lt;/strong&gt;, we can have a placeholder while the image is loading and style our image once is has loaded.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;            AsyncImage(
                url:https://i1.wp.com/swifttom.com/wp-content/uploads/2019/10/img_8186-2.jpg?resize=338%2C452&amp;amp;ssl=1,
                content: { image in
                    image.resizable()
                         .scaledToFit()
                         .frame(maxWidth: 100, maxHeight: 100)
                },
                placeholder: {
                    ProgressView()
                }
            )&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the example above we have added a &lt;strong&gt;content&lt;/strong&gt; parameter to our &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/asyncimage?changes=__5"&gt;AsyncImage&lt;/a&gt;&lt;/strong&gt;. This allows us to set the image modifiers to give our image styling. We also added a &lt;strong&gt;placeholder&lt;/strong&gt; parameter which allows us to show a view as a placeholder until our image has loaded. In the example above we are using a &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/progressview/"&gt;ProgressView&lt;/a&gt;&lt;/strong&gt; as our placeholder until the image loads.&lt;/p&gt;

&lt;p&gt;I hope you find this useful in your next SwiftUI 3 projects! Happy coding!! 🌁📸🤳&lt;/p&gt;



</description>
      <category>swift</category>
      <category>swiftui</category>
      <category>ios</category>
    </item>
    <item>
      <title>"ARCHS[@]: unbound variable" error in SwiftUI Project</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Tue, 18 May 2021 17:19:12 +0000</pubDate>
      <link>https://forem.com/tprezioso/archs-unbound-variable-error-in-swiftui-project-42pd</link>
      <guid>https://forem.com/tprezioso/archs-unbound-variable-error-in-swiftui-project-42pd</guid>
      <description>&lt;p&gt;Recently I ran into an error when trying to run a SwiftUI Project on my iPhone. I'm running this project on a &lt;strong&gt;M1 Macbook Pro&lt;/strong&gt;. The error seemed to start happening when my project started using certain &lt;strong&gt;Cocoapods&lt;/strong&gt;. The error reads "&lt;strong&gt;ARCHS[@]: unbound variable&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;To fix this error all you need to do is navigate to the &lt;strong&gt;Project File&lt;/strong&gt; &lt;strong&gt;&amp;gt;&lt;/strong&gt; &lt;strong&gt;Info&lt;/strong&gt; &lt;strong&gt;&amp;gt;&lt;/strong&gt; &lt;strong&gt;Excluded Architecture&lt;/strong&gt;. If in &lt;strong&gt;Excluded Architecture&lt;/strong&gt; you see &lt;strong&gt;arm64&lt;/strong&gt;, all you need to do is remove the &lt;strong&gt;arm64&lt;/strong&gt; and reload your Xcode project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m_XSKEFS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-18-at-1.06.06-PM-1024x303.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m_XSKEFS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-18-at-1.06.06-PM-1024x303.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this quick post helps anyone struggling with this weird error in your SwiftUI project. If this doesn't help please check out this &lt;a href="https://stackoverflow.com/questions/64474801/archs-unbound-variable-in-xcode-12"&gt;stack overflow post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>swift</category>
      <category>swiftui</category>
      <category>ios</category>
      <category>xcode</category>
    </item>
    <item>
      <title>How to Make a Launch Screen in SwiftUI</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Sat, 08 May 2021 21:12:57 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-make-a-launch-screen-in-swiftui-lea</link>
      <guid>https://forem.com/tprezioso/how-to-make-a-launch-screen-in-swiftui-lea</guid>
      <description>&lt;p&gt;In this post we are going to look at how we can implement a launch screen in our SwiftUI project. In the past we would usually have to use a storyboard or XIB file to make our launch screens. In SwiftUI, we can now use the &lt;strong&gt;Info.plist&lt;/strong&gt; to make our launch screen. &lt;/p&gt;

&lt;p&gt;Let us get started by first navigating to our &lt;strong&gt;Info.plist&lt;/strong&gt; file and towards the bottom we should see a &lt;strong&gt;"Launch Screen"&lt;/strong&gt; area in our plist. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Eru8SME0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-06-at-7.02.08-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Eru8SME0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-06-at-7.02.08-PM.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we click the little plus button next to where it says &lt;strong&gt;"Dictionary"&lt;/strong&gt; we should see a list of options popup. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9VEgzdMz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-06-at-7.05.44-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9VEgzdMz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-06-at-7.05.44-PM.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Background color:&lt;/strong&gt; Here we can set the color of the launch screens background&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image name:&lt;/strong&gt; Here we can set an image to our launch screen at the images size / resolution&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image respects safe area insets:&lt;/strong&gt; This is a bool where we can allow the image to respect or exceed the safe area of the screen&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show navigation bar:&lt;/strong&gt; This is a bool where we can display a mock up of a Navigation bar&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show Tab bar:&lt;/strong&gt; This is a bool where we can display a mock up of a Tab bar &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show Toolbar:&lt;/strong&gt; This is a bool where we can display a mock up of a tool bar&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this example we are only going to add an image to our launch screen. To do this we will click on the &lt;strong&gt;"Image Name"&lt;/strong&gt; option. This will add an image name property to our plist with a blank string. We will leave this blank for now but we will soon fill it in with our image name.&lt;/p&gt;

&lt;p&gt;Next we will need to add an image to our &lt;strong&gt;Assets.xcassets&lt;/strong&gt; file. Once we have dragged and dropped an image into our &lt;strong&gt;Assets.xcassets&lt;/strong&gt; file, we will now copy the image name and paste it into the string area of&lt;strong&gt; "Launch Screen&lt;/strong&gt;" "&lt;strong&gt;Image Name"&lt;/strong&gt; back in our plist.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1Emd8TZ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-07-at-6.51.18-PM-1-1024x210.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1Emd8TZ8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-07-at-6.51.18-PM-1-1024x210.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7ks6uGH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-07-at-6.51.59-PM-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7ks6uGH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Screen-Shot-2021-05-07-at-6.51.59-PM-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the images above we added an image named &lt;strong&gt;"144"&lt;/strong&gt; to our projects assets file. We then set that image in our &lt;strong&gt;Info.plist&lt;/strong&gt; to be our launch screen image (&lt;em&gt;Don't ever name an image with a number&lt;/em&gt; 🤢). Now if we go and run our app we should see a quick glimpse of our launch screen image before the app loads.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3y_ivTac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Simulator-Screen-Shot-iPhone-12-Pro-2021-05-07-at-19.01.03-473x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3y_ivTac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/05/Simulator-Screen-Shot-iPhone-12-Pro-2021-05-07-at-19.01.03-473x1024.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is all you need to make a launch screen in SwiftUI! This is just another example of how SwiftUI makes developers lives that much easier. &lt;/p&gt;

&lt;p&gt;Hope this helps you on your next SwiftUI project! &lt;/p&gt;

&lt;p&gt;Thanks for reading and Happy coding 🚀📱 🚀📱 &lt;/p&gt;

</description>
      <category>swift</category>
      <category>swiftui</category>
      <category>ios</category>
    </item>
    <item>
      <title>How to Add External Libraries to a SwiftUI Project Using Swift Package Manager</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Wed, 24 Mar 2021 21:23:07 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-add-external-libraries-to-a-swiftui-project-using-swift-package-manager-dfm</link>
      <guid>https://forem.com/tprezioso/how-to-add-external-libraries-to-a-swiftui-project-using-swift-package-manager-dfm</guid>
      <description>&lt;p&gt;In this post we are going to look at how we can add a Swift package to our SwiftUI Project. Let's start by going to the &lt;a href="http://swiftpackageindex.com" rel="noopener noreferrer"&gt;Swift Package Index&lt;/a&gt; website and searching through the libraries. For this post we are going to use the &lt;a href="https://swiftpackageindex.com/AppPear/ChartView" rel="noopener noreferrer"&gt;SwiftUICharts&lt;/a&gt; package to add to our project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-19-at-6.42.32-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-19-at-6.42.32-PM.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SwiftUICharts&lt;/strong&gt; is an amazing library that makes it super easy to get beautifully animated charts into your SwiftUI project. &lt;/p&gt;

&lt;p&gt;Now that we have picked the library we want to add to our project, we now need to click on the copy button under the &lt;strong&gt;SwiftUICharts&lt;/strong&gt; title. This copies the link to &lt;strong&gt;SwiftUICharts&lt;/strong&gt; &lt;strong&gt;GitHub&lt;/strong&gt; so that we can download the package to our project. &lt;/p&gt;

&lt;p&gt;Now that we have our link to &lt;strong&gt;SwiftUICharts&lt;/strong&gt; repo, we will need to go to our Xcode project and click on &lt;strong&gt;File&lt;/strong&gt; &lt;strong&gt;&amp;gt;&lt;/strong&gt; &lt;strong&gt;Swift&lt;/strong&gt; &lt;strong&gt;Packages&lt;/strong&gt; &lt;strong&gt;&amp;gt; Add Package Dependency&lt;/strong&gt; and then paste in the repo's url: &lt;code&gt;&lt;strong&gt;https://github.com/AppPear/ChartView&lt;/strong&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-22-at-2.15.39-PM-1024x622.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-22-at-2.15.39-PM-1024x622.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you click on the next button, you will then have to choose what version, branch or commit from the package you would like to use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-22-at-2.17.25-PM-1024x612.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-22-at-2.17.25-PM-1024x612.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we will not mess with any of the options and just click on the next button. This will now download the package into your Xcode project. Once downloaded, we will make sure our package is selected and click on the finish button. &lt;/p&gt;

&lt;p&gt;Now we should see that our package has been successfully added to our project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-22-at-2.21.29-PM-1024x327.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F03%2FScreen-Shot-2021-03-22-at-2.21.29-PM-1024x327.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thats all there is too it! &lt;/p&gt;

&lt;p&gt;From here we can import the &lt;strong&gt;SwiftUICharts&lt;/strong&gt; library into a file and start using all the amazing charts and animations &lt;strong&gt;SwiftUICharts&lt;/strong&gt; has to offer. &lt;/p&gt;

&lt;p&gt;If you would like a deeper dive into &lt;strong&gt;Swift Package Manager&lt;/strong&gt; I would recommend checking out this &lt;a href="https://medium.com/xcblog/apple-swift-package-manager-a-deep-dive-ebe6909a5284" rel="noopener noreferrer"&gt;great article&lt;/a&gt; by @Shashikant86 &lt;/p&gt;

&lt;p&gt;Thanks for reading and happy coding!&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>swiftui</category>
    </item>
    <item>
      <title>How to Make a Custom HUD View in SwiftUI</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Wed, 10 Mar 2021 23:25:51 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-make-a-custom-hud-view-in-swiftui-171o</link>
      <guid>https://forem.com/tprezioso/how-to-make-a-custom-hud-view-in-swiftui-171o</guid>
      <description>&lt;p&gt;In this post we are going to make a custom &lt;strong&gt;HUD&lt;/strong&gt; view with a timer. The timer will dismiss our HUD view after about a second. Our &lt;strong&gt;HUD&lt;/strong&gt; view will be similar to the pop up view we see on our screen when we put our phone into silent mode. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dtd2NuFg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/03/silentMode.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dtd2NuFg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/03/silentMode.jpg" alt="" class="wp-image-1607" width="400" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's jump right in by creating a new SwiftUI file and naming it &lt;strong&gt;HUDView&lt;/strong&gt;. Next we are going to copy the code below into our &lt;strong&gt;HUDView.swift&lt;/strong&gt; file.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;import SwiftUI

struct HUDView&amp;lt;Content: View&amp;gt;: View {
    var content: Content
    @ViewBuilder var body: some View {
        content
            .padding(.horizontal, 10)
            .padding(10)
            .background(
                Capsule()
                    .foregroundColor(Color.white)
                    .shadow(color: Color(.black).opacity(0.10), radius: 10, x: 0, y: 5)
            )
    }
}

struct HUD_Previews: PreviewProvider {
    static var previews: some View {
        HUDView(content: Text("HI"))
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Above we created a &lt;strong&gt;HUD&lt;/strong&gt; view that takes in a view as a variable and then presents that view when the &lt;strong&gt;HUD&lt;/strong&gt; appears. We also stylized our &lt;strong&gt;HUD&lt;/strong&gt; to look like the pill shaped silent mode view in the image above. Now that we have created our &lt;strong&gt;HUD&lt;/strong&gt; lets go add it to our &lt;strong&gt;ContentView.swift&lt;/strong&gt; file. &lt;/p&gt;

&lt;p&gt;In our &lt;strong&gt;ContentView&lt;/strong&gt; file we will replace the boilerplate code with the code below.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;import SwiftUI

struct ContentView: View {
    var body: some View {
        HUDView(content: Text("Hello, World!"))
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hb-qn8a_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/03/Simulator-Screen-Shot-iPod-touch-7th-generation-2021-03-08-at-14.10.56-577x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hb-qn8a_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/03/Simulator-Screen-Shot-iPod-touch-7th-generation-2021-03-08-at-14.10.56-577x1024.png" alt="" class="wp-image-1599" width="313" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our preview screen we should see a pill shaped view with a text view saying "Hello World!". &lt;/p&gt;

&lt;p&gt;Next we will need to move our &lt;strong&gt;HUD&lt;/strong&gt; view from the middle of our view to the top of our view. Let's take a look at the example below to see how we can setup our &lt;strong&gt;HUD&lt;/strong&gt; view.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;import SwiftUI

struct ContentView: View {
    var body: some View {
        ZStack(alignment: .top) {
            NavigationView {
                Button("Save") {
                    
                }
                .navigationTitle("Home")
            }
            HUDView(content: Text("Save"))
        }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--66im2Jca--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/03/Simulator-Screen-Shot-iPod-touch-7th-generation-2021-03-08-at-14.35.20-577x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--66im2Jca--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/03/Simulator-Screen-Shot-iPod-touch-7th-generation-2021-03-08-at-14.35.20-577x1024.png" alt="" class="wp-image-1603" width="313" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the code above we added a &lt;strong&gt;ZStack&lt;/strong&gt; to keep our &lt;strong&gt;HUD&lt;/strong&gt; view aligned to the top and above the content on screen. Next we added a save button which will show our &lt;strong&gt;HUD&lt;/strong&gt; view when we tap on the button. Lastly we added a &lt;strong&gt;NavigationView&lt;/strong&gt; so we can have a navigation title on our screen for some style points. &lt;/p&gt;

&lt;p&gt;Now when our save button is tapped we will want to present our &lt;strong&gt;HUDView&lt;/strong&gt;. Then after 1.5 seconds we will have our &lt;strong&gt;HUD&lt;/strong&gt; dismiss itself. To do this let us add the code below to our &lt;strong&gt;ContentView&lt;/strong&gt; file.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;import SwiftUI

struct ContentView: View {
    @State private var showHUD = false
    var body: some View {
        ZStack(alignment: .top) {
            NavigationView {
                Button("Save") {
                    withAnimation {
                        self.showHUD.toggle()
                        dismissHUD()
                    }
                }
                .navigationTitle("Home")
            }
            
            HUDView(content: Text("Save"))
                .offset(y: showHUD ? 0 : -100)
                .animation(.spring())
        }
    }

    func dismissHUD() {
        DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
            self.showHUD = false
        }
    }

}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Above we added a &lt;strong&gt;@State&lt;/strong&gt; property to track when we will show and hide the &lt;strong&gt;HUD&lt;/strong&gt; view. Then we added the &lt;strong&gt;dismissHUD() &lt;/strong&gt;function so that we can dismiss the &lt;strong&gt;HUD&lt;/strong&gt; view after 1.5 seconds(feel free to change the time to dismiss to whatever you like best). Lastly we added an &lt;strong&gt;.offset&lt;/strong&gt; and &lt;strong&gt;.animation(.spring())&lt;/strong&gt; modifier to our &lt;strong&gt;HUD&lt;/strong&gt; view. We added the &lt;strong&gt;.offset&lt;/strong&gt; modifier so we can hide the &lt;strong&gt;HUD&lt;/strong&gt; view offscreen when not being shown. We also added a spring animation to give our &lt;strong&gt;HUD&lt;/strong&gt; some bounce when entering the view from off screen. Now when we run our app and press our save button, we should see our &lt;strong&gt;HUD&lt;/strong&gt; appear and then disappear after 1.5 seconds.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://videopress.com/v/GThOyjdD?controls=false&amp;amp;loop=true&amp;amp;preloadContent=metadata"&gt;https://videopress.com/v/GThOyjdD?controls=false&amp;amp;amp;loop=true&amp;amp;amp;preloadContent=metadata&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! Hope this helps you in your next SwiftUI project.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oWd0R7Sd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.gifer.com/LhZn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oWd0R7Sd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.gifer.com/LhZn.gif" alt="Iron man GIF - Find on GIFER"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>swift</category>
      <category>swiftui</category>
      <category>ios</category>
    </item>
    <item>
      <title>Picker View Styles in SwiftUI</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Mon, 22 Feb 2021 18:53:20 +0000</pubDate>
      <link>https://forem.com/tprezioso/picker-view-styles-in-swiftui-16oh</link>
      <guid>https://forem.com/tprezioso/picker-view-styles-in-swiftui-16oh</guid>
      <description>&lt;p&gt;In this post we are going to take a look at the different ways we can style a picker view in our SwiftUI project. Let's first setup a simple picker view like in the example below.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;    var arrayOfNames = ["Tom", "Nick", "Tony", "Dylan"]
    @State private var selectedIndex = 0
    
    var body: some View {
        Picker("Names", selection: $selectedIndex) {
            ForEach(0 ..&amp;lt; arrayOfNames.count) {
                Text(self.arrayOfNames[$0])
            }
        }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pn7mfdyY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPod-touch-7th-generation-2021-02-19-at-17.19.09-577x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pn7mfdyY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPod-touch-7th-generation-2021-02-19-at-17.19.09-577x1024.png" alt="" class="wp-image-1549" width="337" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Above we created a basic picker view with four names to choose from. Now let us change the style of our picker to be included in a &lt;strong&gt;Form&lt;/strong&gt;.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;    var arrayOfNames = ["Tom", "Nick", "Tony", "Dylan"]
    @State private var selectedIndex = 0
    
    var body: some View {
        NavigationView {
            Form {
                Picker("Names", selection: $selectedIndex) {
                    ForEach(0 ..&amp;lt; arrayOfNames.count) {
                        Text(self.arrayOfNames[$0])
                    }
                }
            }
        }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;ul class="blocks-gallery-grid"&gt;
&lt;li class="blocks-gallery-item"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A96zmxWO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPhone-12-2021-02-21-at-11.05.49-1-473x1024.png" alt="" class="wp-image-1555"&gt;&lt;/li&gt;
&lt;li class="blocks-gallery-item"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IeAIW4-c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPhone-12-2021-02-21-at-11.05.54-1-473x1024.png" alt="" class="wp-image-1556"&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the example above is wrapped our code in a &lt;strong&gt;NavigationView&lt;/strong&gt; and a &lt;strong&gt;Form&lt;/strong&gt;. This changes our picker view style so that it segues us to another view to make our selection. This is great for a picker that has many options to choose from. But let's say we didn't want to segue to another view to see our options. &lt;/p&gt;

&lt;p&gt;Let's see how we can implement a segmented picker view style.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;    var arrayOfNames = ["Tom", "Nick", "Tony", "Dylan"]
    @State private var selectedIndex = 0
    
    var body: some View {
        NavigationView {
            Form {
                Picker("Names", selection: $selectedIndex) {
                    ForEach(0 ..&amp;lt; arrayOfNames.count) {
                        Text(self.arrayOfNames[$0])
                    }
                }.pickerStyle(SegmentedPickerStyle())
            }
        }
    }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DN1hdj-C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPhone-12-2021-02-21-at-11.14.46-473x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DN1hdj-C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPhone-12-2021-02-21-at-11.14.46-473x1024.png" alt="" class="wp-image-1558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By just adding &lt;strong&gt;.pickerStyle(SegmentedPickerStyle())&lt;/strong&gt; to our picker view, SwiftUI gives us a segmented style picker view with minimal change to our code. &lt;/p&gt;

&lt;p&gt;Let's say we don't want either of these styles. What if we wanted a picker view like we originally had in our first example. We can easily do this by switching our picker style to &lt;strong&gt;.pickerStyle(&lt;strong&gt;WheelPickerStyle&lt;/strong&gt;())&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BGXMgta0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPhone-12-2021-02-21-at-11.20.45-473x1024.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BGXMgta0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Simulator-Screen-Shot-iPhone-12-2021-02-21-at-11.20.45-473x1024.png" alt="" class="wp-image-1560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this helps you in your next SwiftUI Project.&lt;/p&gt;

&lt;p&gt;Thanks for reading and happy coding! ⛏⛏⛏&lt;/p&gt;

</description>
      <category>swift</category>
      <category>swiftui</category>
      <category>ios</category>
    </item>
    <item>
      <title>No Such Module Found (M1 Macbook Pro Solution)</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Tue, 16 Feb 2021 22:05:48 +0000</pubDate>
      <link>https://forem.com/tprezioso/no-such-module-found-m1-macbook-pro-solution-14a7</link>
      <guid>https://forem.com/tprezioso/no-such-module-found-m1-macbook-pro-solution-14a7</guid>
      <description>&lt;p&gt;Recently I have been working on a new project with my new M1 Macbook Pro. In this project I needed to use third party libraries such as &lt;strong&gt;FBSDKCoreKit&lt;/strong&gt; (Facebook) so the user could sign in with their Facebook account. The problem I ran into was that no matter what I did the &lt;a href="https://cocoapods.org/"&gt;Cocoapods&lt;/a&gt; I loaded into my project would not run. Xcode would give me error messages such as "&lt;strong&gt;No such module found&lt;/strong&gt;" or "&lt;strong&gt;module 'FBSDKCoreKit' not found&lt;/strong&gt;". &lt;/p&gt;

&lt;p&gt;After hours of googling and looking at Github issues on the topic, I found the solution. If you are running into this problem on a M1 Mac you need to open Xcode using &lt;strong&gt;Rosetta&lt;/strong&gt;. What is &lt;strong&gt;Rosetta&lt;/strong&gt;? Without getting too technical &lt;strong&gt;Rosetta&lt;/strong&gt; allows the new M1 Mac's to run x86 architecture apps. For a deeper dive into Rosetta check out the link &lt;a href="https://www.computerworld.com/article/3597949/everything-you-need-to-know-about-rosetta-2-on-apple-silicon-macs.html"&gt;here&lt;/a&gt;. If you need to install Rosetta 2 on your M1 Mac click on this link &lt;a href="https://osxdaily.com/2020/12/04/how-install-rosetta-2-apple-silicon-mac/"&gt;here&lt;/a&gt; and follow the tutorial.&lt;/p&gt;

&lt;p&gt;Now to fix this issue we need to go into our &lt;strong&gt;Finder&lt;/strong&gt; &amp;gt; &lt;strong&gt;Applications&lt;/strong&gt; &lt;strong&gt;&amp;gt;&lt;/strong&gt; and right click (command ⌘ + click) on Xcode. Then we need to select "&lt;strong&gt;Get Info&lt;/strong&gt;"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IB8k_Tph--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-16-at-9.21.05-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IB8k_Tph--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-16-at-9.21.05-AM.png" alt="" class="wp-image-1533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have the &lt;strong&gt;"Get Info&lt;/strong&gt;" window opened, we then need to click on "&lt;strong&gt;Open using Rosetta&lt;/strong&gt;"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4RbmfY4q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-16-at-9.23.02-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4RbmfY4q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/Screen-Shot-2021-02-16-at-9.23.02-AM.png" alt="" class="wp-image-1535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if we relaunch our Xcode and build our project we shouldn't see anymore errors like "&lt;strong&gt;Module not Found&lt;/strong&gt;". I hope this helps save you some time and headaches.&lt;/p&gt;

&lt;p&gt;Thanks for reading. Happy Coding!&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>xcode</category>
      <category>mac</category>
    </item>
    <item>
      <title>How to Add an AppDelegate to a SwiftUI Project</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Mon, 15 Feb 2021 23:39:35 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-add-an-appdelegate-to-a-swiftui-project-4lek</link>
      <guid>https://forem.com/tprezioso/how-to-add-an-appdelegate-to-a-swiftui-project-4lek</guid>
      <description>&lt;p&gt;When you create a new SwiftUI project, you will see that we no longer have the &lt;strong&gt;AppDelegate.swift&lt;/strong&gt; file. This doesn't mean we don't need or use the &lt;strong&gt;AppDelegate&lt;/strong&gt; file anymore. If we want to implement something like push notifications we will need to use an &lt;strong&gt;AppDelegate&lt;/strong&gt; in our SwiftUI app. Let's take a look at how we can add an &lt;strong&gt;AppDelegate&lt;/strong&gt; file to our SwiftUI project.&lt;/p&gt;

&lt;p&gt;First we will need to create a new swift file and name it &lt;strong&gt;AppDelegate&lt;/strong&gt;. Now inside of our new &lt;strong&gt;AppDelegate&lt;/strong&gt; file we will need to copy and paste the code below (Feel free to add any &lt;strong&gt;AppDelegate&lt;/strong&gt; functions you need for your project). &lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;import UIKit

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -&amp;gt; Bool {

        // Your Code Here!
        return true
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now that we have our &lt;strong&gt;AppDelegate&lt;/strong&gt; created, we will need to tell our app to use the &lt;strong&gt;AppDelegate.swift&lt;/strong&gt; file. Let us navigate over to the App file in our project. This file is named after your project with &lt;strong&gt;"App&lt;/strong&gt;" at the end. In this example my file is named &lt;strong&gt;AppDelegateBlogProjectApp.swift&lt;/strong&gt; (Not the best name in the world 🤣). &lt;/p&gt;

&lt;p&gt;In this file we will create and wrap our AppDelegate property in the &lt;strong&gt;UIApplicationDelegateAdaptor&lt;/strong&gt; property wrapper. This tells SwiftUI we want to use the &lt;strong&gt;AppDelegate&lt;/strong&gt; file we just created.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;@main
struct AppDelegateBlogProject: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That is all we need to make an &lt;strong&gt;AppDelegate&lt;/strong&gt; in a SwiftUI project! &lt;/p&gt;

&lt;p&gt;Thanks for reading! &lt;/p&gt;



</description>
      <category>swift</category>
      <category>ios</category>
      <category>swiftui</category>
    </item>
    <item>
      <title>@Appstorage in SwiftUI</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Mon, 08 Feb 2021 19:43:24 +0000</pubDate>
      <link>https://forem.com/tprezioso/appstorage-in-swiftui-3jai</link>
      <guid>https://forem.com/tprezioso/appstorage-in-swiftui-3jai</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/swiftui/appstorage"&gt;Appstorage&lt;/a&gt;&lt;/strong&gt; is a property wrapper for getting stored values from &lt;strong&gt;&lt;a href="https://developer.apple.com/documentation/foundation/userdefaults"&gt;UserDefaults&lt;/a&gt;&lt;/strong&gt; in SwiftUI. We use &lt;strong&gt;@Appstorage&lt;/strong&gt; too reload our body view property whenever the value changes of our &lt;strong&gt;UserDefaults&lt;/strong&gt;. This keeps our view up to date with the data that we have stored. Let's take a look at an example on how we can use &lt;strong&gt;@Appstorage&lt;/strong&gt; in our SwiftUI project.&lt;/p&gt;

&lt;pre class="wp-block-code"&gt;&lt;code&gt;import SwiftUI

struct ContentView: View {
    @AppStorage("isCookieTime") var isCookieTime = false
    
    var body: some View {
            Toggle("Cookie time", isOn: $isCookieTime)
        .padding()
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the example above we have a Toggle view for "Cookie time" 🍪. We use our &lt;strong&gt;@AppStorage&lt;/strong&gt; property to watch our &lt;strong&gt;isCookieTime&lt;/strong&gt; variable. If the value changes it is then stored in our &lt;strong&gt;UserDefaults&lt;/strong&gt;. Now our toggle will show the stored value depending on the &lt;strong&gt;@AppStorage&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt; A example of where I use &lt;strong&gt;@AppStorage&lt;/strong&gt; is for storing things like a users settings options in a settings screen of an app. I hope this helps explain how to use &lt;strong&gt;@AppStorage&lt;/strong&gt; in SwiftUI. &lt;/p&gt;

&lt;p&gt;Thanks for reading and happy coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_yYxgnfo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/storageFull.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_yYxgnfo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://swifttom.com/wp-content/uploads/2021/02/storageFull.jpg" alt="" class="wp-image-1502"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>swiftui</category>
    </item>
    <item>
      <title>How to Make a Code Snippet in Xcode</title>
      <dc:creator>Thomas Prezioso Jr.</dc:creator>
      <pubDate>Fri, 29 Jan 2021 23:44:33 +0000</pubDate>
      <link>https://forem.com/tprezioso/how-to-make-a-code-snippet-in-xcode-5bo5</link>
      <guid>https://forem.com/tprezioso/how-to-make-a-code-snippet-in-xcode-5bo5</guid>
      <description>&lt;p&gt;Code snippets are shortcuts to blocks of boilerplate code that we use most often when programming. Xcode allows us to add custom snippets to the many pre-existing snippets that Apple provides. Let's see how we can make a code snippet out of the following code below.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DispatchQueue.main.async {
                    
                }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You might be familiar with the example code above. This block of code is used to make sure things like network calls are made on the main thread and not on a background thread. Let's make a code snippet of this so we don't have to type the whole thing out every time we want to use it.&lt;/p&gt;

&lt;p&gt;If we highlight the code and then right click (⌘ + click) you will see an option to "Create Code Snippet".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-5.53.45-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-5.53.45-PM.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we click on "Create Code Snippet" a window will popup and prompt us to customize our code snippet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-5.55.10-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-5.55.10-PM.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First we will name our snippet "Dispatch Main Queue" (Feel free to name it whatever you want 😄). Now we will leave everything else the same except the "Completion" section. In the "Completion" textfield we will type in "dpm". &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-5.59.41-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-5.59.41-PM.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What this does is every time we type "dpm" Xcode will prompt us in the autocompletion to see if we want to use our code snippet! So from now on anytime we want to put something on the main thread all we have to do is type "dpm" and we get our code snippet we just created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-6.05.13-PM-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-6.05.13-PM-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-6.05.30-PM-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fswifttom.com%2Fwp-content%2Fuploads%2F2021%2F01%2FScreen-Shot-2021-01-29-at-6.05.30-PM-1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just like that we have made a code snippet and saved ourselves time by never having to type out all that code ever again!  Feel free to make code snippets of any block of code your tired of typing out! Embrace your laziness! &lt;/p&gt;

&lt;p&gt;Thanks for reading and I hope this helps your coding productivity.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F64.media.tumblr.com%2F26460fbabb524c6906212d60cb0bfe2e%2Ftumblr_inline_pae21mGEP91s6q7r3_500.gifv" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F64.media.tumblr.com%2F26460fbabb524c6906212d60cb0bfe2e%2Ftumblr_inline_pae21mGEP91s6q7r3_500.gifv" alt="Texas Tribune Nerds - What I Learned at The Texas Tribune"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>xcode</category>
    </item>
  </channel>
</rss>
