<?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>DEV Community: Suryansh Mansharamani</title>
    <description>The latest articles on DEV Community by Suryansh Mansharamani (@1337).</description>
    <link>https://dev.to/1337</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%2F369755%2Fec5d7d08-09d5-461a-8d0d-479457013311.jpeg</url>
      <title>DEV Community: Suryansh Mansharamani</title>
      <link>https://dev.to/1337</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/1337"/>
    <language>en</language>
    <item>
      <title>How to add and test In-App Purchases to your iOS app!</title>
      <dc:creator>Suryansh Mansharamani</dc:creator>
      <pubDate>Mon, 25 May 2020 19:31:22 +0000</pubDate>
      <link>https://dev.to/1337/how-to-add-and-test-in-app-purchases-to-your-ios-app-4k0c</link>
      <guid>https://dev.to/1337/how-to-add-and-test-in-app-purchases-to-your-ios-app-4k0c</guid>
      <description>&lt;p&gt;In-App Purchases can end up making you tons of money with your next app…&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L6zadeqv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oz5zhhxzlg6t17jn3878.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L6zadeqv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oz5zhhxzlg6t17jn3878.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Why In-App purchases?&lt;/p&gt;

&lt;p&gt;If you haven’t noticed, the biggest apps in the market like Spotify and Evernote are free, which attract far more users than any paid app. What makes these apps different is that they have In-App purchases which usually far surpass any income a solo developer can accumulate with a paid app. If your incentive is to not only help others and create something that the people want, but also making a good amount of money off of it, In-App purchases are perfect for you. Here is a short, easy tutorial on how to implement In-App purchases into your next app in just 13 steps…&lt;/p&gt;

&lt;p&gt;1) Go to App Store Connect&lt;/p&gt;

&lt;p&gt;First, go to App Store Connect (&lt;a href="https://appstoreconnect.apple.com/"&gt;https://appstoreconnect.apple.com/&lt;/a&gt;)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--22wXPfhS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q0r4g795fi2w0m4y495b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--22wXPfhS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q0r4g795fi2w0m4y495b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Check the Paid Apps Status&lt;/p&gt;

&lt;p&gt;Press the Agreements, Tax and Banking button to check if you’re able to create an app with any paid components in it. If it says Active, then your fine. If the dot under status for the Paid Apps type is red, then you have to add certain information before creating this app.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hSIuY0Wn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l9txo03oong8epcbq2o4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hSIuY0Wn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l9txo03oong8epcbq2o4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) Registering the App ID&lt;/p&gt;

&lt;p&gt;Now we need to register the App ID (&lt;a href="https://developer.apple.com/account/resources/identifiers/bundleId/add/"&gt;https://developer.apple.com/account/resources/identifiers/bundleId/add/&lt;/a&gt;) .&lt;/p&gt;

&lt;p&gt;First, for the description, write something quite generic or just the app name. The Bundle ID will be set to explicit. The Bundle ID has to be unique, so the convention usually is the following:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If you have a website, then write com.[websitename].[appname]
If you don't have a website, then write com.[fullname].[appname]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Although the capabilities section is preset, its good practice to scroll down in the Capabilities section to check that In-App Purchases is enabled.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JUfYiA9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/amo59yv3rspnh5uwujg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JUfYiA9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/amo59yv3rspnh5uwujg7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4) Setting the Project Info&lt;/p&gt;

&lt;p&gt;Next, open up Xcode and create a project with the same App ID description. This is a requirement because, as you can see, the Bundle Identifier is heavily dependent on both the Product Name and the Organization identifier, which follows nearly the same form:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For those with a website, it will be com.[websitename]
For those without a website, it will be com.[fullname]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;For this project, we will be using Swift and the Storyboard User Interface.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KF1C_NYt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tkg0a9fdi5f8x0yr1sk7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KF1C_NYt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tkg0a9fdi5f8x0yr1sk7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5) Adding the In-App Purchase Capability to Xcode&lt;/p&gt;

&lt;p&gt;After successfully creating the project, go to the project file and then to the Signing and Capabilities section. For the latest version of Xcode, you will have to go to the top left corner of this section which says “+ Capability” to add a capability. After the window opens, search for the In-App Purchase capability and add it to your project.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qrrQIJVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/58qxyrrgn5n388onayki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qrrQIJVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/58qxyrrgn5n388onayki.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6) Creating the New App&lt;/p&gt;

