Build the future of communications.
Start Building for Free

Swift posts

  • By Lizzie Siegle
    Receive and Respond to Text Messages with Server-Side Swift, Perfect, and Twilio perfecttwilioswift.jpg

    Perfect is a versatile open source server-side Swift framework and toolset that makes it easy for developers to quickly create server- and client-side apps. Let's see how easy it is to send SMS with Twilio and Perfect.

    Setup

    To follow along with this post we'll need

    Install Perfect using the Swift Package Manager. Create a new project directory called PerfectSMS and then on the command line in your project directory, run

    swift package init --type executable
    swift package generate-xcodeproj
    

    This generates a package with the same name as your current directory.

    1. Package.swift at the top-level of your project contains your package description and your package’s dependencies.
    2. Sources/ is home to all your Swift source files, including main.swift, which will be the entry point for your project. It currently prints hello, world to the Terminal.
    3. Tests/ will contain unit tests you can write …
    Read More
  • By Barney Waiganjo
    How to Add Keyframe Animations to iOS Apps in Swift 4 OibP_MhVytCwAouP1CsLwizQPWxk1cSLY46NM69XDz2GyYJ3ddBQOBfAzWu-i3dU-CAjYUO2AbG5dTSJL6ZjW9t2cVkD05fO8c4tbb5kTuLdYoTZi9r8NQy5V1svA1SzWwtm6Q81

    In the beautiful world of modern iOS applications, not much stands out more than well applied animations and transitions. They capture the user’s attention and set your app apart from the competition. If you’ve ever wished to add cool animations to your current or future projects but felt it was too challenging, this article is purposely meant to change your mind.

    Tools You’ll Need

    To be able to follow along with this tutorial, there are a couple of prerequisites before we start. You will need:

    • A Mac running the latest point release of macOS X Sierra or later.
    • Xcode 8 or later.
    • Basic knowledge of the Swift 4 language and Auto Layout.

    Getting Started

    Now that we have all that we’ll need, let’s find out what we’re going to be working on.
    I have already set up a small project for us to work on. You can download it …

    Read More
  • By Lizzie Siegle
    Intro to Markov Models with Swift Rick Roll Cover Image

    Did you know PageRank, the algorithm Google uses to determine the order of search results, is a type of Markov chain? I first learned about Markov chains and Markov models in my Speech Synthesis and Recognition elective and was amazed at how they are used in speech recognition, music generation, and modeling sequential data to predict the outcome of a basketball game (or almost any competition.)

    What are Markov Chains and Markov Models?

    The most basic type of Markov model is a Markov chain, a model whose next state is only selected based on its current state. Markov chains are used in genetics, finance, economics, game theory, and other fields. An example of one would be predicting tomorrow's weather by looking only at today's weather, not yesterday's.

    weather prediction with a ball gif

    Wikipedia defines a Markov model like so:

    In probability theory, a Markov model is a stochastic model used to model randomly changing …

    Read More
  • By Lizzie Siegle
    Intro to Speech Recognition in Swift via FlyoverKit speechsiricombined.jpg

    One of my favorite computer science electives was Speech Synthesis and Recognition because Natural Language Processing and Computational Linguistics are becoming more widespread (look at Siri!). In this post we will add speech recognition to select famous landmarks with FlyoverKit in Swift. If you haven't seen part one of this multi-part series, check it out on the Twilio blog here.

    Setup

    For this post you will need Xcode 10, a Mac, and a physical iOS device to test the speech recognition features. To follow along with this post make sure to clone the corresponding GitHub repo here as we'll be adding speech recognition capabilities to it. If you just want to make a simple speech recognition app in Swift, you can use the same code but just need to add a button to your ViewController. Name the button locButton, and create a label called placeLbl …

    Read More
  • By Barney Waiganjo
    Animating View Properties in Xcode with Swift 4 and Auto Layout eKnIEBdn-ZMTKBDw32Y26D3o572YaEi7krXp0OLWm_zuNoUtN-RvlBAPX81w-nJW2eBUiPZ3rTP6Ik5DQiN1yA4DZssOnsS3WYQkaCMV_l0CbgSSLCT5pq1_QhrZ_PwxJH0z7wv_

    One way to make your iOS applications more interactive is by adding awesome view animations. They always look cool and are surprisingly easy to accomplish. You’re in the right place if you would love to learn how to add fun animations to your next project.

    Tools You’ll Need

    To be able to follow along with this tutorial, there are a couple of prerequisites before we start. You will need:

    • A Mac running the latest point release of macOS X Sierra or later.
    • Xcode 8 or later.
    • Basic knowledge of the Swift 4 language and Auto Layout.

    If you don’t have any of these, go ahead and get them now.

    Getting Started

    Now that we have what we’ll need, let’s get to work. I’ve already set up a small project for us to work on. You can download it here or if you prefer to check out the GitHub …

    Read More
  • By Sam Agnew
    Working with JSON in Swift Swift JSON

    Often developers need to deal with data in various different formats and JSON, short for JavaScript Object Notation, is one of the most popular choices. This is the syntax that the JavaScript language uses to denote objects.

    For this post, we are going to use the following modified JSON data from NASA's Astronomy Picture of the Day API to cover some basic examples of scenarios where you'd need to parse JSON. You will need to be running Swift 4.0 or greater. The following JSON is the example that we are going to be working with:

    {
        "copyright": "Yin Hao",
        "date": "2018-10-30",
        "explanation": "Meteors have been shooting out from the constellation of Orion. This was expected, as October is the time of year for the Orionids Meteor Shower. Pictured here, over two dozen meteors were caught in successively added exposures last October over Wulan Hada volcano in Inner Mongolia, China. …
    Read More
  • By Lizzie Siegle
    Travel the World with FlyoverKit in Swift flyoverkitheader.jpg

    I was a bit jealous to see some of my peers visit multiple cities and countries after graduation. What if we could build an app that could take us to all those places instead? FlyoverKit is a Swift library that presents you with "stunning 360° flyover views of various monuments on a MKMapView." This post will go over how to see different sights with FlyoverKit by generating a random location at the click of a button. The Sagrada Familia and the Eiffel Tower (shown below) are just a few of the locales we'll be flying over in this post.

    Sagrada Familia Eiffel Tower

    In part two of this multi-part series, we will go over how to travel the world with FlyoverKit with speech recognition in Swift.

    Setup

    This post …

    Read More
  • By Barney Waiganjo
    Working with iOS View Animations and Transitions in Swift VKwo826Z04oZh4JHc0AmU15CYraDoF4fQLdSAMMqc6QK9n9vH_ds0Ijh2YFLvw1mpbjB9T7ch7Fy3nOmZhGtDA5nWqtFhG90oSMGl8cvQNyLu1jc2dwcz-_C8MNNgw_m7fprloJX

    If you use an Apple device, you’ve probably seen a bunch of animations from third-party apps or Apple’s stock apps. If you ever wished you knew how to do that, but thought it looked too complicated, your wish is about to come true. Follow along with me and you’ll discover that creating animations in iOS is not only uncomplicated, but also fun.

    Animations grab a user’s attention and allow them to focus on what’s important on the screen. Animations also highlight changes on the screen and can help a user learn to navigate your app. But who are we kidding, everyone loves animations. They’re just so cool.

    Tools You’ll Need

    To follow along with this tutorial, assuming you are an iOS developer looking to explore the world of animations, you will need a couple of prerequisites:

    • A Mac running the latest point release of macOS X Sierra or later.
    • Xcode …
    Read More
  • By Kelley Robinson
    How to Test Your iOS Application on a Real Device Screen Shot 2018-07-31 at 4.25.07 PM

    There are some features of iOS apps that don’t work from the iOS simulator. Maybe you want to test how your application works with the device camera or send an SMS message from your application. For these examples and more you’ll need to test and debug your app using a real device.

    This post will walk through how to run the Xcode simulator on your iPhone or other iOS device and show you how to fix some common errors you’ll see along the way.

    How to select your iPhone as the “Simulator” Device

    Simulator is in quotes here since this will create an actual app on your phone; it’s no longer a simulation. Open up a project in Xcode and click on the device near the Run ▶ button at the top left of your Xcode screen.

    Plug your iPhone into your computer. You can select your device from the …

    Read More
  • By Sam Agnew
    Sending text messages from your iOS app in Swift using MFMessageComposeViewController Screen Shot 2018-07-17 at 6.45.06 PM

    Do you ever want to send text messages in your iOS app from your user’s phone number? While you can’t do this directly without your user’s consent, you can display a pre-composed message for your user to send using MFMessageComposeViewController.

    If you want to programmatically send an SMS from a different phone number, you can do this with Swift using Twilio.

    That’s cool. Let’s send a message!

    If you already have an app and want to get straight to the point, here’s the code you need to display the message composition interface:

    let composeVC = MFMessageComposeViewController()
    composeVC.messageComposeDelegate = self
    
    // Configure the fields of the interface.
    composeVC.recipients = ["13142026521"]
    composeVC.body = "I love Swift!"
    
    // Present the view controller modally.
    if MFMessageComposeViewController.canSendText() {
        self.present(composeVC, animated: true, completion: nil)
    }
    

    This code will send a text message to a Twilio number that is set up to give a programmatic …

    Read More
  • Newer
    Older
    Sign up and start building
    Not ready yet? Talk to an expert.