From 4ca99422fcf46a2d6945d7defaf022e0b1ac457e Mon Sep 17 00:00:00 2001 From: Maciek Grzybowski Date: Mon, 29 Mar 2021 19:41:37 +0200 Subject: [PATCH 1/7] Merge pull request #453 from DataDog/ncreated/RUMM-1222-fix-linter-version-on-CI RUMM-1222 Update to swiftlint `0.43.x` --- Sources/Datadog/Datadog.swift | 2 +- .../RUM/RUMMonitor/Scopes/RUMViewScope.swift | 2 +- tools/lint/sources.swiftlint.yml | 20 ++++++++--------- tools/lint/tests.swiftlint.yml | 22 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Sources/Datadog/Datadog.swift b/Sources/Datadog/Datadog.swift index 798e3e57e7..07cac7a165 100644 --- a/Sources/Datadog/Datadog.swift +++ b/Sources/Datadog/Datadog.swift @@ -96,7 +96,7 @@ public class Datadog { /// If set, a debugging outline will be displayed on top of the application, describing the name of the active RUM View. /// May be used to debug issues with RUM instrumentation in your app. /// Default is `false`. - public static var debugRUM: Bool = false { + public static var debugRUM = false { didSet { (Global.rum as? RUMMonitor)?.enableRUMDebugging(debugRUM) } diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift index bd5903764c..e00cc1b2e4 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift @@ -37,7 +37,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { /// Tells if this View is the active one. /// `true` for every new started View. /// `false` if the View was stopped or any other View was started. - private(set) var isActiveView: Bool = true + private(set) var isActiveView = true /// Tells if this scope has received the "start" command. /// If `didReceiveStartCommand == true` and another "start" command is received for this View this scope is marked as inactive. private var didReceiveStartCommand = false diff --git a/tools/lint/sources.swiftlint.yml b/tools/lint/sources.swiftlint.yml index d3b9d34c6d..67ec52dd19 100644 --- a/tools/lint/sources.swiftlint.yml +++ b/tools/lint/sources.swiftlint.yml @@ -1,6 +1,6 @@ # Set of Swift Lint rules enforced for Swift code under `Sources/*` directory -whitelist_rules: # we enable lint rules explicitly - only the ones listed below are active +only_rules: # we enable lint rules explicitly - only the ones listed below are active - attributes - closing_brace - closure_end_indentation @@ -90,12 +90,12 @@ custom_rules: severity: error included: - - Sources - - instrumented-tests/http-server-mock/Sources - - tools/api-surface/Sources - - tools/api-surface/Fixtures/Sources - - tools/rum-models-generator/Sources - - tools/rum-models-generator/Tests/rum-models-generator-coreTests/Fixtures/Output # lint generation fixture - - dependency-manager-tests/carthage/CTProject - - dependency-manager-tests/cocoapods/CPProject - - dependency-manager-tests/spm/SPMProject + - ../../Sources + - ../../instrumented-tests/http-server-mock/Sources + - ../../tools/api-surface/Sources + - ../../tools/api-surface/Fixtures/Sources + - ../../tools/rum-models-generator/Sources + - ../../tools/rum-models-generator/Tests/rum-models-generator-coreTests/Fixtures/Output # lint generation fixture + - ../../dependency-manager-tests/carthage/CTProject + - ../../dependency-manager-tests/cocoapods/CPProject + - ../../dependency-manager-tests/spm/SPMProject diff --git a/tools/lint/tests.swiftlint.yml b/tools/lint/tests.swiftlint.yml index 29e31a2a1f..87d1b09057 100644 --- a/tools/lint/tests.swiftlint.yml +++ b/tools/lint/tests.swiftlint.yml @@ -1,6 +1,6 @@ # Set of Swift Lint rules enforced for Swift code under `Tests/*` directory -whitelist_rules: # we enable lint rules explicitly - only the ones listed below are active +only_rules: # we enable lint rules explicitly - only the ones listed below are active - attributes - closing_brace - closure_end_indentation @@ -75,13 +75,13 @@ custom_rules: severity: error included: - - Tests - - instrumented-tests/http-server-mock/Tests - - tools/api-surface/Tests - - tools/rum-models-generator/Tests - - dependency-manager-tests/carthage/CTProjectTests - - dependency-manager-tests/carthage/CTProjectUITests - - dependency-manager-tests/cocoapods/CTProjectTests - - dependency-manager-tests/cocoapods/CTProjectUITests - - dependency-manager-tests/spm/SPMProjectTests - - dependency-manager-tests/spm/SPMProjectUITests + - ../../Tests + - ../../instrumented-tests/http-server-mock/Tests + - ../../tools/api-surface/Tests + - ../../tools/rum-models-generator/Tests + - ../../dependency-manager-tests/carthage/CTProjectTests + - ../../dependency-manager-tests/carthage/CTProjectUITests + - ../../dependency-manager-tests/cocoapods/CTProjectTests + - ../../dependency-manager-tests/cocoapods/CTProjectUITests + - ../../dependency-manager-tests/spm/SPMProjectTests + - ../../dependency-manager-tests/spm/SPMProjectUITests From d14b458291fd5381d5ce3c4909294d69caccd29d Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Mon, 12 Apr 2021 14:14:33 +0200 Subject: [PATCH 2/7] Merge pull request #454 from DataDog/ncreated/RUMM-1222-enforce-up-to-date-version-of-swiftlint RUMM-1222 Patch configuration for `swiftlint 0.42.0` --- Datadog/Datadog.xcodeproj/project.pbxproj | 38 +++++++++++++++++++++++ Makefile | 10 ++---- bitrise.yml | 7 +++++ tools/lint/patch_if_swiftlint_0.42.0.sh | 19 ++++++++++++ 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100755 tools/lint/patch_if_swiftlint_0.42.0.sh diff --git a/Datadog/Datadog.xcodeproj/project.pbxproj b/Datadog/Datadog.xcodeproj/project.pbxproj index 047074e7ec..44bd67d954 100644 --- a/Datadog/Datadog.xcodeproj/project.pbxproj +++ b/Datadog/Datadog.xcodeproj/project.pbxproj @@ -2743,6 +2743,44 @@ /* Begin PBXShellScriptBuildPhase section */ 61133C772423A4C300786299 /* ⚙️ Run linter */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "⚙️ Run linter"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ \"$CARTHAGE\" == \"YES\" ]; then\n echo \"Skipping linting for carthage build...\"\nelif which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n"; + showEnvVarsInLog = 0; + }; + 6170DC2325C18762003AED5C /* ⚙️ Run linter */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "⚙️ Run linter"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ \"$CARTHAGE\" == \"YES\" ]; then\n echo \"Skipping linting for carthage build...\"\nelif which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n"; + showEnvVarsInLog = 0; + }; + 6170DC2425C18784003AED5C /* ⚙️ Run linter */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( diff --git a/Makefile b/Makefile index 867849c626..53daeabb3c 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,4 @@ -all: tools dependencies xcodeproj-httpservermock templates -.PHONY : tools - -tools: - @echo "⚙️ Installing tools..." - @brew list swiftlint &>/dev/null || brew install swiftlint - @echo "OK 👌" +all: dependencies xcodeproj-httpservermock templates # The release version of `dd-sdk-swift-testing` to use for tests instrumentation. DD_SDK_SWIFT_TESTING_VERSION = 0.6.0 @@ -22,6 +16,8 @@ export DD_SDK_TESTING_XCCONFIG_CI dependencies: @echo "⚙️ Installing dependencies..." + @brew update + @brew list swiftlint &>/dev/null || brew install swiftlint # NOTE: RUMM-1145 Bitrise Stacks don't have carthage v0.37 # despite https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/osx-xcode-12.4.x.log @brew upgrade carthage diff --git a/bitrise.yml b/bitrise.yml index 03b9708cc7..1cd2d8ca6f 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -38,6 +38,13 @@ workflows: description: |- Runs swiftlint and license check for all source and test files. steps: + - script: + title: Patch linter configuration for swiftlint 0.42.0 + inputs: + - content: |- + #!/usr/bin/env bash + set -e + ./tools/lint/patch_if_swiftlint_0.42.0.sh - swiftlint@0.8.0: title: Lint Sources/* inputs: diff --git a/tools/lint/patch_if_swiftlint_0.42.0.sh b/tools/lint/patch_if_swiftlint_0.42.0.sh new file mode 100755 index 0000000000..eace92377f --- /dev/null +++ b/tools/lint/patch_if_swiftlint_0.42.0.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Patches `sources.swiftlint.yml` and `tests.swiftlint.yml` configs for swiftlint `0.42.0`. +# We need to run this patch on Bitrise, as their brew-core mirror doesn't include swiftlint `0.43.1` +# on some agent versions (notably: `Agent version: 1.20.0` considers `0.42.0` as the latest version). +# +# REF: we could eventually switch to the official brew source, but this is discouraged in +# https://discuss.bitrise.io/t/how-to-change-brew-core-from-mirror-to-official/16033 + +SWIFTLINT_VERSION=$(swiftlint version) + +if [ $SWIFTLINT_VERSION = "0.42.0" ]; then + echo "⚙️ Found swiftlint '0.42.0', applying the patch." + # Replace "../../" with "" + sed -i '' 's/..\/..\///g' tools/lint/sources.swiftlint.yml + sed -i '' 's/..\/..\///g' tools/lint/tests.swiftlint.yml +else + echo "⚙️ Using swiftlint '${SWIFTLINT_VERSION}', no need to patch." +fi From 8df6aa8bf9b30d8934bb09663afcda8dba689469 Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Mon, 12 Apr 2021 14:22:24 +0200 Subject: [PATCH 3/7] Merge pull request #451 from DataDog/buranmert/RUMM-1160-support-static-pod RUMM-1160 Static pod support --- Datadog/Datadog.xcodeproj/project.pbxproj | 13 ++----------- Datadog/TargetSupport/Datadog/Datadog.h | 3 ++- DatadogSDK.podspec | 5 ++--- Package.swift | 7 ++++++- Sources/Datadog/Core/Persistence/Files/File.swift | 3 +++ .../Datadog/Core/System/LaunchTimeProvider.swift | 7 +++++-- Sources/Datadog/Tracing/DDSpan.swift | 3 +++ Sources/Datadog/Utils/Globals.swift | 6 +++++- Sources/_Datadog_Private/ObjcAppLaunchHandler.m | 2 +- Sources/_Datadog_Private/ObjcExceptionHandler.m | 2 +- .../_Datadog_Private/include/ObjcAppLaunchHandler.h | 2 +- .../_Datadog_Private/include/ObjcExceptionHandler.h | 2 +- .../Datadog/Mocks/DatadogPrivateMocks.swift | 5 +++-- .../DatadogPrivate/ObjcExceptionHandlerTests.swift | 4 ++-- dependency-manager-tests/cocoapods/Podfile.src | 8 +++++++- 15 files changed, 44 insertions(+), 28 deletions(-) diff --git a/Datadog/Datadog.xcodeproj/project.pbxproj b/Datadog/Datadog.xcodeproj/project.pbxproj index 44bd67d954..7df1b8a49a 100644 --- a/Datadog/Datadog.xcodeproj/project.pbxproj +++ b/Datadog/Datadog.xcodeproj/project.pbxproj @@ -218,7 +218,7 @@ 616CCE16250A467E009FED46 /* RUMAutoInstrumentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 616CCE15250A467E009FED46 /* RUMAutoInstrumentation.swift */; }; 61786F7724FCDE05009E6BAB /* RUMDebuggingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61786F7624FCDE04009E6BAB /* RUMDebuggingTests.swift */; }; 6179FFD3254ADB1700556A0B /* ObjcAppLaunchHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 6179FFD2254ADB1100556A0B /* ObjcAppLaunchHandler.m */; }; - 6179FFDE254ADBEF00556A0B /* ObjcAppLaunchHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 6179FFD1254ADB1100556A0B /* ObjcAppLaunchHandler.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 6179FFDE254ADBEF00556A0B /* ObjcAppLaunchHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 6179FFD1254ADB1100556A0B /* ObjcAppLaunchHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 617B953D24BF4D8F00E6F443 /* RUMMonitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617B953C24BF4D8F00E6F443 /* RUMMonitorTests.swift */; }; 617B954024BF4DB300E6F443 /* RUMApplicationScopeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617B953F24BF4DB300E6F443 /* RUMApplicationScopeTests.swift */; }; 617B954224BF4E7600E6F443 /* RUMMonitorConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617B954124BF4E7600E6F443 /* RUMMonitorConfigurationTests.swift */; }; @@ -385,7 +385,7 @@ 9E58E8E124615C75008E5063 /* JSONEncoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E58E8E024615C75008E5063 /* JSONEncoder.swift */; }; 9E58E8E324615EDA008E5063 /* JSONEncoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E58E8E224615EDA008E5063 /* JSONEncoderTests.swift */; }; 9E68FB55244707FD0013A8AA /* ObjcExceptionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E68FB53244707FD0013A8AA /* ObjcExceptionHandler.m */; }; - 9E68FB56244707FD0013A8AA /* ObjcExceptionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9E68FB54244707FD0013A8AA /* ObjcExceptionHandler.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 9E68FB56244707FD0013A8AA /* ObjcExceptionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9E68FB54244707FD0013A8AA /* ObjcExceptionHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9EEA4871258B76A100EBDA9D /* Global+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEA4870258B76A100EBDA9D /* Global+objc.swift */; }; 9EF963E82537556300235F98 /* DDURLSessionDelegateAsSuperclassTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EF963E72537556300235F98 /* DDURLSessionDelegateAsSuperclassTests.swift */; }; 9EFD112C24B32D29003A1A2B /* FirstPartyURLsFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EFD112B24B32D29003A1A2B /* FirstPartyURLsFilter.swift */; }; @@ -3279,7 +3279,6 @@ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; @@ -3297,7 +3296,6 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -3344,7 +3342,6 @@ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; @@ -3362,7 +3359,6 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -3415,7 +3411,6 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MODULEMAP_FILE = "$(SRCROOT)/../Sources/Datadog/Datadog.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.Datadog; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -3445,7 +3440,6 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MODULEMAP_FILE = "$(SRCROOT)/../Sources/Datadog/Datadog.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.Datadog; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -3745,7 +3739,6 @@ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; @@ -3763,7 +3756,6 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -3817,7 +3809,6 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MODULEMAP_FILE = "$(SRCROOT)/../Sources/Datadog/Datadog.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = com.datadogqh.Datadog; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; diff --git a/Datadog/TargetSupport/Datadog/Datadog.h b/Datadog/TargetSupport/Datadog/Datadog.h index 0653a3453a..84858a999f 100644 --- a/Datadog/TargetSupport/Datadog/Datadog.h +++ b/Datadog/TargetSupport/Datadog/Datadog.h @@ -14,4 +14,5 @@ FOUNDATION_EXPORT const unsigned char DatadogVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import - +#import "ObjcAppLaunchHandler.h" +#import "ObjcExceptionHandler.h" diff --git a/DatadogSDK.podspec b/DatadogSDK.podspec index 85525f3b0a..b444b85b56 100644 --- a/DatadogSDK.podspec +++ b/DatadogSDK.podspec @@ -22,8 +22,7 @@ Pod::Spec.new do |s| s.source_files = ["Sources/Datadog/**/*.swift", "Sources/_Datadog_Private/**/*.{h,m}", "Datadog/TargetSupport/Datadog/Datadog.h"] - s.public_header_files = "Datadog/TargetSupport/Datadog/Datadog.h" - s.private_header_files = "Sources/_Datadog_Private/include/*.h" - s.module_map = "Sources/Datadog/Datadog.modulemap" + s.public_header_files = ["Datadog/TargetSupport/Datadog/Datadog.h", + "Sources/_Datadog_Private/include/*.h"] s.dependency 'Kronos', '~> 4.1' end diff --git a/Package.swift b/Package.swift index 0bad96217a..023ac42130 100644 --- a/Package.swift +++ b/Package.swift @@ -31,7 +31,12 @@ let package = Package( targets: [ .target( name: "Datadog", - dependencies: ["_Datadog_Private", "Kronos"]), + dependencies: [ + "_Datadog_Private", + .product(name: "Kronos", package: "Kronos"), + ], + swiftSettings: [.define("SPM_BUILD")] + ), .target( name: "DatadogObjc", dependencies: ["Datadog"]), diff --git a/Sources/Datadog/Core/Persistence/Files/File.swift b/Sources/Datadog/Core/Persistence/Files/File.swift index bf552529ef..2b1df5d1a7 100644 --- a/Sources/Datadog/Core/Persistence/Files/File.swift +++ b/Sources/Datadog/Core/Persistence/Files/File.swift @@ -5,7 +5,10 @@ */ import Foundation + +#if SPM_BUILD import _Datadog_Private +#endif /// Provides convenient interface for reading metadata and appending data to the file. internal protocol WritableFile { diff --git a/Sources/Datadog/Core/System/LaunchTimeProvider.swift b/Sources/Datadog/Core/System/LaunchTimeProvider.swift index ad36a16338..5e8165ba1d 100644 --- a/Sources/Datadog/Core/System/LaunchTimeProvider.swift +++ b/Sources/Datadog/Core/System/LaunchTimeProvider.swift @@ -5,7 +5,10 @@ */ import UIKit + +#if SPM_BUILD import _Datadog_Private +#endif /// Provides the application launch time. internal protocol LaunchTimeProviderType { @@ -16,9 +19,9 @@ internal protocol LaunchTimeProviderType { internal class LaunchTimeProvider: LaunchTimeProviderType { var launchTime: TimeInterval? { - // Even if AppLaunchTime() is using a lock behind the scenes, TSAN will report a data race if there are no synchronizations at this level. + // Even if __dd_private_AppLaunchTime() is using a lock behind the scenes, TSAN will report a data race if there are no synchronizations at this level. objc_sync_enter(self) - let time = AppLaunchTime() + let time = __dd_private_AppLaunchTime() objc_sync_exit(self) return time > 0 ? time : nil } diff --git a/Sources/Datadog/Tracing/DDSpan.swift b/Sources/Datadog/Tracing/DDSpan.swift index 58209a6fb9..498d2d6b23 100644 --- a/Sources/Datadog/Tracing/DDSpan.swift +++ b/Sources/Datadog/Tracing/DDSpan.swift @@ -5,7 +5,10 @@ */ import Foundation + +#if SPM_BUILD import _Datadog_Private +#endif internal class DDSpan: OTSpan { /// The `Tracer` which created this span. diff --git a/Sources/Datadog/Utils/Globals.swift b/Sources/Datadog/Utils/Globals.swift index a9f1e68bbd..1f6b7e0fd4 100644 --- a/Sources/Datadog/Utils/Globals.swift +++ b/Sources/Datadog/Utils/Globals.swift @@ -4,7 +4,11 @@ * Copyright 2019-2020 Datadog, Inc. */ +import Foundation + +#if SPM_BUILD import _Datadog_Private +#endif /// Function printing `String` content to console. internal var consolePrint: (String) -> Void = { content in @@ -12,4 +16,4 @@ internal var consolePrint: (String) -> Void = { content in } /// Exception handler rethrowing `NSExceptions` to Swift `NSError`. -internal var objcExceptionHandler = ObjcExceptionHandler() +internal var objcExceptionHandler = __dd_private_ObjcExceptionHandler() diff --git a/Sources/_Datadog_Private/ObjcAppLaunchHandler.m b/Sources/_Datadog_Private/ObjcAppLaunchHandler.m index dcd660f076..5656944278 100644 --- a/Sources/_Datadog_Private/ObjcAppLaunchHandler.m +++ b/Sources/_Datadog_Private/ObjcAppLaunchHandler.m @@ -76,7 +76,7 @@ + (void)load { @end -CFTimeInterval AppLaunchTime() { +CFTimeInterval __dd_private_AppLaunchTime() { pthread_rwlock_rdlock(&rwLock); CFTimeInterval time = TimeToApplicationDidBecomeActive; pthread_rwlock_unlock(&rwLock); diff --git a/Sources/_Datadog_Private/ObjcExceptionHandler.m b/Sources/_Datadog_Private/ObjcExceptionHandler.m index 61a0c28ea7..773604b709 100644 --- a/Sources/_Datadog_Private/ObjcExceptionHandler.m +++ b/Sources/_Datadog_Private/ObjcExceptionHandler.m @@ -7,7 +7,7 @@ #import #import "ObjcExceptionHandler.h" -@implementation ObjcExceptionHandler +@implementation __dd_private_ObjcExceptionHandler - (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error { @try { diff --git a/Sources/_Datadog_Private/include/ObjcAppLaunchHandler.h b/Sources/_Datadog_Private/include/ObjcAppLaunchHandler.h index 4de259cecf..0707c114ca 100644 --- a/Sources/_Datadog_Private/include/ObjcAppLaunchHandler.h +++ b/Sources/_Datadog_Private/include/ObjcAppLaunchHandler.h @@ -6,4 +6,4 @@ #import -CFTimeInterval AppLaunchTime(void); +CFTimeInterval __dd_private_AppLaunchTime(void); diff --git a/Sources/_Datadog_Private/include/ObjcExceptionHandler.h b/Sources/_Datadog_Private/include/ObjcExceptionHandler.h index bf5a9e3e75..3417f96d1b 100644 --- a/Sources/_Datadog_Private/include/ObjcExceptionHandler.h +++ b/Sources/_Datadog_Private/include/ObjcExceptionHandler.h @@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface ObjcExceptionHandler : NSObject +@interface __dd_private_ObjcExceptionHandler : NSObject - (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error NS_SWIFT_NAME(rethrowToSwift(tryBlock:)); diff --git a/Tests/DatadogTests/Datadog/Mocks/DatadogPrivateMocks.swift b/Tests/DatadogTests/Datadog/Mocks/DatadogPrivateMocks.swift index 70123a77db..2d07d8810b 100644 --- a/Tests/DatadogTests/Datadog/Mocks/DatadogPrivateMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/DatadogPrivateMocks.swift @@ -4,9 +4,10 @@ * Copyright 2019-2020 Datadog, Inc. */ -import _Datadog_Private +import Foundation +import Datadog -class ObjcExceptionHandlerMock: ObjcExceptionHandler { +class ObjcExceptionHandlerMock: __dd_private_ObjcExceptionHandler { let error: Error init(throwingError: Error) { diff --git a/Tests/DatadogTests/DatadogPrivate/ObjcExceptionHandlerTests.swift b/Tests/DatadogTests/DatadogPrivate/ObjcExceptionHandlerTests.swift index dcbb1cc88b..85add50043 100644 --- a/Tests/DatadogTests/DatadogPrivate/ObjcExceptionHandlerTests.swift +++ b/Tests/DatadogTests/DatadogPrivate/ObjcExceptionHandlerTests.swift @@ -5,10 +5,10 @@ */ import XCTest -import _Datadog_Private +import Datadog class ObjcExceptionHandlerTests: XCTestCase { - private let exceptionHandler = ObjcExceptionHandler() + private let exceptionHandler = __dd_private_ObjcExceptionHandler() func testGivenNonThrowingCode_itDoesNotThrow() throws { var counter = 0 diff --git a/dependency-manager-tests/cocoapods/Podfile.src b/dependency-manager-tests/cocoapods/Podfile.src index 8a40d48027..a4e31649e3 100644 --- a/dependency-manager-tests/cocoapods/Podfile.src +++ b/dependency-manager-tests/cocoapods/Podfile.src @@ -1,8 +1,14 @@ platform :ios, '12.0' target 'CPProject' do - use_frameworks! pod 'DatadogSDK', :git => 'https://github.com/DataDog/dd-sdk-ios.git', :branch => 'REMOTE_GIT_BRANCH' pod 'DatadogSDKAlamofireExtension', :git => 'https://github.com/DataDog/dd-sdk-ios.git', :branch => 'REMOTE_GIT_BRANCH' pod 'Alamofire' + + target 'CPProjectTests' do + inherit! :search_paths + end + target 'CPProjectUITests' do + inherit! :search_paths + end end From a4b099ea07c5960f274942995bf411f993f2039a Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Mon, 12 Apr 2021 14:25:54 +0200 Subject: [PATCH 4/7] Merge pull request #456 from DataDog/xgouchet/RUMM-1213/additional_configuration RUMM-1213 Allow additional configuration when initializing the SDK --- Sources/Datadog/DatadogConfiguration.swift | 12 +++++++++++- Sources/DatadogObjc/DatadogConfiguration+objc.swift | 5 +++++ .../Datadog/DatadogConfigurationBuilderTests.swift | 4 ++++ Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift | 6 ++++-- .../DatadogObjc/DDConfigurationTests.swift | 5 +++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Sources/Datadog/DatadogConfiguration.swift b/Sources/Datadog/DatadogConfiguration.swift index b153a1f251..d659afddcf 100644 --- a/Sources/Datadog/DatadogConfiguration.swift +++ b/Sources/Datadog/DatadogConfiguration.swift @@ -179,6 +179,7 @@ extension Datadog { private(set) var rumErrorEventMapper: RUMErrorEventMapper? private(set) var batchSize: BatchSize private(set) var uploadFrequency: UploadFrequency + private(set) var additionalConfiguration: [String: Any] /// Creates the builder for configuring the SDK to work with RUM, Logging and Tracing features. /// - Parameter rumApplicationID: RUM Application ID obtained on Datadog website. @@ -242,7 +243,8 @@ extension Datadog { rumActionEventMapper: nil, rumErrorEventMapper: nil, batchSize: .medium, - uploadFrequency: .average + uploadFrequency: .average, + additionalConfiguration: [:] ) } @@ -515,6 +517,14 @@ extension Datadog { return self } + /// Sets additional configuration attributes. + /// This can be used to tweak internal features of the SDK. + /// - Parameter additionalConfiguration: `[:]` by default. + public func set(additionalConfiguration: [String: Any]) -> Builder { + configuration.additionalConfiguration = additionalConfiguration + return self + } + /// Builds `Datadog.Configuration` object. public func build() -> Configuration { return configuration diff --git a/Sources/DatadogObjc/DatadogConfiguration+objc.swift b/Sources/DatadogObjc/DatadogConfiguration+objc.swift index 9cb8f426f7..b757685e1b 100644 --- a/Sources/DatadogObjc/DatadogConfiguration+objc.swift +++ b/Sources/DatadogObjc/DatadogConfiguration+objc.swift @@ -272,6 +272,11 @@ public class DDConfigurationBuilder: NSObject { _ = sdkBuilder.set(uploadFrequency: uploadFrequency.swiftType) } + @objc + public func set(additionalConfiguration: [String: Any]) { + _ = sdkBuilder.set(additionalConfiguration: additionalConfiguration) + } + @objc public func build() -> DDConfiguration { return DDConfiguration(sdkConfiguration: sdkBuilder.build()) diff --git a/Tests/DatadogTests/Datadog/DatadogConfigurationBuilderTests.swift b/Tests/DatadogTests/Datadog/DatadogConfigurationBuilderTests.swift index 38ee5737d2..a203c30c5e 100644 --- a/Tests/DatadogTests/Datadog/DatadogConfigurationBuilderTests.swift +++ b/Tests/DatadogTests/Datadog/DatadogConfigurationBuilderTests.swift @@ -51,6 +51,7 @@ class DatadogConfigurationBuilderTests: XCTestCase { XCTAssertNil(configuration.rumErrorEventMapper) XCTAssertEqual(configuration.batchSize, .medium) XCTAssertEqual(configuration.uploadFrequency, .average) + XCTAssertEqual(configuration.additionalConfiguration.count, 0) } } @@ -80,6 +81,7 @@ class DatadogConfigurationBuilderTests: XCTestCase { .setRUMActionEventMapper { _ in mockRUMActionEvent } .set(batchSize: .small) .set(uploadFrequency: .frequent) + .set(additionalConfiguration: ["foo": 42, "bar": "something"]) return builder } @@ -121,6 +123,8 @@ class DatadogConfigurationBuilderTests: XCTestCase { XCTAssertEqual(configuration.rumErrorEventMapper?(.mockRandom()), mockRUMErrorEvent) XCTAssertEqual(configuration.batchSize, .small) XCTAssertEqual(configuration.uploadFrequency, .frequent) + XCTAssertEqual(configuration.additionalConfiguration["foo"] as? Int, 42) + XCTAssertEqual(configuration.additionalConfiguration["bar"] as? String, "something") } XCTAssertTrue(rumConfigurationWithDefaultValues.rumUIKitViewsPredicate is DefaultUIKitRUMViewsPredicate) diff --git a/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift b/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift index 433d1be73d..4c2d4ee8e6 100644 --- a/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift @@ -37,7 +37,8 @@ extension Datadog.Configuration { rumUIKitViewsPredicate: UIKitRUMViewsPredicate? = nil, rumUIKitActionsTrackingEnabled: Bool = false, batchSize: BatchSize = .medium, - uploadFrequency: UploadFrequency = .average + uploadFrequency: UploadFrequency = .average, + additionalConfiguration: [String: Any] = [:] ) -> Datadog.Configuration { return Datadog.Configuration( rumApplicationID: rumApplicationID, @@ -59,7 +60,8 @@ extension Datadog.Configuration { rumUIKitViewsPredicate: rumUIKitViewsPredicate, rumUIKitActionsTrackingEnabled: rumUIKitActionsTrackingEnabled, batchSize: batchSize, - uploadFrequency: uploadFrequency + uploadFrequency: uploadFrequency, + additionalConfiguration: additionalConfiguration ) } } diff --git a/Tests/DatadogTests/DatadogObjc/DDConfigurationTests.swift b/Tests/DatadogTests/DatadogObjc/DDConfigurationTests.swift index ea6f4f288a..e054e9fcef 100644 --- a/Tests/DatadogTests/DatadogObjc/DDConfigurationTests.swift +++ b/Tests/DatadogTests/DatadogObjc/DDConfigurationTests.swift @@ -62,6 +62,7 @@ class DDConfigurationTests: XCTestCase { XCTAssertNil(configuration.rumResourceEventMapper) XCTAssertNil(configuration.rumActionEventMapper) XCTAssertNil(configuration.rumErrorEventMapper) + XCTAssertEqual(configuration.additionalConfiguration.count, 0) } } @@ -146,6 +147,10 @@ class DDConfigurationTests: XCTestCase { objcBuilder.set(uploadFrequency: .rare) XCTAssertEqual(objcBuilder.build().sdkConfiguration.uploadFrequency, .rare) + + objcBuilder.set(additionalConfiguration: ["foo": 42, "bar": "something"]) + XCTAssertEqual(objcBuilder.build().sdkConfiguration.additionalConfiguration["foo"] as? Int, 42) + XCTAssertEqual(objcBuilder.build().sdkConfiguration.additionalConfiguration["bar"] as? String, "something") } func testScrubbingRUMEvents() { From 810f2211ecc65aa6cca61318aec3a4ff5ebdd0d5 Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Mon, 12 Apr 2021 14:31:33 +0200 Subject: [PATCH 5/7] Merge pull request #459 from DataDog/xgouchet/RUMM-1038/update_source RUMM-1038 add option to customize the `source` tag --- Sources/Datadog/Core/FeaturesConfiguration.swift | 6 +++++- Sources/Datadog/Core/Upload/DataUploader.swift | 4 ++-- Sources/Datadog/Logging/LoggingFeature.swift | 2 +- Sources/Datadog/RUM/RUMFeature.swift | 2 +- Sources/Datadog/Tracer.swift | 3 ++- Sources/Datadog/Tracing/Span/SpanBuilder.swift | 3 +++ Sources/Datadog/Tracing/Span/SpanEncoder.swift | 3 ++- .../DataStorage/TracingStorageBenchmarkTests.swift | 1 + .../Datadog/Core/Upload/DataUploaderTests.swift | 10 +++++----- .../Datadog/Logging/LoggingFeatureTests.swift | 5 +++-- Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift | 6 ++++-- .../Datadog/Mocks/TracingFeatureMocks.swift | 8 ++++++-- Tests/DatadogTests/Datadog/RUM/RUMFeatureTests.swift | 5 +++-- Tests/DatadogTests/Datadog/TracerTests.swift | 5 +++-- 14 files changed, 41 insertions(+), 22 deletions(-) diff --git a/Sources/Datadog/Core/FeaturesConfiguration.swift b/Sources/Datadog/Core/FeaturesConfiguration.swift index fb04fda659..4a0ab1be05 100644 --- a/Sources/Datadog/Core/FeaturesConfiguration.swift +++ b/Sources/Datadog/Core/FeaturesConfiguration.swift @@ -18,6 +18,7 @@ internal struct FeaturesConfiguration { let serviceName: String let environment: String let performance: PerformancePreset + let source: String } struct Logging { @@ -87,6 +88,8 @@ extension FeaturesConfiguration { var tracesEndpoint = configuration.tracesEndpoint var rumEndpoint = configuration.rumEndpoint + let source = (configuration.additionalConfiguration["_dd.source"] as? String) ?? Datadog.Constants.ddsource + if let datadogEndpoint = configuration.datadogEndpoint { // If `.set(endpoint:)` API was used, it should override the values // set by deprecated `.set(Endpoint:)` APIs. @@ -120,7 +123,8 @@ extension FeaturesConfiguration { batchSize: configuration.batchSize, uploadFrequency: configuration.uploadFrequency, bundleType: appContext.bundleType - ) + ), + source: source ) if configuration.loggingEnabled { diff --git a/Sources/Datadog/Core/Upload/DataUploader.swift b/Sources/Datadog/Core/Upload/DataUploader.swift index b01d5cc43f..2bf49bb655 100644 --- a/Sources/Datadog/Core/Upload/DataUploader.swift +++ b/Sources/Datadog/Core/Upload/DataUploader.swift @@ -15,8 +15,8 @@ internal class UploadURLProvider { let value: () -> URLQueryItem /// Creates `ddsource=ios` query item. - static func ddsource() -> QueryItemProvider { - let queryItem = URLQueryItem(name: "ddsource", value: Datadog.Constants.ddsource) + static func ddsource(source: String) -> QueryItemProvider { + let queryItem = URLQueryItem(name: "ddsource", value: source) return QueryItemProvider { queryItem } } diff --git a/Sources/Datadog/Logging/LoggingFeature.swift b/Sources/Datadog/Logging/LoggingFeature.swift index 63be0f8c6e..9bbd01d8e1 100644 --- a/Sources/Datadog/Logging/LoggingFeature.swift +++ b/Sources/Datadog/Logging/LoggingFeature.swift @@ -80,7 +80,7 @@ internal final class LoggingFeature { uploadURLProvider: UploadURLProvider( urlWithClientToken: configuration.uploadURLWithClientToken, queryItemProviders: [ - .ddsource() + .ddsource(source: configuration.common.source) ] ), commonDependencies: commonDependencies diff --git a/Sources/Datadog/RUM/RUMFeature.swift b/Sources/Datadog/RUM/RUMFeature.swift index 862fc954e5..5852e630cc 100644 --- a/Sources/Datadog/RUM/RUMFeature.swift +++ b/Sources/Datadog/RUM/RUMFeature.swift @@ -85,7 +85,7 @@ internal final class RUMFeature { uploadURLProvider: UploadURLProvider( urlWithClientToken: configuration.uploadURLWithClientToken, queryItemProviders: [ - .ddsource(), + .ddsource(source: configuration.common.source), .ddtags( tags: [ "service:\(configuration.common.serviceName)", diff --git a/Sources/Datadog/Tracer.swift b/Sources/Datadog/Tracer.swift index 697b63e0f2..af0bd2f9c1 100644 --- a/Sources/Datadog/Tracer.swift +++ b/Sources/Datadog/Tracer.swift @@ -100,7 +100,8 @@ public class Tracer: OTTracer { userInfoProvider: tracingFeature.userInfoProvider, networkConnectionInfoProvider: tracerConfiguration.sendNetworkInfo ? tracingFeature.networkConnectionInfoProvider : nil, carrierInfoProvider: tracerConfiguration.sendNetworkInfo ? tracingFeature.carrierInfoProvider : nil, - dateCorrector: tracingFeature.dateCorrector + dateCorrector: tracingFeature.dateCorrector, + source: tracingFeature.configuration.common.source ), fileWriter: tracingFeature.storage.writer ), diff --git a/Sources/Datadog/Tracing/Span/SpanBuilder.swift b/Sources/Datadog/Tracing/Span/SpanBuilder.swift index 5f044e3d91..85c0e7ef5a 100644 --- a/Sources/Datadog/Tracing/Span/SpanBuilder.swift +++ b/Sources/Datadog/Tracing/Span/SpanBuilder.swift @@ -22,6 +22,8 @@ internal struct SpanBuilder { let carrierInfoProvider: CarrierInfoProviderType? /// Adjusts span's time (device time) to server time. let dateCorrector: DateCorrectorType + /// source tag to encode in span. + let source: String /// Encodes tag `Span` tag values as JSON string private let tagsJSONEncoder: JSONEncoder = .default() @@ -60,6 +62,7 @@ internal struct SpanBuilder { startTime: dateCorrector.currentCorrection.applying(to: ddspan.startTime), duration: finishTime.timeIntervalSince(ddspan.startTime), isError: tagsReducer.extractedIsError ?? false, + source: source, tracerVersion: sdkVersion, applicationVersion: applicationVersion, networkConnectionInfo: networkConnectionInfoProvider?.current, diff --git a/Sources/Datadog/Tracing/Span/SpanEncoder.swift b/Sources/Datadog/Tracing/Span/SpanEncoder.swift index 110b84c4aa..d083d90023 100644 --- a/Sources/Datadog/Tracing/Span/SpanEncoder.swift +++ b/Sources/Datadog/Tracing/Span/SpanEncoder.swift @@ -41,6 +41,7 @@ internal struct Span: Encodable { let startTime: Date let duration: TimeInterval let isError: Bool + let source: String // MARK: - Meta @@ -159,7 +160,7 @@ internal struct SpanEncoder { /// Encodes default `meta.*` attributes private func encodeDefaultMeta(_ span: Span, to container: inout KeyedEncodingContainer) throws { // NOTE: RUMM-299 only string values are supported for `meta.*` attributes - try container.encode(Datadog.Constants.ddsource, forKey: .source) + try container.encode(span.source, forKey: .source) try container.encode(span.tracerVersion, forKey: .tracerVersion) try container.encode(span.applicationVersion, forKey: .applicationVersion) diff --git a/Tests/DatadogBenchmarkTests/DataStorage/TracingStorageBenchmarkTests.swift b/Tests/DatadogBenchmarkTests/DataStorage/TracingStorageBenchmarkTests.swift index 592b3bb4f5..762d0dc0c8 100644 --- a/Tests/DatadogBenchmarkTests/DataStorage/TracingStorageBenchmarkTests.swift +++ b/Tests/DatadogBenchmarkTests/DataStorage/TracingStorageBenchmarkTests.swift @@ -87,6 +87,7 @@ class TracingStorageBenchmarkTests: XCTestCase { startTime: Date(), duration: Double.random(in: 0.0..<1.0), isError: false, + source: "ios", tracerVersion: "0.0.0", applicationVersion: "0.0.0", networkConnectionInfo: NetworkConnectionInfo( diff --git a/Tests/DatadogTests/Datadog/Core/Upload/DataUploaderTests.swift b/Tests/DatadogTests/Datadog/Core/Upload/DataUploaderTests.swift index fdb0a3627d..f94013db85 100644 --- a/Tests/DatadogTests/Datadog/Core/Upload/DataUploaderTests.swift +++ b/Tests/DatadogTests/Datadog/Core/Upload/DataUploaderTests.swift @@ -9,10 +9,10 @@ import XCTest class DataUploadURLProviderTests: XCTestCase { func testDDSourceQueryItem() { - let item: UploadURLProvider.QueryItemProvider = .ddsource() + let item: UploadURLProvider.QueryItemProvider = .ddsource(source: "abc") XCTAssertEqual(item.value().name, "ddsource") - XCTAssertEqual(item.value().value, "ios") + XCTAssertEqual(item.value().value, "abc") } func testItBuildsValidURLUsingNoQueryItems() throws { @@ -27,11 +27,11 @@ class DataUploadURLProviderTests: XCTestCase { func testItBuildsValidURLUsingAllQueryItems() throws { let urlProvider = UploadURLProvider( urlWithClientToken: URL(string: "https://api.example.com/v1/endpoint/abc")!, - queryItemProviders: [.ddsource(), .ddtags(tags: ["abc:def"])] + queryItemProviders: [.ddsource(source: "abc"), .ddtags(tags: ["abc:def"])] ) - XCTAssertEqual(urlProvider.url, URL(string: "https://api.example.com/v1/endpoint/abc?ddsource=ios&ddtags=abc:def")) - XCTAssertEqual(urlProvider.url, URL(string: "https://api.example.com/v1/endpoint/abc?ddsource=ios&ddtags=abc:def")) + XCTAssertEqual(urlProvider.url, URL(string: "https://api.example.com/v1/endpoint/abc?ddsource=abc&ddtags=abc:def")) + XCTAssertEqual(urlProvider.url, URL(string: "https://api.example.com/v1/endpoint/abc?ddsource=abc&ddtags=abc:def")) } func testItEscapesWhitespacesInQueryItems() throws { diff --git a/Tests/DatadogTests/Datadog/Logging/LoggingFeatureTests.swift b/Tests/DatadogTests/Datadog/Logging/LoggingFeatureTests.swift index 90547c2b58..edfa5f24a1 100644 --- a/Tests/DatadogTests/Datadog/Logging/LoggingFeatureTests.swift +++ b/Tests/DatadogTests/Datadog/Logging/LoggingFeatureTests.swift @@ -31,7 +31,8 @@ class LoggingFeatureTests: XCTestCase { configuration: .mockWith( common: .mockWith( applicationName: "FoobarApp", - applicationVersion: "2.1.0" + applicationVersion: "2.1.0", + source: "abc" ) ), dependencies: .mockWith( @@ -45,7 +46,7 @@ class LoggingFeatureTests: XCTestCase { let request = server.waitAndReturnRequests(count: 1)[0] XCTAssertEqual(request.httpMethod, "POST") - XCTAssertEqual(request.url?.query, "ddsource=ios") + XCTAssertEqual(request.url?.query, "ddsource=abc") XCTAssertEqual(request.allHTTPHeaderFields?["User-Agent"], "FoobarApp/2.1.0 CFNetwork (iPhone; iOS/13.3.1)") XCTAssertEqual(request.allHTTPHeaderFields?["Content-Type"], "application/json") } diff --git a/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift b/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift index 4c2d4ee8e6..b1d5987278 100644 --- a/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/CoreMocks.swift @@ -143,7 +143,8 @@ extension FeaturesConfiguration.Common { applicationBundleIdentifier: String = .mockAny(), serviceName: String = .mockAny(), environment: String = .mockAny(), - performance: PerformancePreset = .init(batchSize: .medium, uploadFrequency: .average, bundleType: .iOSApp) + performance: PerformancePreset = .init(batchSize: .medium, uploadFrequency: .average, bundleType: .iOSApp), + source: String = .mockAny() ) -> Self { return .init( applicationName: applicationName, @@ -151,7 +152,8 @@ extension FeaturesConfiguration.Common { applicationBundleIdentifier: applicationBundleIdentifier, serviceName: serviceName, environment: environment, - performance: performance + performance: performance, + source: source ) } } diff --git a/Tests/DatadogTests/Datadog/Mocks/TracingFeatureMocks.swift b/Tests/DatadogTests/Datadog/Mocks/TracingFeatureMocks.swift index 8ab08a4545..d8d09484f7 100644 --- a/Tests/DatadogTests/Datadog/Mocks/TracingFeatureMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/TracingFeatureMocks.swift @@ -175,6 +175,7 @@ extension Span { startTime: Date = .mockAny(), duration: TimeInterval = .mockAny(), isError: Bool = .mockAny(), + source: String = .mockAny(), tracerVersion: String = .mockAny(), applicationVersion: String = .mockAny(), networkConnectionInfo: NetworkConnectionInfo? = .mockAny(), @@ -192,6 +193,7 @@ extension Span { startTime: startTime, duration: duration, isError: isError, + source: source, tracerVersion: tracerVersion, applicationVersion: applicationVersion, networkConnectionInfo: networkConnectionInfo, @@ -258,7 +260,8 @@ extension SpanBuilder { userInfoProvider: UserInfoProvider = .mockAny(), networkConnectionInfoProvider: NetworkConnectionInfoProviderType = NetworkConnectionInfoProviderMock.mockAny(), carrierInfoProvider: CarrierInfoProviderType = CarrierInfoProviderMock.mockAny(), - dateCorrector: DateCorrectorType = DateCorrectorMock() + dateCorrector: DateCorrectorType = DateCorrectorMock(), + source: String = .mockAny() ) -> SpanBuilder { return SpanBuilder( applicationVersion: applicationVersion, @@ -267,7 +270,8 @@ extension SpanBuilder { userInfoProvider: userInfoProvider, networkConnectionInfoProvider: networkConnectionInfoProvider, carrierInfoProvider: carrierInfoProvider, - dateCorrector: dateCorrector + dateCorrector: dateCorrector, + source: source ) } } diff --git a/Tests/DatadogTests/Datadog/RUM/RUMFeatureTests.swift b/Tests/DatadogTests/Datadog/RUM/RUMFeatureTests.swift index 6ce67e76e8..03cad05bbf 100644 --- a/Tests/DatadogTests/Datadog/RUM/RUMFeatureTests.swift +++ b/Tests/DatadogTests/Datadog/RUM/RUMFeatureTests.swift @@ -33,7 +33,8 @@ class RUMFeatureTests: XCTestCase { applicationName: "FoobarApp", applicationVersion: "2.1.0", serviceName: "service-name", - environment: "environment-name" + environment: "environment-name", + source: "abc" ) ), dependencies: .mockWith( @@ -52,7 +53,7 @@ class RUMFeatureTests: XCTestCase { XCTAssertEqual( request.url?.query, """ - ddsource=ios&ddtags=service:service-name,version:2.1.0,sdk_version:\(sdkVersion),env:environment-name + ddsource=abc&ddtags=service:service-name,version:2.1.0,sdk_version:\(sdkVersion),env:environment-name """ ) XCTAssertEqual(request.allHTTPHeaderFields?["User-Agent"], "FoobarApp/2.1.0 CFNetwork (iPhone; iOS/13.3.1)") diff --git a/Tests/DatadogTests/Datadog/TracerTests.swift b/Tests/DatadogTests/Datadog/TracerTests.swift index bb3e35eef1..ed7c524f99 100644 --- a/Tests/DatadogTests/Datadog/TracerTests.swift +++ b/Tests/DatadogTests/Datadog/TracerTests.swift @@ -33,7 +33,8 @@ class TracerTests: XCTestCase { applicationVersion: "1.0.0", applicationBundleIdentifier: "com.datadoghq.ios-sdk", serviceName: "default-service-name", - environment: "custom" + environment: "custom", + source: "abc" ) ), dependencies: .mockWith( @@ -65,7 +66,7 @@ class TracerTests: XCTestCase { "type": "custom", "meta.tracer.version": "\(sdkVersion)", "meta.version": "1.0.0", - "meta._dd.source": "ios", + "meta._dd.source": "abc", "metrics._top_level": 1, "metrics._sampling_priority_v1": 1 } From 8c7952b344dbe189f6c54d184d381aa1e940198e Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Mon, 12 Apr 2021 14:38:52 +0200 Subject: [PATCH 6/7] Bumped version to 1.5.2 --- CHANGELOG.md | 9 +++++++++ DatadogSDK.podspec | 2 +- DatadogSDKAlamofireExtension.podspec | 2 +- DatadogSDKObjc.podspec | 4 ++-- Sources/Datadog/Versioning.swift | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25ecbbc87b..76a3146ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.5.2 / 04-12-2021 + +### Changes + +* [BUGFIX] Static pod support for cocoapods. See [#451][] +* [BUGFIX] Swiftlint won't run for carthage builds. See [#450][] + # 1.5.1 / 03-11-2021 ### Changes @@ -158,6 +165,8 @@ [#381]: https://github.com/DataDog/dd-sdk-ios/issues/381 [#390]: https://github.com/DataDog/dd-sdk-ios/issues/390 [#439]: https://github.com/DataDog/dd-sdk-ios/pull/439 +[#450]: https://github.com/DataDog/dd-sdk-ios/pull/450 +[#451]: https://github.com/DataDog/dd-sdk-ios/pull/451 [@00FA9A]: https://github.com/00FA9A [@Britton-Earnin]: https://github.com/Britton-Earnin [@Hengyu]: https://github.com/Hengyu diff --git a/DatadogSDK.podspec b/DatadogSDK.podspec index b444b85b56..4158731ac6 100644 --- a/DatadogSDK.podspec +++ b/DatadogSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "DatadogSDK" s.module_name = "Datadog" - s.version = "1.5.1" + s.version = "1.5.2" s.summary = "Official Datadog Swift SDK for iOS." s.homepage = "https://www.datadoghq.com" diff --git a/DatadogSDKAlamofireExtension.podspec b/DatadogSDKAlamofireExtension.podspec index 161784ebb3..e8828befc6 100644 --- a/DatadogSDKAlamofireExtension.podspec +++ b/DatadogSDKAlamofireExtension.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "DatadogSDKAlamofireExtension" s.module_name = "DatadogAlamofireExtension" - s.version = "1.5.1" + s.version = "1.5.2" s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire." s.homepage = "https://www.datadoghq.com" diff --git a/DatadogSDKObjc.podspec b/DatadogSDKObjc.podspec index d57e79bfc0..748be8573d 100644 --- a/DatadogSDKObjc.podspec +++ b/DatadogSDKObjc.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "DatadogSDKObjc" s.module_name = "DatadogObjc" - s.version = "1.5.1" + s.version = "1.5.2" s.summary = "Official Datadog Objective-C SDK for iOS." s.homepage = "https://www.datadoghq.com" @@ -20,5 +20,5 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/DataDog/dd-sdk-ios.git', :tag => s.version.to_s } s.source_files = "Sources/DatadogObjc/**/*.swift" - s.dependency 'DatadogSDK', '1.5.1' + s.dependency 'DatadogSDK', '1.5.2' end diff --git a/Sources/Datadog/Versioning.swift b/Sources/Datadog/Versioning.swift index 4116501608..136cdbc612 100644 --- a/Sources/Datadog/Versioning.swift +++ b/Sources/Datadog/Versioning.swift @@ -1,3 +1,3 @@ // GENERATED FILE: Do not edit directly -internal let sdkVersion = "1.5.1" +internal let sdkVersion = "1.5.2" From 213b3a50367c42e5962e63a9f676a534b1d4dfb1 Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Mon, 12 Apr 2021 15:09:57 +0200 Subject: [PATCH 7/7] Temporary fix CI brew fails with 404 responses --- Makefile | 28 +------------------ .../Datadog/Utils/CompilationConditions.swift | 4 +-- bitrise.yml | 2 +- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 53daeabb3c..76469aa6f0 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,11 @@ all: dependencies xcodeproj-httpservermock templates -# The release version of `dd-sdk-swift-testing` to use for tests instrumentation. -DD_SDK_SWIFT_TESTING_VERSION = 0.6.0 - -define DD_SDK_TESTING_XCCONFIG_CI -FRAMEWORK_SEARCH_PATHS=$$(inherited) $$(SRCROOT)/../instrumented-tests/DatadogSDKTesting.xcframework/ios-arm64_x86_64-simulator/\n -LD_RUNPATH_SEARCH_PATHS=$$(inherited) $$(SRCROOT)/../instrumented-tests/DatadogSDKTesting.xcframework/ios-arm64_x86_64-simulator/\n -OTHER_LDFLAGS=$$(inherited) -framework DatadogSDKTesting\n -DD_TEST_RUNNER=1\n -DD_SDK_SWIFT_TESTING_SERVICE=dd-sdk-ios\n -DD_SDK_SWIFT_TESTING_CLIENT_TOKEN=${DD_SDK_SWIFT_TESTING_CLIENT_TOKEN}\n -DD_SDK_SWIFT_TESTING_ENV=ci\n -endef -export DD_SDK_TESTING_XCCONFIG_CI - dependencies: @echo "⚙️ Installing dependencies..." - @brew update - @brew list swiftlint &>/dev/null || brew install swiftlint # NOTE: RUMM-1145 Bitrise Stacks don't have carthage v0.37 # despite https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/osx-xcode-12.4.x.log - @brew upgrade carthage @carthage bootstrap --platform iOS --use-xcframeworks -ifeq (${ci}, true) - @echo $$DD_SDK_TESTING_XCCONFIG_CI > xcconfigs/DatadogSDKTesting.local.xcconfig; - @brew list gh &>/dev/null || brew install gh - @rm -rf instrumented-tests/DatadogSDKTesting.xcframework - @rm -rf instrumented-tests/DatadogSDKTesting.zip - @rm -rf instrumented-tests/LICENSE - @gh release download ${DD_SDK_SWIFT_TESTING_VERSION} -D instrumented-tests -R https://github.com/DataDog/dd-sdk-swift-testing -p "DatadogSDKTesting.zip" - @unzip instrumented-tests/DatadogSDKTesting.zip -d instrumented-tests - @[ -e "instrumented-tests/DatadogSDKTesting.xcframework" ] && echo "DatadogSDKTesting.xcframework - OK" || { echo "DatadogSDKTesting.xcframework - missing"; exit 1; } -endif + @echo "" > xcconfigs/DatadogSDKTesting.local.xcconfig; xcodeproj-httpservermock: @echo "⚙️ Generating 'HTTPServerMock.xcodeproj'..." diff --git a/Sources/Datadog/Utils/CompilationConditions.swift b/Sources/Datadog/Utils/CompilationConditions.swift index d253ae7bc8..51a45ec77f 100644 --- a/Sources/Datadog/Utils/CompilationConditions.swift +++ b/Sources/Datadog/Utils/CompilationConditions.swift @@ -10,9 +10,9 @@ import Foundation internal struct CompilationConditions { #if DD_SDK_DEVELOPMENT /// `true` if `DD_SDK_DEVELOPMENT` flag is set. - static var isSDKCompiledForDevelopment: Bool = true + static var isSDKCompiledForDevelopment = true #else /// `false` if `DD_SDK_DEVELOPMENT` flag is not set. - static var isSDKCompiledForDevelopment: Bool = false + static var isSDKCompiledForDevelopment = false #endif } diff --git a/bitrise.yml b/bitrise.yml index 1cd2d8ca6f..5f6490ebdb 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -10,7 +10,7 @@ workflows: push_to_any_branch: after_run: - _make_dependencies - - run_linter + # - run_linter - run_unit_tests - run_integration_tests - check_dependency_managers