&lt;p&gt;Now, let’s go back to App Store Connect. On the upper left corner, there will be a “+” sign, where you will have to press the New App button in order to create a new app.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---yLnvMPx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y3nrsgze20xp2fa9cmib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---yLnvMPx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y3nrsgze20xp2fa9cmib.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7) Setting the New App Info&lt;/p&gt;

&lt;p&gt;Upon pressing the button, the following window will pop up. Here we will select the platform, which for us, will be iOS. First, start out by entering the name of the app. Remember, the name has to be unique, and while the description was quite clear, it isn’t counted and compared to the other existing apps.&lt;/p&gt;

&lt;p&gt;In our case, I named the app InAppPurchase 1023. The primary language is quite self-explanatory and the Bundle ID will be the same bundleID we created before for this app. The SKU is basically a unique string that won’t be displayed anywhere. I encourage following this format for the SKU:&lt;/p&gt;

&lt;p&gt;[2 or 3 letters][00]&lt;/p&gt;

&lt;p&gt;The 00 will then change to 01 an on as you create more apps. The user will have access to the full app, so be sure to select Full Access.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ILILeUC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jkzd6qqnsthlbe67a5nu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ILILeUC4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jkzd6qqnsthlbe67a5nu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8) In-App Purchase Types&lt;/p&gt;

&lt;p&gt;Now, let’s go to Features and then In-App Purchases. When adding an In-App Purchase, make sure to only check Non-Consumable.&lt;/p&gt;

&lt;p&gt;While Apple explains these 4 types of In-App purchases, here is a short, easy to understand the description of them:&lt;/p&gt;

&lt;p&gt;Consumable: You can only use this once, and once you have to use it again, then you have buy it again. This applies to games that use coins, etc.&lt;/p&gt;

&lt;p&gt;Non-Consumable: As soon as you buy a non-consumable In-App Purchase, it will stay with you forever. This usually applies to unlocking special levels in games, premium versions of apps, etc.&lt;/p&gt;

&lt;p&gt;Auto-Renewable Subscriptions: These are great for apps like Spotify, etc. As soon as the subscription is bought, it will keep on renewing after the desired amount of time automatically unless the user chooses to cancel the subscription.&lt;/p&gt;

&lt;p&gt;Non-Renewing Subscription: As soon as the user buys the subscription to the app, it will not automatically renew, but the user has to renew it manually.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MeayU9fJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gq10xfkbbvyvwvmcsb77.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MeayU9fJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gq10xfkbbvyvwvmcsb77.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;9) Setting the price&lt;/p&gt;

&lt;p&gt;After pressing Create, the box below might take some time to fully process. Upon finishing, you will see a drop-down which will show the different Tiers of prices. We will go with Tier 1, so if the sandbox section of this tutorial does not work out for you, it's only going to cost you 99 cents. To save some times, copy the Product ID as will be using that later.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5Scg-HOc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bn4c1jawcjrgx9k87r8k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5Scg-HOc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bn4c1jawcjrgx9k87r8k.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10) Setting up the UI&lt;/p&gt;

&lt;p&gt;Now, let's go back to Xcode and into the Main.storyboard file. By using Cmd+Shift+L, we can search and add a UIButton to our interface.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F5ppRlRv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h2fb3hryjtpykqtmr7pm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F5ppRlRv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h2fb3hryjtpykqtmr7pm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets set the button horizontally and vertically in the container.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--18yADo5F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kg71bujogehy1pguhif2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--18yADo5F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kg71bujogehy1pguhif2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set the width 150 and the height to 50.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x0azuGUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pujbx1srwsx0y3blkj3r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x0azuGUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pujbx1srwsx0y3blkj3r.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, once again, use Cmd+Shift+L to create a Label and set its alignment constraints to be horizontally in the container.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3dVkPynu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ia5nohic60ihedc3enwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3dVkPynu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ia5nohic60ihedc3enwj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's go to the ViewController.swift file, where will paste the ID we had copied before into a new constant called PurchaseID as a string.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WHCDYKUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uu5h236peuh857mer1k4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WHCDYKUG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uu5h236peuh857mer1k4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make it a little bit more neat, lets set a couple more additional constraints in terms of the y position.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UQMLMMvO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r6p6xj7yi7ka8ioze7va.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UQMLMMvO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r6p6xj7yi7ka8ioze7va.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, by holding Control and moving the label to the View Controller. Set the type to UILabel and the name to buyLabel.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OwDD_NHB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o7xo1ppevjaokj9t5jpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OwDD_NHB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o7xo1ppevjaokj9t5jpb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's use the same concept for the button and name it as buyPressed.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZeUx7OQb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sm0cks02qi69yemh3e64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZeUx7OQb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sm0cks02qi69yemh3e64.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, import the StoreKit in order to access certain commands for the In-App Purchases ability. After the colon and then the UIVewController, use the SKPaymentTransactionObeserver.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AsNpvRhS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/exk2mbrnubwzy27t7pw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AsNpvRhS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/exk2mbrnubwzy27t7pw2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;11) Let’s start the actual programming!&lt;/p&gt;

