Skip to content

Instantly share code, notes, and snippets.

View samdods's full-sized avatar

Sam Dods samdods

  • The App Business
  • London
View GitHub Profile
/// Use this method to inject the configuration for this framework.
public func setup(with config: AnalyticsConfig.Type) {
ConfigType.shared = ConfigType(config)
}
var Config: ConfigType { // swiftlint:disable:this variable_name
if let config = ConfigType.shared {
return config
} else {
fatalError("Please set the Config for \(Bundle(for: ConfigType.self))")
}
}
extension Config: AnalyticsConfig, HomeConfig, BrowseConfig, SearchConfig {
static let appVersion = valueFromInfoPlist(forKey: "CFBundleShortVersionString")
}
Analytics.setup(with: Config.self)
Home.setup(with: Config.self)
Browse.setup(with: Config.self)
Search.setup(with: Config.self)
extension Config: AnalyticsConfig, HomeConfig, BrowseConfig, SearchConfig {
static let appVersion = valueFromInfoPlist(forKey: "CFBundleShortVersionString")
static let buildVersion = valueFromInfoPlist(forKey: "CFBundleVersion")
}
/// performs one time setup activities before running tests. Used as the Principal class in the test target's info.plist
class TestInitializer: NSObject {
override init() {
Analytics.setup(with: MockConfig.self)
}
}
private class MockConfig: AnalyticsConfig {
static let appVersion = "1.0"
static let buildVersion = "1234"
//
// Config.swift
// Analytics
//
public protocol AnalyticsConfig {
static var analyticsKey: String { get }
static var appVersion: String { get }
}
<FileRef
location = “group:Common/Common.xcodeproj”>
</FileRef>
<FileRef
location = “group:FunkySocial/FunkySocial.xcodeproj”>
</FileRef>
<FileRef
location = “group:FunkySocial/FunkySocial.xcodeproj”>
</FileRef>
<FileRef
location = “group:Common/Common.xcodeproj”>
</FileRef>
<Workspace
version = "1.0">
<FileRef
location = “group:FunkySocial/FunkySocial.xcodeproj”>
</FileRef>
<Group
location = “container:”
name = “Features”>
<FileRef
location = “group:NewsFeed/NewsFeed.xcodeproj”>