Skip to content

Commit

Permalink
Move the bundle information to a place accessible from both executabl…
Browse files Browse the repository at this point in the history
…es and the test environment
  • Loading branch information
buggmagnet committed Jan 15, 2024
1 parent 479a4aa commit 247c543
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 6 additions & 2 deletions ios/MullvadREST/ApiHandlers/RESTDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ 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 = Bundle.main.infoDictionary!["ApiHostName"] as! String
public static let defaultAPIHostname = infoDictionary["ApiHostName"] as! String

/// Default API endpoint.
public static let defaultAPIEndpoint = AnyIPEndpoint(string: Bundle.main.infoDictionary!["ApiEndpoint"] as! String)!
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
Expand Down
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>
4 changes: 0 additions & 4 deletions ios/MullvadVPN/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ApiHostName</key>
<string>$(API_HOST_NAME)</string>
<key>ApiEndpoint</key>
<string>$(API_ENDPOINT)</string>
<key>ApplicationSecurityGroupIdentifier</key>
<string>$(SECURITY_GROUP_IDENTIFIER)</string>
<key>MainApplicationIdentifier</key>
Expand Down
4 changes: 0 additions & 4 deletions ios/PacketTunnel/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ApiHostName</key>
<string>$(API_HOST_NAME)</string>
<key>ApiEndpoint</key>
<string>$(API_ENDPOINT)</string>
<key>ApplicationSecurityGroupIdentifier</key>
<string>$(SECURITY_GROUP_IDENTIFIER)</string>
<key>MainApplicationIdentifier</key>
Expand Down

0 comments on commit 247c543

Please sign in to comment.