iOS Ecommerce App Template – Technical Documentation

This page contains the technical documentation you’ll need in order to be able to compile and add further customizations to our iOS Ecommerce App Template (which you can download here).

Build and run the Xcode project

1. Install the latest version of Xcode. If you already have Xcode installed on your computer, make sure you update it to the latest version. We keep our Swift code up-to-date, so you’ll need the latest Apple updates in order to avoid eventual compatibility issues.

2. Unarchive the downloaded .zip file. This will extract the Xcode project, which you’ll be able to compile and run, by following the next steps.

3. Open up a terminal and navigate to the downloaded folder (by running “cd ~/Users/path_to_folder/EcommerceApp”)

4. Install CocoaPods and make sure it is up to date. Please go to https://cocoapods.org if you are not familiar with pods.

5. Run “pod update” in your terminal, in order to make sure your cocoa pod software is up to date. This will ensure you’ll be working with the latest version of all the pods that this project is relying on. 

6. In the terminal window, run “pod install” command. Running this command downloads all the dependencies that are relied on (libraries such as Alamofire, Firebase, Fabric, etc). If everything ends successfully, you’ll see the following results in your terminal:

wordpress ios mobile app template cocoapods pod install

As a side note, if your app crashes because TwitterKit is out of date, try and run “pod update TwitterKit” in your terminal.

7. Open the file “EcommerceApp.xcworkspace” with Xcode. Then go to Product -> Run (or press Command + R). The project should now be running on an iOS simulator (or device).

Configure Firebase Authentication

In order to store your users in Firebase, you need to configure the Authentication section of your Firebase account. There you can specify which login methods your iOS app will support. Just go to Firebase -> Authentication and enable the preferred options. For instance, this is how our configuration looks like (we enabled Login with Facebook and Twitter, as well as regular sign in, with email and password).

iOS Swift Mobile Firebase Login Authentication app

Keep in mind that Google has strict rules when it comes to signing in with email and password, so make sure you type in valid email addresses and passwords that are longer than 6 characters. By default, the template will create user accounts for all the unexisting users that try to log in (the form is essentially a sign up form if the user doesn’t exist, and a sign in form, if the user exists already).

Configure the Firebase Database

By default, the iOS Ecommerce App Template is displaying some static, hard coded products. In order to make the shopping theme use your own products, you’ll have to hook up the Swift code to your own database. In this section, we’re assuming that your shopping products are stored in a Firebase Database. Keep in mind that Firebase provides ways to import your data from other places. If your shopping items are stored in a SQL database, for example, you might be able to move them to Firebase with very little effort.

  1. Go to AppConfiguration.swift file, and set “isFirebaseDatabaseIntegrationEnabled” to “true“.
  2. Go to Firebase Console and configure your application’s database. If this is your first time doing this, you’ll need to create a new iOS application and set its database. See the screenshot below to visualize the structure of the product database.
    iOS Ecommerce App Template
  3. If you have a different structure for your data, you’ll need to update the parsing logic. For example, look into Product.swift, to see that there’s a 1-1 relationship between the product structure and the fields used by the mapping function:iOS Ecommerce App Template Swift Code Parsing
  4. By default, the downloaded Swift project uses one of our own Firebase databases. In order to make it use your own database, you’ll need to replace the GoogleService-Info.plist file with your own. You can download your GoogleService-Info.plist corresponding to your Firebase account by following the steps described here – download a configuration file.
  5. As the last step, you need to provide permissions for your app to access the Firebase database. To do this, go to Firebase -> Database -> “Rules” tab and replace your database access rules to
{
  "rules": {
    ".read": true,
    ".write": "auth != null"
  }
}

This will enable read access, so that the iOS app will have permissions to read the products and categories.

If you encounter any errors while trying to compile, run or make customizations to our iOS ecommerce app template, don’t hesitate to contact us.