&lt;p&gt;Create a function called as payment queue to handle the transaction states. Now in the function viewDidLoad() we will add the SKPaymentQueue, which as described by Apple, is a “A queue of payment transactions to be processed by the App Store.”. If you aren’t that proficient with Swift, I really recommend to look at this link for further information: &lt;a href="https://developer.apple.com/documentation/storekit/skpaymentqueue"&gt;https://developer.apple.com/documentation/storekit/skpaymentqueue&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3-j4uOdx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/82727eyfqr4csqubs5ki.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3-j4uOdx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/82727eyfqr4csqubs5ki.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the paymentQueue function, we will add the true content of this tutorial into it. Use the if-else statement to see if the transaction state is purchased, and if it is, let the console print back “Transaction is successful” just to be sure and change the label of the buyLabel to the same. Now use else if to see if the transaction failed or not and change the label to “The transaction has failed.”&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vU6iNQ3t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sakgvurfgbjx4t95dci7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vU6iNQ3t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sakgvurfgbjx4t95dci7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;According to Apple, the SKMutablePayment class is “A mutable request to the App Store to process payment for additional functionality offered by your app.” We will name the constant accordingly, as transactionRequest. Within this, we will “tell Apple to recognize” the purchaseID as the productIdentifier and “add” the same transactionRequest to the SKPaymentQueue.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Jxp8B9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kmo7ksj7d62usjyzwjl7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Jxp8B9y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kmo7ksj7d62usjyzwjl7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;12) Setting up testing&lt;/p&gt;

&lt;p&gt;Now, its time to test our app! Instead of paying to make sure it works, we have to create a “sandbox account”. To do this, let's create a fake account on google. This will be your “sandbox account” from now on. You can’t use any of your own accounts since they will be associated with an Apple ID (or have been).&lt;/p&gt;

&lt;p&gt;After entering the data below, Google will ask for your birth date, the country you live in, and phone number. You need to type in the right phone number for this to work as you will need to verify the account. Also, do NOT add a backup email, since it will be associated with your Apple ID (in most cases).&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QN0SJQ_T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cafvzwrvmf5gqak4baal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QN0SJQ_T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cafvzwrvmf5gqak4baal.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's go back into App Store Connect and into Users and Access. To the bottom left, there will be a section in bold called “Sandbox” as shown by the image below. Press on Testers under Sandbox. Here, you will notice a blue plus icon which will allow you to create a new tester. Here, enter the required information.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SsEZTU9X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y1wepr8jv4bjg8y5zugp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SsEZTU9X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y1wepr8jv4bjg8y5zugp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qQAAP6eW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7k6l824dmd5v9n78g4gx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qQAAP6eW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7k6l824dmd5v9n78g4gx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;13) Testing&lt;/p&gt;

&lt;p&gt;Done!&lt;/p&gt;

&lt;p&gt;Let's go an run your app on your device, NOT the simulator, as this won’t work if you use a simulator. First, to avoid any chances of paying (although 99 cents won’t hurt) go to Settings. In Settings, scroll down to iTunes &amp;amp; App Stores. Under here, you should see a “Sandbox Account” section where there should be your tester account. If it’s there, then congratulations, you did it! If it isn’t, go back to the beginning and try again.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RnDAAKNs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lcgcx01un7h1kwqmmc57.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RnDAAKNs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lcgcx01un7h1kwqmmc57.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading my tutorial! It means a lot, and I’m sure that others would want to see this too, so don’t forget to 👏 and follow me on Medium at: &lt;a href="https://medium.com/@suryanshmansha"&gt;https://medium.com/@suryanshmansha&lt;/a&gt;&lt;/p&gt;

