Skip to content

Commit

Permalink
Add a staging configuration that automatically targets the staging en…
Browse files Browse the repository at this point in the history
…vironment
  • Loading branch information
buggmagnet committed Jan 15, 2024
1 parent 6bc4b86 commit fb4cfb3
Show file tree
Hide file tree
Showing 17 changed files with 1,217 additions and 94 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ios-screenshots-creation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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-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
Expand Up @@ -81,6 +81,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
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
3 changes: 3 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,6 @@ 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
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
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

0 comments on commit fb4cfb3

Please sign in to comment.