Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a staging configuration that automatically targets the staging environment #5677

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ios-screenshots-creation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: iOS create screenshots
on:

Check warning on line 3 in .github/workflows/ios-screenshots-creation.yml

View workflow job for this annotation

GitHub Actions / check-formatting

3:1 [truthy] truthy value should be one of [false, true]
push:
tags:
- ios/*
Expand Down Expand Up @@ -39,6 +39,7 @@
cp App.xcconfig.template App.xcconfig
cp PacketTunnel.xcconfig.template PacketTunnel.xcconfig
cp Screenshots.xcconfig.template Screenshots.xcconfig
cp Api.xcconfig.template Api.xcconfig
sed -i "" "s/MULLVAD_ACCOUNT_TOKEN = /MULLVAD_ACCOUNT_TOKEN = $TEST_ACCOUNT/g" Screenshots.xcconfig
working-directory: ios/Configurations

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ios-screenshots-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
cp App.xcconfig.template App.xcconfig
cp PacketTunnel.xcconfig.template PacketTunnel.xcconfig
cp Screenshots.xcconfig.template Screenshots.xcconfig
cp Api.xcconfig.template Api.xcconfig
sed -i "" "s/MULLVAD_ACCOUNT_TOKEN = /MULLVAD_ACCOUNT_TOKEN = $TEST_ACCOUNT/g" Screenshots.xcconfig
working-directory: ios/Configurations

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: iOS app
on:

Check warning on line 3 in .github/workflows/ios.yml

View workflow job for this annotation

GitHub Actions / check-formatting

3:1 [truthy] truthy value should be one of [false, true]
pull_request:
paths:
- .github/workflows/ios.yml
Expand Down Expand Up @@ -81,6 +81,7 @@
cp App.xcconfig.template App.xcconfig
cp PacketTunnel.xcconfig.template PacketTunnel.xcconfig
cp Screenshots.xcconfig.template Screenshots.xcconfig
cp Api.xcconfig.template Api.xcconfig
working-directory: ios/Configurations

- name: Install xcbeautify
Expand Down
1 change: 1 addition & 0 deletions ios/BuildInstructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ developer portal in the top right corner next to your organization name (upperca
digits).
1. Edit `App.xcconfig` and `PacketTunnel.xcconfig` and supply the names of your provisioning profiles
for development (Debug) and distribution (Release).
1. Edit `Api.xcconfig` to supply the endpoint that will be used to reach the Mullvad API.
1. Edit `Screenshots.xcconfig` and supply the name of your provisioning profile. We only specify
development profile here as we never build UI testing targets for distribution. Skip this step if
you do not intend to generate screenshots for the app.
Expand Down
9 changes: 9 additions & 0 deletions ios/Configurations/Api.xcconfig.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
API_HOST_NAME[config=Debug] = api.mullvad.net
API_HOST_NAME[config=Release] = api.mullvad.net
API_HOST_NAME[config=MockRelease] = api.mullvad.net
API_HOST_NAME[config=Staging] = api.stagemole.eu

API_ENDPOINT[config=Debug] = 45.83.223.196:443
API_ENDPOINT[config=Release] = 45.83.223.196:443
API_ENDPOINT[config=MockRelease] = 45.83.223.196:443
API_ENDPOINT[config=Staging] = 85.203.53.95:443
2 changes: 2 additions & 0 deletions ios/Configurations/App.xcconfig.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
// Provisioning profiles
// Comment out the lines below if using automatic code sign
PROVISIONING_PROFILE_SPECIFIER[config=Debug][sdk=*][arch=*] = Mullvad VPN Development
PROVISIONING_PROFILE_SPECIFIER[config=Staging][sdk=*][arch=*] = Mullvad VPN Development
PROVISIONING_PROFILE_SPECIFIER[config=MockRelease][sdk=*][arch=*] = Mullvad VPN Development
PROVISIONING_PROFILE_SPECIFIER[config=Release][sdk=*][arch=*] = Mullvad VPN Release
9 changes: 9 additions & 0 deletions ios/Configurations/Base.xcconfig.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Version.xcconfig"
#include "Api.xcconfig"

// Development team
DEVELOPMENT_TEAM = CKG9MXH72F
Expand All @@ -15,4 +16,12 @@ CODE_SIGN_STYLE = Manual

// Code signing identity
CODE_SIGN_IDENTITY[config=Debug] = Apple Development
CODE_SIGN_IDENTITY[config=Staging] = Apple Development
CODE_SIGN_IDENTITY[config=MockRelease] = Apple Development
CODE_SIGN_IDENTITY[config=Release] = Apple Distribution

// Flag used to conditionally show features that are in development
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = DEBUG
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Staging] = DEBUG
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=MockRelease] =
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Release] =
3 changes: 3 additions & 0 deletions ios/Configurations/PacketTunnel.xcconfig.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "Base.xcconfig"
#include "Api.xcconfig"

// Provisioning profiles
// Comment out the lines below if using automatic code sign
PROVISIONING_PROFILE_SPECIFIER[config=Debug][sdk=*][arch=*] = Packet Tunnel Development
PROVISIONING_PROFILE_SPECIFIER[config=Staging][sdk=*][arch=*] = Packet Tunnel Development
PROVISIONING_PROFILE_SPECIFIER[config=MockRelease][sdk=*][arch=*] = Packet Tunnel Development
PROVISIONING_PROFILE_SPECIFIER[config=Release][sdk=*][arch=*] = Packet Tunnel Release
2 changes: 2 additions & 0 deletions ios/Configurations/Screenshots.xcconfig.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Provisioning profiles
// Comment out the lines below if using automatic code sign
PROVISIONING_PROFILE_SPECIFIER[config=Debug][sdk=*][arch=*] = Screenshots Development
PROVISIONING_PROFILE_SPECIFIER[config=Staging][sdk=*][arch=*] = Screenshots Development
PROVISIONING_PROFILE_SPECIFIER[config=MockRelease][sdk=*][arch=*] = Screenshots Development

// Mullvad account number used when taking screenshots
MULLVAD_ACCOUNT_TOKEN =
11 changes: 9 additions & 2 deletions ios/MullvadREST/ApiHandlers/RESTDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
import Foundation
import MullvadTypes

// swiftlint:disable force_cast
extension REST {
/// The API hostname and endpoint are defined in the Info.plist of the MullvadREST framework bundle
/// This is due to not being able to target `Bundle.main` from a Unit Test environment as it gets its own bundle that would not contain the above variables.
private static let infoDictionary = Bundle(for: AddressCache.self).infoDictionary!

/// Default API hostname.
public static let defaultAPIHostname = "api.mullvad.net"
public static let defaultAPIHostname = infoDictionary["ApiHostName"] as! String

/// Default API endpoint.
public static let defaultAPIEndpoint = AnyIPEndpoint(string: "45.83.223.196:443")!
public static let defaultAPIEndpoint = AnyIPEndpoint(string: infoDictionary["ApiEndpoint"] as! String)!

/// Disables API IP address cache when in staging environment and sticks to using default API endpoint instead.
public static let isStagingEnvironment = false

/// Default network timeout for API requests.
public static let defaultAPINetworkTimeout: Duration = .seconds(10)
}

// swiftlint:enable force_cast
7 changes: 6 additions & 1 deletion ios/MullvadREST/Info.plist
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?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/>
<dict>
<key>ApiHostName</key>
<string>$(API_HOST_NAME)</string>
<key>ApiEndpoint</key>
<string>$(API_ENDPOINT)</string>
</dict>
</plist>
Loading
Loading