Skip to content
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
2 changes: 1 addition & 1 deletion Examples/apps/ObjCExample/ObjCExample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
SEGConfiguration *config = [[SEGConfiguration alloc] initWithWriteKey:@"WRITE_KEY"];
config.trackApplicationLifecycleEvents = TRUE;
config.trackApplicationLifecycleEvents = YES;

SEGAnalytics *analytics = [[SEGAnalytics alloc] initWithConfiguration: config];

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let package = Package(
.package(
name: "Sovran",
url: "https://github.com/segmentio/Sovran-Swift.git",
from: "1.0.1"
from: "1.0.2"
)
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion Segment.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@
repositoryURL = "[email protected]:segmentio/Sovran-Swift.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
minimumVersion = 1.0.2;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Sources/Segment/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ extension Analytics {
}

internal func checkSettings() {
#if DEBUG
if isUnitTesting {
// we don't really wanna wait for this network call during tests...
// but we should make it work similarly.
Expand All @@ -116,6 +117,7 @@ extension Analytics {
}
return
}
#endif

let writeKey = self.configuration.values.writeKey
let httpClient = HTTPClient(analytics: self, cdnHost: configuration.values.cdnHost)
Expand Down
34 changes: 24 additions & 10 deletions Sources/Segment/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@

import Foundation

/// Inquire as to whether we are within a Unit Testing environment.
#if DEBUG
internal var isUnitTesting: Bool = {
let env = ProcessInfo.processInfo.environment
let value = (env["XCTestConfigurationFilePath"] != nil)
return value
// this will work on apple platforms, but fail on linux.
if NSClassFromString("XCTestCase") != nil {
return true
}
// this will work on linux and apple platforms, but not in anything with a UI
// because XCTest doesn't come into the call stack till much later.
let matches = Thread.callStackSymbols.filter { line in
return line.contains("XCTest") || line.contains("xctest")
}
if matches.count > 0 {
return true
}
// this will work on CircleCI to correctly detect test running.
if ProcessInfo.processInfo.environment["CIRCLE_WORKFLOW_WORKSPACE_ID"] != nil {
return true
}
// couldn't see anything that indicated we were testing.
return false
}()
#endif

internal var isAppExtension: Bool = {
if Bundle.main.bundlePath.hasSuffix(".appex") {
Expand All @@ -21,11 +39,7 @@ internal var isAppExtension: Bool = {
}()

internal func exceptionFailure(_ message: String) {
if isUnitTesting {
assertionFailure(message)
} else {
#if DEBUG
assertionFailure(message)
#endif
}
#if DEBUG
assertionFailure(message)
#endif
}