Creating an iOS Project with Forceios
- Specify the type of application you want, along with basic configuration
data.
or
- Use an existing Mobile SDK app as a template. You still provide the basic configuration data.
Forceios Application Types
For application type, the forceios create command accepts either of the following input values:
| App Type | Language |
|---|---|
| Type native_swift (or press RETURN) | Swift |
| Type native | Objective-C |
Using forceios create Interactively
1$ forceios create
2Enter your application type (native, native_swift): <press RETURN>
3Enter your application name: testSwift
4Enter the package name for your app (com.mycompany.myapp): com.bestapps.ios
5Enter your organization name (Acme, Inc.): BestApps.com
6Enter output directory for your app (leave empty for the current directory): testSwiftUsing forceios create in Script Mode
1$ forceios create --apptype="native_swift" --appname="package-test" --packagename="com.acme.mobile_apps"
2 --organization="Acme Widgets, Inc." --outputdir="PackageTest"1$ forceios create --apptype="native" --appname="package-test" --packagename="com.acme.mobile_apps"
2 --organization="Acme Widgets, Inc." --outputdir="PackageTest"Each of these calls creates a native app named “package-test” and places it in the PackageTest/ subdirectory of your current directory.
Creating an App from a Template
The forceios createWithTemplate command is identical to forceios create except that it asks for a GitHub repo URI instead of an app type. You set this URI to point to any repo directory that contains a Mobile SDK app that can be used as a template. Your template app can be any supported Mobile SDK app type. The script changes the template’s identifiers and configuration to match the values you provide for the other parameters.
1Available templates:
2
31) Swift application using MobileSync, SwiftUI and Combine
4forceios createwithtemplate --templaterepouri=iOSNativeSwiftTemplate
5
62) Swift application using MobileSync, SwiftUI and Combine (pulled in using Swift Package Manager)
7forceios createwithtemplate --templaterepouri=iOSNativeSwiftPackageManagerTemplate
8
93) Basic Swift application with notification service extension
10forceios createwithtemplate --templaterepouri=iOSNativeSwiftEncryptedNotificationTemplate
11
124) Basic Objective-C application
13forceios createwithtemplate --templaterepouri=iOSNativeTemplate
14
155) Sample Swift Identity Provider application
16forceios createwithtemplate --templaterepouri=iOSIDPTemplate
17
186) Sample Swift application using MobileSync data framework
19forceios createwithtemplate --templaterepouri=MobileSyncExplorerSwift1Usage:
2forceios createWithTemplate
3 --templaterepouri=<Template repo URI> (e.g., MobileSyncExplorerReactNative)]
4 --appname=<Application Name>
5 --packagename=<App Package Identifier> (e.g. com.mycompany.myapp)
6 --organization=<Organization Name> (Your company's/organization's name)
7 --outputdir=<Output directory> (Leave empty for current directory)]1forceios createwithtemplate --templaterepouri=iOSNativeSwiftTemplate1forceios createWithTemplate
2--templaterepouri=MobileSyncExplorerSwift
3--appname=MyMobileSyncExplorer
4-—packagename=com.mycompany.react
5--organization="Acme Software, Inc."
6-—outputdir=testWithTemplateChecking the Forceios Version
1forceios versionRunning Your New forceios Project
Apps created with forceios are ready to run, right out of the box. After forceios finishes, it prints instructions for opening and running the project from the command line.
- In Xcode, select .
- Navigate to the output folder you specified.
- Open the workspace file (<project_name>.xcworkspace).
- When Xcode finishes building, click the Run button.
How the Forceios Script Generates New Apps
- Apps are based on CocoaPods or Swift Package Manager.
- The script downloads templates at runtime from a GitHub repo.
- For the forceios create command, the script uses the default templates in the SalesforceMobileSDK-Templates GitHub repo.
- For templates based on CocoaPods, the script uses npm at runtime to download Mobile SDK libraries. The podfile refers to these libraries with :path => node_modules/... directives.
- For projects built with Swift Package Manager, the script configures the Xcode project to use the Salesforce Mobile SDK Swift Package published on https://github.com/forcedotcom/SalesfoceMobileSDK-iOS-SPM.