Skip to content

Commit

Permalink
Add support for CoreAardvark in SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Oct 4, 2024
1 parent 491d57c commit ded8c2a
Show file tree
Hide file tree
Showing 26 changed files with 109 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ profile
*.moved-aside
DerivedData
.idea/
# SPM
.build/
4 changes: 2 additions & 2 deletions CoreAardvark.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '14.0'
s.watchos.deployment_target = '7.0'

s.source_files = 'Sources/CoreAardvark/**/*.{h,m,swift}'
s.private_header_files = 'Sources/CoreAardvark/**/*_Testing.h', 'Sources/CoreAardvark/PrivateCategories/*.h'
s.source_files = 'Sources/CoreAardvark/**/*.{h,m}', 'Sources/CoreAardvarkSwift/**/*.{swift}'
s.private_header_files = 'Sources/CoreAardvark/private/*.h'
end
36 changes: 36 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// swift-tools-version:5.10

import PackageDescription

let package = Package(
name: "Aardvark",
defaultLocalization: "en",
platforms: [
.iOS(.v14),
],
products: [
.library(
name: "CoreAardvark",
targets: ["CoreAardvark", "CoreAardvarkSwift"]
),
],
targets: [
.target(
name: "CoreAardvark",
resources: [
.process("Resources/en.lproj"),
],
cSettings: [
.define("SWIFT_PACKAGE"),
.headerSearchPath("private"),
]
),
.target(
name: "CoreAardvarkSwift",
dependencies: ["CoreAardvark"],
cSettings: [
.define("SWIFT_PACKAGE"),
]
),
]
)
18 changes: 11 additions & 7 deletions Sources/CoreAardvark/Logging/ARKLogMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
#import "ARKLogMessage.h"
#else
#import <CoreAardvark/ARKLogMessage.h>
#endif

#import "AardvarkDefines.h"

Expand Down Expand Up @@ -46,14 +50,14 @@ - (instancetype)initWithText:(NSString *)text image:(UIImage *)image type:(ARKLo
- (instancetype)initWithText:(NSString *)text image:(UIImage *)image type:(ARKLogType)type parameters:(NSDictionary *)parameters userInfo:(NSDictionary *)userInfo date:(nonnull NSDate *)date;
{
self = [super init];

_text = [text copy];
_image = image;
_type = type;
_parameters = [parameters copy] ?: @{};
_userInfo = [userInfo copy] ?: @{};
_date = date;

return self;
}

Expand All @@ -69,7 +73,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder;
NSDate *const date = [([aDecoder decodeObjectOfClass:[NSDate class] forKey:ARKSelfKeyPath(date)] ?: [aDecoder decodeObjectOfClass:[NSDate class] forKey:ARKSelfKeyPath(creationDate)]) copy];
#pragma clang diagnostic pop
NSDictionary<NSString *, NSString*> *const parameters = [aDecoder decodeObjectOfClass:[NSDictionary class] forKey:ARKSelfKeyPath(parameters)];

return [self initWithText:text image:image type:type parameters:parameters userInfo:nil date:date];
}

Expand Down Expand Up @@ -97,16 +101,16 @@ - (BOOL)isEqual:(id)object;
if (![self isMemberOfClass:[object class]]) {
return NO;
}

ARKLogMessage *otherMessage = (ARKLogMessage *)object;
if (!(self.text == otherMessage.text || [self.text isEqualToString:otherMessage.text])) {
return NO;
}

if (!(self.image == otherMessage.image || [self.image isEqual:otherMessage.image])) {
return NO;
}

if (self.type != otherMessage.type) {
return NO;
}
Expand All @@ -118,7 +122,7 @@ - (BOOL)isEqual:(id)object;
if (![self.parameters isEqualToDictionary:otherMessage.parameters]) {
return NO;
}

return YES;
}

Expand Down
4 changes: 4 additions & 0 deletions Sources/CoreAardvark/Logging/ARKLogging.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
#import "ARKLogging.h"
#else
#import <CoreAardvark/ARKLogging.h>
#endif

#import "ARKLogDistributor.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@import Foundation;

#if SWIFT_PACKAGE
#import "ARKLogFormatter.h"
#else
#import <CoreAardvark/ARKLogFormatter.h>
#endif


@interface ARKDefaultLogFormatter : NSObject <ARKLogFormatter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@import UIKit;

#if SWIFT_PACKAGE
#import "ARKLogTypes.h"
#else
#import <CoreAardvark/ARKLogTypes.h>
#endif


@protocol ARKLogObserver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@import UIKit;

#if SWIFT_PACKAGE
#import "ARKLogTypes.h"
#else
#import <CoreAardvark/ARKLogTypes.h>
#endif


@interface ARKLogMessage : NSObject <NSCopying, NSSecureCoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
#import "ARKLogObserver.h"
#else
#import <CoreAardvark/ARKLogObserver.h>
#endif


/// Stores log messages locally for use in bug reports. All methods and properties on this class are threadsafe.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
// limitations under the License.
//

#if SWIFT_PACKAGE
#import "ARKLogTypes.h"
#else
#import <CoreAardvark/ARKLogTypes.h>
#endif


/// Logs a log with default type to the default log distributor.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ FOUNDATION_EXPORT double CoreAardvark_iOSVersionNumber;
//! Project version string for CoreAardvark-iOS.
FOUNDATION_EXPORT const unsigned char CoreAardvark_iOSVersionString[];


#if SWIFT_PACKAGE
#import "AardvarkDefines.h"
#import "ARKDataArchive.h"
#import "ARKDefaultLogFormatter.h"
#import "ARKLogDistributor.h"
#import "ARKLogging.h"
#import "ARKLogFormatter.h"
#import "ARKLogMessage.h"
#import "ARKLogObserver.h"
#import "ARKLogStore.h"
#import "ARKLogTypes.h"
#import "ARKExceptionLogging.h"
#else
#import <CoreAardvark/AardvarkDefines.h>
#import <CoreAardvark/ARKDataArchive.h>
#import <CoreAardvark/ARKDefaultLogFormatter.h>
Expand All @@ -35,3 +47,4 @@ FOUNDATION_EXPORT const unsigned char CoreAardvark_iOSVersionString[];
#import <CoreAardvark/ARKLogStore.h>
#import <CoreAardvark/ARKLogTypes.h>
#import <CoreAardvark/ARKExceptionLogging.h>
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@import Foundation;

#if SWIFT_PACKAGE
#import "ARKDataArchive.h"
#else
#import <CoreAardvark/ARKDataArchive.h>
#endif


@interface ARKDataArchive (Private)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@import Foundation;

#if SWIFT_PACKAGE
#import "ARKLogDistributor.h"
#else
#import <CoreAardvark/ARKLogDistributor.h>
#endif


@interface ARKLogDistributor (Protected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@import Foundation;

#if SWIFT_PACKAGE
#import "ARKLogDistributor.h"
#else
#import <CoreAardvark/ARKLogDistributor.h>
#endif


@interface ARKLogDistributor (Private)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

import Foundation

#if SWIFT_PACKAGE
import CoreAardvark
#endif

extension ARKLogDistributor {

/// Creates a log message and distributes it to the log observers. This is a convenience wrapper for Swift usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

import Foundation

#if SWIFT_PACKAGE
import CoreAardvark
#endif

/// Logs a new messages to the default Aardvark log distributor.
///
/// - parameter text: The text of the log message.
Expand Down

0 comments on commit ded8c2a

Please sign in to comment.