Skip to content

Commit

Permalink
Merge pull request #451 from DataDog/buranmert/RUMM-1160-support-stat…
Browse files Browse the repository at this point in the history
…ic-pod

RUMM-1160 Static pod support
  • Loading branch information
buranmert authored Apr 9, 2021
2 parents b927435 + 768e5a2 commit af85391
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 28 deletions.
13 changes: 2 additions & 11 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
617247B825DAB0E2007085B3 /* PLCrashReportFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617247B725DAB0E2007085B3 /* PLCrashReportFormatter.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 */; };
Expand Down Expand Up @@ -430,7 +430,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, ); }; };
9E989A4225F640D100235FC3 /* AppStateListenerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E989A4125F640D100235FC3 /* AppStateListenerTests.swift */; };
9ED6A6B425F2901800CB2E29 /* AppStateListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ED6A6B325F2901800CB2E29 /* AppStateListener.swift */; };
9EEA4871258B76A100EBDA9D /* Global+objc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEA4870258B76A100EBDA9D /* Global+objc.swift */; };
Expand Down Expand Up @@ -3768,7 +3768,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;
Expand All @@ -3786,7 +3785,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;
Expand Down Expand Up @@ -3833,7 +3831,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;
Expand All @@ -3851,7 +3848,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;
Expand Down Expand Up @@ -3904,7 +3900,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;
Expand Down Expand Up @@ -3934,7 +3929,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;
Expand Down Expand Up @@ -4378,7 +4372,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;
Expand All @@ -4396,7 +4389,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;
Expand Down Expand Up @@ -4450,7 +4442,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;
Expand Down
3 changes: 2 additions & 1 deletion Datadog/TargetSupport/Datadog/Datadog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Datadog/PublicHeader.h>


#import "ObjcAppLaunchHandler.h"
#import "ObjcExceptionHandler.h"
6 changes: 3 additions & 3 deletions DatadogSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ 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.2'
end
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ let package = Package(
dependencies: [
"_Datadog_Private",
.product(name: "Kronos", package: "Kronos"),
]
],
swiftSettings: [.define("SPM_BUILD")]
),
.target(
name: "DatadogObjc",
Expand Down
3 changes: 3 additions & 0 deletions Sources/Datadog/Core/Persistence/Files/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions Sources/Datadog/Core/System/LaunchTimeProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import UIKit

#if SPM_BUILD
import _Datadog_Private
#endif

/// Provides the application launch time.
internal protocol LaunchTimeProviderType {
Expand All @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/Datadog/Tracing/DDSpan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import Foundation

#if SPM_BUILD
import _Datadog_Private
#endif

internal class DDSpan: OTSpan {
/// The `Tracer` which created this span.
Expand Down
6 changes: 5 additions & 1 deletion Sources/Datadog/Utils/Globals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
* 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
print(content)
}

/// Exception handler rethrowing `NSExceptions` to Swift `NSError`.
internal var objcExceptionHandler = ObjcExceptionHandler()
internal var objcExceptionHandler = __dd_private_ObjcExceptionHandler()
2 changes: 1 addition & 1 deletion Sources/_Datadog_Private/ObjcAppLaunchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ + (void)load {

@end

CFTimeInterval AppLaunchTime() {
CFTimeInterval __dd_private_AppLaunchTime() {
pthread_rwlock_rdlock(&rwLock);
CFTimeInterval time = TimeToApplicationDidBecomeActive;
pthread_rwlock_unlock(&rwLock);
Expand Down
2 changes: 1 addition & 1 deletion Sources/_Datadog_Private/ObjcExceptionHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#import <Foundation/Foundation.h>
#import "ObjcExceptionHandler.h"

@implementation ObjcExceptionHandler
@implementation __dd_private_ObjcExceptionHandler

- (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error {
@try {
Expand Down
2 changes: 1 addition & 1 deletion Sources/_Datadog_Private/include/ObjcAppLaunchHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

#import <CoreFoundation/CFDate.h>

CFTimeInterval AppLaunchTime(void);
CFTimeInterval __dd_private_AppLaunchTime(void);
2 changes: 1 addition & 1 deletion Sources/_Datadog_Private/include/ObjcExceptionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:));
Expand Down
5 changes: 3 additions & 2 deletions Tests/DatadogTests/Datadog/Mocks/DatadogPrivateMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion dependency-manager-tests/cocoapods/Podfile.src
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit af85391

Please sign in to comment.