</description>
      <category>swift</category>
      <category>ios</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Making a Music Player with SwiftUI in 3 minutes.</title>
      <dc:creator>Suryansh Mansharamani</dc:creator>
      <pubDate>Sun, 17 May 2020 18:43:30 +0000</pubDate>
      <link>https://dev.to/1337/making-a-music-player-with-swiftui-in-3-minutes-4pi3</link>
      <guid>https://dev.to/1337/making-a-music-player-with-swiftui-in-3-minutes-4pi3</guid>
      <description>&lt;p&gt;Integrating music into your next app has never been easier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f-9OQNVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r4up7qs7m4cr8yb3c0r1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f-9OQNVs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r4up7qs7m4cr8yb3c0r1.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Extensions File&lt;/p&gt;

&lt;p&gt;First, create a new .swift file named Extensions. As you could guess by the name, we will create an extension called “Color” where we will create static constants called backgroundColor and buttonColor along with a static function named rgb, where, as you could, guess contains an rgb value. The following snippet shows my own rgb colors, but feel free to edit it and use your own!&lt;/p&gt;

&lt;p&gt;import SwiftUI&lt;/p&gt;

&lt;p&gt;extension Color {&lt;br&gt;
static func rgb(r: Double, g: Double, b: Double) -&amp;gt; Color {                       return Color(red: r / 255, green: g / 255, blue: b / 255)                       }static let backgroundColor = Color.rgb(r: 21, g: 22, b: 33)                       static let buttonColor = Color.rgb(r: 190, g: 230, b: 100)                       }&lt;/p&gt;

&lt;p&gt;Modules&lt;/p&gt;

&lt;p&gt;Next, lets set up our modules. Since SwiftUI projects have Import SwiftUI as the default module, leave it as it is and add AVKit, which is used as, according to Apple, a framework which “provides a high-level interface for playing video content.”&lt;/p&gt;

&lt;p&gt;import SwiftUI&lt;br&gt;
import AVKit&lt;/p&gt;

&lt;p&gt;Setting Up&lt;/p&gt;

&lt;p&gt;Now, lets get to programming! First lets use the @State property wrapper to declare a variable called “audioPlayer” which will be equal to an implicitly unwrapped optional called AVAudioPlayer, which will be used to play the given audio.&lt;/p&gt;

