Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now
Build the future of communications.
Start building for free

Swift posts

  • 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 …
    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 …

    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 = [ …
    Read More
  • By Kelley Robinson
    How to do Phone Verification in iOS Apps with Twilio Verify and Swift iOS phone verification message

    Security is at the top of everyone’s mind and phone verification is a simple way to secure your application and help prevent bot accounts. Phone verification is a common security tool used when people sign up for a product or give you their phone number for the first time.

    Confidence in your users’ phone numbers decreases fraud and increases reliability of notifications. Let’s take a look at how to verify phone numbers from an iOS application using Swift and the Twilio Verify API.

    mulaney i smell a robot

    This tutorial will walk you through the process of SMS phone verification step by step. You can check out the final project on my GitHub.

    What you’ll need

    To code along with this post, you’ll need:

    Setting up

    Navigate to the …

    Read More
  • By Kayeli Dennis
    Building Reusable iOS Components in Swift ei1MoM9cqEUQoseUZ1fpzblpTtpjK57YFUArLmVFPgOis3ZmqCYMqpubojrk5DTPo8DwWsIXc-xV9Hn5-mJga7eQhlhdoQ9q1kVmoAB-FaQXnYrbHdfPvXrucIzeVR0OvGNQF8TI

    Keeping it DRY (Don’t Repeat Yourself) is every software developer’s priority in seeing a product through to completion. It not only helps make debugging easier, but also provisions easy testing and writing less code whilst achieving more. More than once, I’ve found myself building reusable components to reduce the repetitiveness in my code. For instance, building an iOS application will involve building multiple table view controllers. This means one will end up writing the same pieces of code in a couple of places that feed the table view controllers with data. Why not just build a wrapper and reuse it throughout the app as a plugin?

    Hopefully by the end of this article I’ll convince you to start building reusable components in Swift for iOS application development. To demonstrate reusable components, we’ll build a dummy app that simulates a company providing employees with meals and then soliciting a feedback form …

    Read More
  • By Sam Agnew
    Handling Incoming Phone Calls with Server Side Swift, Vapor and Twilio Screen Shot 2018-06-01 at 11.37.46 AM

    You’re building a Vapor app and want to be able to handle phone calls? Let’s walk through how to add Twilio Programmable Voice to the barebones Vapor “Hello World” app.

    Swift Package Manager

    For this project we’re going to use Swift Package Manager to set everything up and install dependencies. Make sure you have Swift 4.0 or greater installed before moving on. You can check your Swift version by running the following in your terminal:

    swift --version
    

    Vapor has a convenient command line tool which can be used to generate templates for projects. Installing this will also take care of other necessary dependencies.

    You can install it using Homebrew with the following command:

    Read More
  • By Angela Mugo
    Migrating Swift iOS Apps from MVC to MVVM w0ApU8yEXOQiOaKjv-wYaUGfcWOCtUzTWv8_EmGR5LX5wptM0eQ6DEBeQr0kEgX4cQHaGvxnQV3sHDC_sbvXSNUIl-WByh80uAx_srp92AX2XMSWwRAPAhCVN9nFvi2PN5jJ3rEr

    Design patterns are reusable solutions to common problems in code. MVVM (Model-View-Viewmodel) and MVC (Model-View-Controller) are both design patterns. While MVC is a very common and easy-to-implement design pattern, it has been faulted as very inefficient while working with large code bases. If you’ve built a product, you’ve probably built using MVC. Other common design patterns include MVP (Model-view-presenter) and VIPER (here is a little write up that describes them). In this post, we’ll be concentrating on MVVM and MVC.

    Why use design patterns? We use them because design patterns are typically easier to reuse and debug than an unproven design. Say you solve a problem without any particular design, and at the moment, it works. However, in the future you get a bug. When you go back to debug, it may be hard to figure out where some things are and why you even did them in the …

    Read More
  • By Sam Agnew
    Receiving and Responding to Text Messages with Server Side Swift, Vapor and Twilio Screen Shot 2018-05-29 at 7.05.00 PM

    You’re building a Vapor app and want to be able to respond to SMS messages? Let’s walk through how to add Twilio SMS to the barebones Vapor “Hello World” app.

    Swift Package Manager

    For this project we’re going to use Swift Package Manager to set everything up and install dependencies. Make sure you have Swift 4.0 or greater installed before moving on. You can check your Swift version by running the following in your terminal:

    swift --version
    

    Vapor has a convenient command line tool which can be used to generate templates for projects. Installing this will also take care of other necessary dependencies.

    You can install it using Homebrew with the following command:

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