Skip to content

Commit

Permalink
Introduce gps and bte ios targets
Browse files Browse the repository at this point in the history
Why:
We would like to introduce bluetooth to the application for bluetooth
based contact tracing. Given the privacy concerns of having both
location and bluetooth data available to the same application, google
and apple do not allow for both location and bluetooth to be available
at the same time.

Hence in order to service both location and bluetooth
we will need to provide separate apps with separate info.plists and
bundle identifiers. At the same time we would like to share a much
application logic between the two applications as to reduce the
maintenance and organizational overhead. Ideally as close to 100% of the
javascript layer is common and for the ios layer we only need to change
the info.plists.

This commit:

Introduces two build targets, GPS and BTE, to the xcode project which
are setup to read from the corresponding groups for config and info.plist
A COVIDSafePathsConfig file was introduced to expose a
'getTracingStrategy' function to the react native side so that the js
runtime can determine which tracing strategy the bundle will be using.
This will allow us flexibility to programmatically determine which
tracing strategy is being used either within a given react component or
to conditional render components altogether. This also allows use to
maximize the amount of shared native code.

Three schemes where added for each target, a Development, a Staging, and
a Production.

To build the corresponding targets via the react native cli, you can
pass the --scheme flag with the corresponding scheme, e.g:

react-native run-ios --scheme "GPS_Development"
react-native run-ios --scheme "BTE_Development"
We updated the yarn run-ios script in package.json to two scripts for
for the gps based build and the bte based build, yarn run-ios-bte and
yarn run-ios-gps respectively

Note that theres a fair amount of location information storing logic
currently in AppDelegate, a future commit might want to refactor this so
that the gps specific code is only built in the GPS target builds.

We also updated the targets for the tests one for each build target,
GPSTests and BTETests respectively. Note that the tests are currently
only being run for the GPS version of the app, as the BTE version does
not have any different native code at this point.
  • Loading branch information
johnschoeman committed May 21, 2020
1 parent 2ccb2d4 commit 93cca7d
Show file tree
Hide file tree
Showing 32 changed files with 2,020 additions and 149 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ jobs:
# TODO(https://pathcheck.atlassian.net/browse/SAF-250): remove the skip on COVIDSafePathsTests/testRendersWelcomeScreen once it's passing
- run: |
xcodebuild test -workspace COVIDSafePaths.xcworkspace \
-scheme COVIDSafePathsTests \
-scheme GPS_Tests \
-destination 'platform=iOS Simulator,name=iPhone 8' \
-skip-testing COVIDSafePathsTests/COVIDSafePathsTests/testRendersWelcomeScreen
-skip-testing GPSTests/COVIDSafePathsTests/testRendersWelcomeScreen
working-directory: ./ios
e2e-ios-build:
Expand Down
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ buck-out/
!debug.keystore

