Skip to content

Commit 08f33ad

Browse files
authored
Add files via upload
Uploading AutomaticLinkConditioner project for iOS Xcode 11
1 parent f6fef95 commit 08f33ad

23 files changed

Lines changed: 1341 additions & 0 deletions

File tree

HowtousetheNetworkLinkConditionerinXcode11/AutomaticLinkConditioner/AutomaticLinkConditioner.xcodeproj/project.pbxproj

Lines changed: 554 additions & 0 deletions
Large diffs are not rendered by default.

HowtousetheNetworkLinkConditionerinXcode11/AutomaticLinkConditioner/AutomaticLinkConditioner.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1100"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "30243A1F22AD768E0076CF79"
18+
BuildableName = "AutomaticLinkConditioner.app"
19+
BlueprintName = "AutomaticLinkConditioner"
20+
ReferencedContainer = "container:AutomaticLinkConditioner.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "30243A3522AD76920076CF79"
36+
BuildableName = "AutomaticLinkConditionerTests.xctest"
37+
BlueprintName = "AutomaticLinkConditionerTests"
38+
ReferencedContainer = "container:AutomaticLinkConditioner.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
</TestAction>
43+
<LaunchAction
44+
buildConfiguration = "Debug"
45+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
46+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47+
enableAddressSanitizer = "YES"
48+
launchStyle = "0"
49+
useCustomWorkingDirectory = "NO"
50+
ignoresPersistentStateOnLaunch = "NO"
51+
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
53+
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "30243A1F22AD768E0076CF79"
59+
BuildableName = "AutomaticLinkConditioner.app"
60+
BlueprintName = "AutomaticLinkConditioner"
61+
ReferencedContainer = "container:AutomaticLinkConditioner.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
64+
<EnvironmentVariables>
65+
<EnvironmentVariable
66+
key = "OS_ACTIVITY_MODE"
67+
value = "enable"
68+
isEnabled = "YES">
69+
</EnvironmentVariable>
70+
<EnvironmentVariable
71+
key = "CFNETWORK_DIAGNOSTICS"
72+
value = "3"
73+
isEnabled = "YES">
74+
</EnvironmentVariable>
75+
</EnvironmentVariables>
76+
</LaunchAction>
77+
<ProfileAction
78+
buildConfiguration = "Release"
79+
shouldUseLaunchSchemeArgsEnv = "YES"
80+
savedToolIdentifier = ""
81+
useCustomWorkingDirectory = "NO"
82+
debugDocumentVersioning = "YES">
83+
<BuildableProductRunnable
84+
runnableDebuggingMode = "0">
85+
<BuildableReference
86+
BuildableIdentifier = "primary"
87+
BlueprintIdentifier = "30243A1F22AD768E0076CF79"
88+
BuildableName = "AutomaticLinkConditioner.app"
89+
BlueprintName = "AutomaticLinkConditioner"
90+
ReferencedContainer = "container:AutomaticLinkConditioner.xcodeproj">
91+
</BuildableReference>
92+
</BuildableProductRunnable>
93+
</ProfileAction>
94+
<AnalyzeAction
95+
buildConfiguration = "Debug">
96+
</AnalyzeAction>
97+
<ArchiveAction
98+
buildConfiguration = "Release"
99+
revealArchiveInOrganizer = "YES">
100+
</ArchiveAction>
101+
</Scheme>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>AutomaticLinkConditioner.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
<key>SuppressBuildableAutocreation</key>
14+
<dict>
15+
<key>30243A1F22AD768E0076CF79</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
20+
<key>30243A3522AD76920076CF79</key>
21+
<dict>
22+
<key>primary</key>
23+
<true/>
24+
</dict>
25+
</dict>
26+
</dict>
27+
</plist>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// AppDelegate.swift
3+
// AutomaticLinkConditioner
4+
//
5+
// Created by Matt Eaton on 6/9/19.
6+
// Copyright © 2019 Matt Eaton. All rights reserved.
7+
//
8+
9+
import UIKit
10+
//import NetworkSniffer
11+
12+
//setenv("CFNETWORK_DIAGNOSTICS", "3", 1)
13+
14+
//@UIApplicationMain
15+
class AppDelegate: UIResponder, UIApplicationDelegate {
16+
17+
18+
19+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
20+
// Override point for customization after application launch.
21+
22+
return true
23+
}
24+
25+
func applicationWillTerminate(_ application: UIApplication) {
26+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
27+
}
28+
29+
// MARK: UISceneSession Lifecycle
30+
31+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
32+
// Called when a new scene session is being created.
33+
// Use this method to select a configuration to create the new scene with.
34+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
35+
}
36+
37+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
38+
// Called when the user discards a scene session.
39+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
40+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
41+
}
42+
43+
44+
}
45+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.cs.debugger</key>
8+
<true/>
9+
<key>com.apple.security.network.client</key>
10+
<true/>
11+
<key>com.apple.security.network.server</key>
12+
<true/>
13+
</dict>
14+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// NetworkManager+Requests.swift
3+
// AutomaticLinkConditioner
4+
//
5+
// Created by Matt Eaton on 6/10/19.
6+
// Copyright © 2019 Matt Eaton. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
12+
extension NetworkManager {
13+
14+
// Utility method to respond on the main thread usign the NetworkDelegate
15+
// Normally passing in a closure here would work too.
16+
func respondToMainThread(response: String) {
17+
DispatchQueue.main.async {
18+
self.networkDelegate?.networkTimeElapsed(response: response)
19+
}
20+
}
21+
22+
func getRequest() {
23+
24+
guard let getURL = URL(string: getSampleURL) else {
25+
return
26+
}
27+
28+
var getRequest = URLRequest(url: getURL)
29+
getRequest.httpMethod = "GET"
30+
31+
// Set the URLSession configuration
32+
let urlSession = URLSession(configuration: urlConfiguration)
33+
34+
let dateStart = Date()
35+
print("Request Started: \(dateStart)")
36+
// Send the GET dataTask here
37+
let getRequestTask = urlSession.dataTask(with: getRequest, completionHandler: { (data, response, error) in
38+
39+
guard let httpResponse = response as? HTTPURLResponse else {
40+
self.respondToMainThread(response: "Malformed HTTPURLResponse Failure - Error: \(String(describing: error?.localizedDescription))")
41+
return
42+
}
43+
44+
let timeSinceNow = dateStart.timeIntervalSinceNow
45+
let timeElapsed = String(format: "Request Time: %.4f - Status: \(httpResponse.statusCode)", (abs(timeSinceNow)))
46+
47+
// Ensure that an error is not present, otherwise, return the error along with the message
48+
if let unwrappedError = error {
49+
self.respondToMainThread(response: "\(timeElapsed) - Error: \(String(describing: unwrappedError.localizedDescription))")
50+
return
51+
}
52+
53+
// Fall through and respond with a successful response.
54+
self.respondToMainThread(response: timeElapsed)
55+
56+
})
57+
getRequestTask.resume()
58+
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// NetworkManager.swift
3+
// AutomaticLinkConditioner
4+
//
5+
// Created by Matt Eaton on 6/9/19.
6+
// Copyright © 2019 Matt Eaton. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
import Foundation
12+
13+
14+
// NetworkManager class to make the network request.
15+
class NetworkManager: NSObject {
16+
17+
18+
//
19+
// MARK: - Static Class Constants
20+
//
21+
static let shared = NetworkManager()
22+
23+
//
24+
// MARK: - Public instance properties
25+
//
26+
public weak var networkDelegate: NetworkProtocol?
27+
28+
//
29+
// MARK: - Public constants
30+
//
31+
public let urlConfiguration = URLSessionConfiguration.default
32+
public let getSampleURL = "https://api.nasa.gov/planetary/apod?api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo"
33+
34+
private override init() {
35+
urlConfiguration.timeoutIntervalForRequest = 15.0
36+
urlConfiguration.timeoutIntervalForResource = 15.0
37+
}
38+
39+
}

0 commit comments

Comments
 (0)