Preface

0.1 Introduction & Prerequisites

R has a very accessible C interface1 which can be used both by R extensions2 (a.k.a. packages) or in any programming language that supports using libraries with a C-like interface.

Apple’s Swift programming language3 is used by developers to craft iOS, iPadOS, watchOS, tvOS, and macOS applications and has matured much since Swift 1.0 (at the time of this writing Swift is at version 5.3). More recent versions of Swift have made it much easier to use R’s C interface directly from Swift and the goal of this book is to get you started making command-line apps as well as macOS GUI apps using R’s C interface from Swift.

All the examples were created using Xcode 12.x on macOS Big Sur. Where possible, application targets are set to 10.14 (Mojave)+, but some SwiftUI 2 (the modern way to craft macOS GUI apps) features are only available on macOS 11.x (Big Sur).

To get the most out of this book, you’ll need R installed4, have at least a free Apple Developer account5 and a copy of Xcode 126.

For those really new to working in Xcode, Apple has some great starter documentation7 that may be helpful to run through before trying any of the projects/code in the remaining chapters.

0.2 Up Next

With your developer account setup and Xcode ready to roll we’ll build our first macOS command line app with Swift/Xcode.

Code examples can be found on GitHub8, though it may take some time for them to be fully organized and mapped to book chapters.