2. Create forceios App

In this unit, you'll use forceios tool and generate a template native iOS App.

Step 1: Generate A Swift Sample App

In this step you'll use forceios tool to generate a sample Swift app that uses mobile SDK. In order to connect to Salesforce, we need to have a Salesforce Connected App with a new App ID and Callback URL. To simplify, forceios tool generates a template app that already uses a test app's "App ID" and "Callback URL"

  1. Open Terminal
  2. Type forceios create and hit enter to start generating the sample app.
  3. Type native_swift for Enter your application type (native, nativeswift, reactnative, hybridremote, or hybridlocal): and hit Enter. This generates a sample app for type Swift iOS.
  4. Type SwiftSample for Enter your application name: and hit Enter.
  5. Hit Enter (leave the answer empty) for Enter the output directory for your app (defaults to the current directory):
  6. Type com.example.swiftsample for Enter the package name for your app (com.mycompany.my_app):
  7. Type Example Inc for Enter your organization name (Acme, Inc.):
  8. Hit Enter(leave the answer blank) for Enter your Connected App ID (defaults to the sample app's ID):. The sample app will use the template app's own App ID. We can change this later
  9. Hit Enter(leave the answer blank) for Enter your Connected App Callback URI (defaults to the sample app's URI):. This will use the template app's own Callback URI. We can change this later as well.
  10. At this point, you should have a folder called SwiftSample

Note that this make take few minutes to download and install everything

Step 2: Install SDK dependencies

In this step you'll use Cocoapods tool to install Salesforce Mobile SDK's dependencies.

  1. In the terminal, CD into SwiftSample by running: cd SwiftSample
  2. Install dependencies by running: pod install
  3. If you do ls -al in the terminal, you should see SwiftSample.xcworkspace among other files.
  4. Open the app by running: open SwiftSample.xcworkspace. This opens the app in Xcode.

    Note: You should open SwiftSample.xcworkspace and NOT the SwiftSample.xcproject because the xcworkspace will now have the pod files.

index
  1. Setting Up Developer Environment
  2. Creating forceios App
  3. Running forceios App
  4. Adding Connected App
  5. Adding PIN Protect
  6. Next Steps
comments powered by Disqus