&lt;p&gt;struct ContentView: View {                        @State var audioPlayer: AVAudioPlayer!&lt;/p&gt;

&lt;p&gt;Inside the “var body: some View {“ we have to start our main programming. First, we will create a ZStack which will be used for the overlapping content, and then set the background to cover the entire screen, ignoring all safe areas through the following code:&lt;/p&gt;

&lt;p&gt;var body: some View {   &lt;/p&gt;

&lt;p&gt;ZStack {                        Color.backgroundColor .edgesIgnoringSafeArea(.all)&lt;/p&gt;

&lt;p&gt;In order to create the elements in a vertical order we will use the vertical stack and then use the horizontal stack to set the background image and the main title, along with setting the background’s image to fit the entire screen via the aspect ratio command. The additional code is used for additional decorative uses.&lt;/p&gt;

&lt;p&gt;VStack {&lt;br&gt;&lt;br&gt;
HStack {                      Text("Rain").font(.system(size: 45)).fontWeight(.bold).navigationBarHidden(true)                        .foregroundColor(.buttonColor).background(Image("Image").resizable()                        .frame(width: 900, height: 900)                        .aspectRatio(contentMode: .fit)&lt;br&gt;&lt;br&gt;
                    )&lt;br&gt;&lt;br&gt;
   }&lt;/p&gt;

&lt;p&gt;The Functionality!&lt;/p&gt;

&lt;p&gt;Create another horizontal stack for both the play and stop button, along with an additional spacer to make the layout more appealing. Now its time for the actually functionality! What’s really nice about this project is that the only thing you need is an image for the background if you want, and nothing else for the buttons since those are already provided. To make the audio play, simply use the self.audioPlayer.play() command and set its image as a preset system name, along with a few more properties as shown by the snippet below:&lt;/p&gt;

&lt;p&gt;HStack {&lt;br&gt;&lt;br&gt;
Spacer()      &lt;/p&gt;

&lt;p&gt;Button(action: {   &lt;/p&gt;

&lt;p&gt;self.audioPlayer.play()&lt;br&gt;&lt;br&gt;
 }) {    &lt;/p&gt;

&lt;p&gt;Image(systemName: "play.circle.fill").resizable()                        .frame(width: 50, height: 50)                                                .aspectRatio(contentMode: .fit)                        .foregroundColor(.buttonColor)&lt;br&gt;&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;After adding an additional spacer, create another button with the same command for the action, except with .pause in the place of .play, along with the same exact properties as the play button.&lt;/p&gt;

&lt;p&gt;Spacer()&lt;br&gt;&lt;br&gt;
Button(action: {&lt;br&gt;&lt;br&gt;
 self.audioPlayer.pause()&lt;br&gt;&lt;br&gt;
}) {                     Image(systemName: "pause.circle.fill").resizable()                        .frame(width: 50, height: 50)&lt;br&gt;&lt;br&gt;
                                              .aspectRatio(contentMode: .fit)                        .foregroundColor(.buttonColor)     &lt;/p&gt;

&lt;p&gt;}    &lt;/p&gt;

&lt;p&gt;Spacer()&lt;br&gt;&lt;br&gt;
   }&lt;br&gt;&lt;br&gt;
 }&lt;br&gt;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The Sound&lt;/p&gt;

&lt;p&gt;Similar to before, after adding an additional spacer after the HStack to define the constant sound to a certain .mp3 file, you can then apply it to the audioPlayer, hence the sound functionality (Remember to keep ContentView_Preview struct without changing a thing). You can either choose to remove the background or not based on your preference.&lt;/p&gt;

&lt;p&gt;.onAppear { &lt;/p&gt;

&lt;p&gt;let sound = Bundle.main.path(forResource: "rain-03", ofType: "mp3")                        self.audioPlayer = try! AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound!))           }&lt;br&gt;&lt;br&gt;
   }&lt;br&gt;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;That’s it! I hoped you like this tutorial on making a music player in SwiftUI! Check out the final app here: &lt;a href="https://github.com/Millennium-X/MusicPlayerDemo"&gt;https://github.com/Millennium-X/MusicPlayerDemo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s the finished product:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sfnVZoFR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fjmi5dx8q1avx8oe9e9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sfnVZoFR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fjmi5dx8q1avx8oe9e9x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading this article! &lt;br&gt;
Follow me on Medium at: &lt;a href="https://medium.com/@suryanshmansha"&gt;https://medium.com/@suryanshmansha&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why I first started programming with Swift - and why you should too.</title>
      <dc:creator>Suryansh Mansharamani</dc:creator>
      <pubDate>Thu, 14 May 2020 15:23:56 +0000</pubDate>
      <link>https://dev.to/1337/why-i-first-started-programming-with-swift-and-why-you-should-too-4530</link>
      <guid>https://dev.to/1337/why-i-first-started-programming-with-swift-and-why-you-should-too-4530</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fff39pylargef8aatfwzt.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fff39pylargef8aatfwzt.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a person with a non-technical background, I can say that scrolling through the endless rows of technical and complex questions on Stack Overflow were nothing short of mind-boggling. Luckily, Swift took those problems away by not only making me a better iOS Developer, but a more experienced programmer. For those who don't know a lick of programming, here's why Swift is absolutely perfect of you - just as it was for me.&lt;/p&gt;

&lt;p&gt;1) It's not complex!&lt;br&gt;
Xcode, the official platform where iOS developers developer games, apps, etc. had been using Objective C as the conventional programming language for years. Unfortunately, Objective C was like most other languages, filled with certain special syntax and complex ways of doing a what is now a simple task in Swift. &lt;/p&gt;

&lt;p&gt;Don't believe me? Writing "Hello World" is convention for those who just started programming. It's supposed to be simple and a welcoming way to introduce a programmer to the limitless possibles of programming. Objective C makes it a hell of a lot harder compared to Swift. Here's proof:&lt;/p&gt;

&lt;p&gt;OBJECTIVE C:&lt;br&gt;
NSString*str =@"HelloWorld";&lt;/p&gt;

&lt;p&gt;NSLog(@"%@", str)&lt;/p&gt;

&lt;p&gt;Now, SWIFT:&lt;br&gt;
let str ="HelloWorld"&lt;/p&gt;

&lt;p&gt;println("(str)")&lt;/p&gt;

&lt;p&gt;Even if someone didn't understand what both were doing and what languages they were in, they could "swift"ly say that the second one is far easier to understand.&lt;/p&gt;

&lt;p&gt;2) Too intimidated to head straight in by making a new project in Xcode with Swift, totally fine!&lt;/p&gt;