# i18next-parser
gps/app/locales/*_old.json
/app/locales/*_old.json

# fastlane
#
Expand Down Expand Up @@ -75,10 +75,22 @@ e2e/artifacts/*
.vscode/*

# Local iOS build artifacts
ios/COVIDSafePaths.ipa
ios/COVIDSafePaths.app
ios/COVIDSafePaths.app.dSYM.zip

ios/COVIDSafePaths-staging.ipa
ios/COVIDSafePaths-staging.app
ios/COVIDSafePaths-staging.app.dSYM.zip

ios/COVIDSafePaths-bte.ipa
ios/COVIDSafePaths-bte.app
ios/COVIDSafePaths-bte.app.dSYM.zip

ios/COVIDSafePaths-staging-bte.ipa
ios/COVIDSafePaths-staging-bte.app
ios/COVIDSafePaths-stating-bte.app.dSYM.zip

# Local Android build artifacts
android/app/src/main/assets/index.android.bundle

Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ Read the [contribution guidelines](CONTRIBUTING.md).

View the [architecture diagram](docs/Private_Kit_Diagram.png) for a basic overview on the sequencing of generalized events and services that are used by Safe Paths.

## WhiteLabeling

PathCheck is building two versions of the application. One for location based
contact tracing and one for bluetooth based contact tracing. Given that the same
application cannot have both gps and bluetooth enabled for privacy
considerations, we need be able to build two separate version of the app for
distribution.

We are following a white labeling strategy to accomplish this. That we have two
build targets for each app which use the same codebase. Ideally using the same
code across the products as possible.

## Developer Setup

First, run the appropriate setup script for your system. This will install relevant packages, walk through Android Studio configuration, etc.
Expand Down Expand Up @@ -99,9 +111,16 @@ Device storage can be cleared by long-pressing on the app icon in the simulator,

#### iOS (macOS only)

Install the pod files:

```
yarn install:pod ## only needs to be ran once
npx react-native run-ios
```

run the application:
```
yarn run-ios-gps ## for the location enabled app
yarn run-ios-bte ## for the bluetooth enabled app
```

Device storage can be cleared by clicking "Hardware" on the system toolbar, and then "Erase all content and settings".
Expand Down
5 changes: 5 additions & 0 deletions app/COVIDSafePathsConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { NativeModules } from 'react-native';

export const config = {
tracingStrategy: NativeModules.COVIDSafePathsConfig.getTracingStrategy(),
};
1 change: 1 addition & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"about": {
"dimensions": "Dimensions:",
"operating_system_abbr": "OS:",
"tracing_strategy": "Tracing Strategy:",
"version": "Version:"
},
"authorities": {
Expand Down
10 changes: 10 additions & 0 deletions app/views/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Icons } from '../assets';
import NavigationBarWrapper from '../components/NavigationBarWrapper';
import { Typography } from '../components/Typography';
import Colors from '../constants/colors';
import { config } from '../COVIDSafePathsConfig';

export const AboutScreen = ({ navigation }) => {
const backToMain = () => {
Expand Down Expand Up @@ -65,6 +66,15 @@ export const AboutScreen = ({ navigation }) => {
<View style={styles.spacer} />

<View style={styles.main}>
<View style={styles.row}>
<Typography style={styles.aboutSectionParaBold}>
{languages.t('about.tracing_strategy')}
</Typography>
<Typography style={styles.aboutSectionPara}>
{config.tracingStrategy}
</Typography>
</View>

<View style={styles.row}>
<Typography style={styles.aboutSectionParaBold}>
{languages.t('about.version')}
Expand Down
8 changes: 8 additions & 0 deletions ios/BTE/COVIDSafePaths.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
26 changes: 26 additions & 0 deletions ios/BTE/COVIDSafePathsConfig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// COVIDSafePathsConfig.m
// COVIDSafePaths
//
// Created by John Schoeman on 5/17/20.
// Copyright © 2020 Path Check Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import <Foundation/Foundation.h>
#import "COVIDSafePathsConfig.h"

@implementation COVIDSafePathsConfig : NSObject

RCT_EXPORT_MODULE();

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getAppName) {
return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getTracingStrategy) {
return @"bte";
}

@end
112 changes: 112 additions & 0 deletions ios/BTE/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.transistorsoft.fetch</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>COVIDSafePaths-bte</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.28</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.28</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>itms-apps</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict/>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app uses Bluetooth to securely collect and share random IDs with nearby devices. The app can use these IDs to notify you if you've been exposed to COVID-19</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app uses Bluetooth to securely collect and share random IDs with nearby devices. The app can use these IDs to notify you if you've been exposed to COVID-19</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Your location history will be saved on your device, and only shared with others if you choose to do so.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Your location history will be saved on your device, and only shared with others if you choose to do so.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location history will be saved on your device, and only shared with others if you choose to do so.</string>
<key>NSMainNibFile</key>
<string>LaunchScreen</string>
<key>NSMotionUsageDescription</key>
<string>We use your accelerometer for accurate location history.</string>
<key>UIAppFonts</key>
<array>
<string>IBMPlexSans-Bold.ttf</string>
<string>IBMPlexSans-BoldItalic.ttf</string>
<string>IBMPlexSans-ExtraLight.ttf</string>
<string>IBMPlexSans-ExtraLightItalic.ttf</string>
<string>IBMPlexSans-Italic.ttf</string>
<string>IBMPlexSans-Light.ttf</string>
<string>IBMPlexSans-LightItalic.ttf</string>
<string>IBMPlexSans-Medium.ttf</string>
<string>IBMPlexSans-MediumItalic.ttf</string>
<string>IBMPlexSans.ttf</string>
<string>IBMPlexSans-SemiBold.ttf</string>
<string>IBMPlexSans-SemiBoldItalic.ttf</string>
<string>IBMPlexSans-Thin.ttf</string>
<string>IBMPlexSans-ThinItalic.ttf</string>
<string>IBMPlexMono-Bold.ttf</string>
<string>IBMPlexMono-BoldItalic.ttf</string>
<string>IBMPlexMono-ExtraLight.ttf</string>
<string>IBMPlexMono-ExtraLightItalic.ttf</string>
<string>IBMPlexMono-Italic.ttf</string>
<string>IBMPlexMono-Light.ttf</string>
<string>IBMPlexMono-LightItalic.ttf</string>
<string>IBMPlexMono-Medium.ttf</string>
<string>IBMPlexMono-MediumItalic.ttf</string>
<string>IBMPlexMono.ttf</string>
<string>IBMPlexMono-SemiBold.ttf</string>
<string>IBMPlexMono-SemiBoldItalic.ttf</string>
<string>IBMPlexMono-Thin.ttf</string>
<string>IBMPlexMono-ThinItalic.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>bluetooth-peripheral</string>
<string>fetch</string>
<string>location</string>
<string>processing</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
24 changes: 24 additions & 0 deletions ios/BTETestsInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.28</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.28</string>
</dict>
</plist>
Loading

0 comments on commit 93cca7d

Please sign in to comment.