Skip to content

Esri/data-collection-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Collection iOS


Data Collection for iOS shows how a robust application can be built around the ArcGIS Platform using the ArcGIS Runtime SDK for iOS and Swift. It demonstrates best practices around some simple but key functionality of the ArcGIS Runtime. Using your organization's web maps, you can use Data Collection as is, or extend it to meet your specific needs.

Map Portal Pop-up Attachments
map profile pop-up attachments
Collect Map Content Bookmarks Layers
collect extras bookmarks layers

Features

  • Taking your web map and data offline
  • Editing your data both offline and online
  • Synchronizing offline edits
  • Viewing and editing your data with Popups
  • Working with Features, Popups and PopupManagers
  • Editing and querying Feature Tables
  • Working with related records
  • Identifying map features
  • Portal authentication with OAuth
  • Using the World Geocoder service
  • Using Popup configuration to drive app behavior

Best practices

The project also demonstrates some patterns for building real-world apps around the ArcGIS Runtime SDK.

  • Map-centric UI design
  • ArcGIS asynchronous service pattern
  • Swift class extensions
  • Swift KVO & NotificationCenter state handling

Detailed documentation

Read the docs for a detailed explanation of the application, including its architecture and how it leverages the ArcGIS platform, as well as how you can begin using the app right away.

Get started

Make sure you've installed Xcode and the ArcGIS Runtime SDK for iOS and that they meet these requirements.

Fork the repo

Fork the Data Collection repo.

Clone the repo

Once you have forked the repo, make a clone.

git clone --recursive [URL to forked Git repo]

Make sure to use the "recursive" option to ensure you get the ArcGIS Runtime Toolkit submodule

If you've already cloned the repo without the submodule, you can load the submodule using

git submodule update --init

Change into the root repo directory.

cd data-collection-ios

Grant permission

The project uses a bash program named masquerade in a custom build rule to conceal app secrets in versioned source code. Grant masquerade executable permissions.

chmod +rwx data-collection/scripts/masquerade

To learn more about masquerade, consult the app's documentation.

Configuring a remote for a fork

If you make changes in the fork and would like to sync those changes with the upstream repository, you must first configure the remote. This will be required when you have created local branches and would like to make a pull request to your upstream branch.

  1. Specify a new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/Esri/data-collection-ios.git
  1. Verify the new upstream is added.
git remote -v

If there are changes made in the original repository, you can sync the fork to keep it updated with upstream repository.

  1. In the terminal, cd to your local project repo.

  2. Fetch the commits from the upstream repository.

git fetch upstream
  1. Checkout your fork's local master branch.
git checkout master
  1. Sync your local master branch with upstream/master.
git merge upstream/master

Note, your local changes will be retained and your fork's master branch will be in sync with the upstream repository.

Configure the app

1. Register an application

The app uses OAuth to authenticate users to a web map hosted in your ArcGIS Portal. Register an application with the developers website to broker authentication between the app and your Portal.

  1. Log in to developers.arcgis.com with either your ArcGIS Organizational Account or an ArcGIS Developer Account.
  2. Visit your dashboard and create a new application.
  3. Click the 'Authentication' tab.
  4. Note the Client ID, we'll use it in a future step.
  5. Add a new Redirect URI, data-collection://auth

The Client ID configures the ArcGIS Runtime to show your users, during the login process, that the application was built by you and can be trusted.

The Redirect URL configures the OAuth process to then return to your app once authentication is complete.

2. Configure the project

Configure the project to access your organization's Portal and web map.

If you would like to run the application using a demo data set maintained by Esri, you can ignore this step.

  1. Open the project named data-collection.xcodeproj in Xcode.
  2. Browse to the file named AppConfiguration.swift located in the directory named data-collection.
  3. Configure the app with your organization's base portal domain by modifying the value of the property named basePortalDomain.
  4. Configure the app with your organization's web map by modifying the value of the property named webMapItemID.

3. Configure app secrets

As a best-practices principle, the project conceals app secrets from source code by generating and compiling an AppSecrets.swift source code file at build time using a custom build rule.

This build rule looks for a secrets file stored in the project directory, $(PROJECT_DIR)/.secrets.

  1. Create a hidden secrets file in the project's root directory.
touch data-collection/.secrets
  1. Add your registered app's Client ID to the secrets file.
echo ARCGIS_CLIENT_ID=your-client-id >> data-collection/.secrets

Replace 'your-client-id' with your app's Client ID.

  1. Optionally add your License Key to the secrets file. Licensing the app will remove the 'Licensed for Development' watermark. Licensing the app is optional in development but required for production. Acquire your license key from your dashboard.
echo ARCGIS_LICENSE_KEY=your-license-key >> data-collection/.secrets

Replace 'your-license-key' with your License Key.

A Lite license is free and enables most of the capabilities required by this app, with the exception of offline editing and synchronizing offline edits back to a feature service. For offline editing and synchronizing, you need a Basic license. Visit the developer's website to learn more about licensing your ArcGIS Runtime app and the different ArcGIS Runtime license levels.

To learn more about masquerade, consult the app's [documentation]](./docs#app-configuration).

Learn More

Learn more about Esri open source apps here.

Requirements

  • Xcode 12 and Swift 5
  • ArcGIS Runtime SDK for iOS, version 100.11 or later.
  • ArcGIS Runtime Toolkit for iOS, version 100.11 or later.
  • To edit records or take a web map offline you will need an ArcGIS Online Organizational account, an ArcGIS Online Developer account or an ArcGIS Online account authenticated using a social login.
  • To consume your own web map you will need an ArcGIS Online Organizational account.
  • Device or Simulator running iOS 13.0 or later.

Contributing

Anyone and everyone is welcome to contribute. We do accept pull requests.

MDTOC

Generation of this and other document's table of contents in this repository was performed using the MDTOC package for Atom.

Licensing

Copyright 2018 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's LICENSE file.

For information about licensing your deployed app, see License your app.

3rd Party Component Licensing

Some great open source components are available out there for iOS developers. The following have been used in this project, with much gratitude to their authors.