&lt;p&gt;For most beginners, the concept of Storyboards, Swift UI and complex file structures can be intimidating, and that's completing fine! Xcode gives you the option to "try it out" with Swift Playground, another awesome feature in Xcode! Swift Playground it completely self-explanatory, you can write the most simple of code snippets in Swift and run it by just pressing the Play button. You don't have to worry about Simulators, devices, or anything else!&lt;/p&gt;

&lt;p&gt;3) It's new and is always updating!&lt;/p&gt;

&lt;p&gt;The Swift programming language released in 2014, and has been updating very frequently. A new feature includes Swift UI, where you can just drag and drop buttons, labels, etc. onto the phone simulator! If that's not enough, there is also a live view feature, where the user can see how is code is affecting the looks of the app live, while they are coding!!!&lt;/p&gt;

&lt;p&gt;While this exactly isn't a main point, the Swift community is very warm and welcoming, with special events held annually! These includes the WWDC, or Worldwide Developers Conference along with an awesome Swift Student Challenge, where students can compete by making awesome games and interactive scenes in playground for special prizes including WWDC jackets, pins, and even tickets to WWDC (not this year, unfortunately)!!!&lt;/p&gt;

&lt;p&gt;(Be sure to follow me on Medium at: &lt;a href="https://medium.com/@suryanshmansha" rel="noopener noreferrer"&gt;https://medium.com/@suryanshmansha&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>swift</category>
    </item>
    <item>
      <title>Image Classification in Xcode without Code!</title>
      <dc:creator>Suryansh Mansharamani</dc:creator>
      <pubDate>Mon, 11 May 2020 22:56:45 +0000</pubDate>
      <link>https://dev.to/1337/image-classification-in-xcode-without-code-5de6</link>
      <guid>https://dev.to/1337/image-classification-in-xcode-without-code-5de6</guid>
      <description>&lt;p&gt;If you've ever wondered how to make an image classifier that you can easily implement into your own Xcode project without writing a single bit of code, here's how!&lt;/p&gt;

&lt;p&gt;First, let's access CreateML! Start by opening Xcode. As soon as you get to the opening screen, as shown on the image below, right click the Xcode icon and press Open Developer Tools. From there, you will get multiple choices to pick from. Select Create ML.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--plwds1vA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/58yvkh0qgfvfowbsvrty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--plwds1vA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/58yvkh0qgfvfowbsvrty.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you open CreateML, you will be greeted by the Finder. If you are opening a preexisting ML Model file, then you can pick from the files, but in our case, you will then go to File and then New Project as shown in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FxrTrk7O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3sqd31qb2vd725wq0lyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FxrTrk7O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3sqd31qb2vd725wq0lyy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon opening the New Project, you will see something like the image below come up. CreateML offers multiple types of machine learning platforms, including text recognition, sound identification and even an object detector! For our case, you will select the first one, which is the Image Classifier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B0LVQ_u---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kmbmkkloclo384pb1btr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B0LVQ_u---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kmbmkkloclo384pb1btr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and name your Project! This step is quite self explanatory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UKwWAKmj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2p45c162owi8usrw5d11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UKwWAKmj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2p45c162owi8usrw5d11.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After naming your project, you will come to this screen. As you can see, there is an option to add both training and testing data. In addition, you add additional parameters such as the number of iterations desired (how many times do you want the model to repeat itself?) along with augmentations. These help you in the training of your model in order to increase both the precision and recall rate, something we will talk about nearing the end of this tutorial.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RLMNhc8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lsos3p9y11qfmzhgggyo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RLMNhc8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lsos3p9y11qfmzhgggyo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How do you organize your data?&lt;/p&gt;

&lt;p&gt;Organizing your data carefully is extremely important in order for the model to work properly and to increase the precision rate. As shown by the series of images below, there are certain easy steps you should follow while organizing your data. First, divide it into both testing and training data. You will be dragging and dropping both these files into CreateML later on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4T32oh6n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xwdhjffvgnxi2q9uyb03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4T32oh6n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xwdhjffvgnxi2q9uyb03.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image below shows the folders inside the Training data folder. Both the training and testing data should be formatted exactly the same (at least for now at this point of the tutorial). The naming of your folders here is extremely important as it defines the class names. For example, these are my top 5 clouds I used in my Cloudifier app. I programmed my app to pull data out of this model and the model is trained to only return these class names.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qPLfHJMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x0khkitk6j8t3unii6zp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qPLfHJMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x0khkitk6j8t3unii6zp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here comes the difference between testing and training data, and that is by the amount of data put in. Any naming of the images is not required, as shown below, so you can drag them into the file from your browser "raw". What's extremely important is that all the data is relevant towards the class name. In addition, the training data, should be MORE than the testing data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ykny5HUw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jus448wgkliwbrjrxwcd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ykny5HUw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jus448wgkliwbrjrxwcd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that data organization is over with, we can start focusing on how to actually train the model. First drag and drop the training data into the Training Data section, as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mOduImj6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q1e9gr55v0kk98trdg2y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mOduImj6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q1e9gr55v0kk98trdg2y.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding both the training data AND the testing data, you can then selection the amount of times you want to the model to iterate itself, along with other augmentations such as cropping, flipping, rotating, etc. For those using lower end MacBook models, I recommend steering clear from augmentations and keeping the iteration number not too low nor high for a higher chance of increasing precision rate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Dpi7gvwE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/npthnl0ospvhx7lo2fe1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Dpi7gvwE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/npthnl0ospvhx7lo2fe1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press the "Train" button with Play symbol on the upper left hand corner to run your project. This will begin the process of training which usually takes a couple of seconds to multiple hours depending on the number of data and the augmentations. You can always press the Cancel button as shown below if it doesn't work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_AGCh1n7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ewfef2nxmr3tl7lr8sb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_AGCh1n7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ewfef2nxmr3tl7lr8sb4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After both the extraction of features and the iterations process is complete, then you will begin to see a graph which models the accuracy rate for both the training and validation accuracy. The validation accuracy is used to evaluate the model's performance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zr7IXTCe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l8hbgz8zxe5po4emd4mc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zr7IXTCe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l8hbgz8zxe5po4emd4mc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As the model graph is done graphing, you will then see a table which shows both the precision and recall rate of the data trained. Usually, having rates greater than 96% means that the data is well-trained. If somehow the accuracy is slightly less try adding other augmentations and/or decreasing and increasing the number of iterations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_iX1bDdU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wf1e22rq7t1hg6yd2tyu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_iX1bDdU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wf1e22rq7t1hg6yd2tyu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The model will then automatically begin to test the testing data based on the accuracy shown by the training data, as shown by the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z4fjR5Eh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kfxbau404ezby9i3vdy8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z4fjR5Eh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kfxbau404ezby9i3vdy8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the step where you get your final and most important results. Here, you see the both the precision and recall rate of the testing data. Although the validation rate is slightly less in this model, keep on tweaking certain features to increase all the rates of accuracy in order to further improve your model.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b5J75LPF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/micvvgdggdp7poc2t9ib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b5J75LPF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/micvvgdggdp7poc2t9ib.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, you can simply go to the Output file and drag the ML model as shown below into your file structure in Xcode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N_t6KOF9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g7e1944c9dd853sm497b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N_t6KOF9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g7e1944c9dd853sm497b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! I hope you liked this tutorial and will use it for your own applications! Here's the link to the orginal post on my blog (there isn't much content since I just started!): &lt;a href="https://millenniumx.carrd.co/#machinelearning"&gt;https://millenniumx.carrd.co/#machinelearning&lt;/a&gt;&lt;/p&gt;

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