Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SPM support #283

Merged
merged 9 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,25 @@ jobs:
name: CocoaPods
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Lint
run: pod lib lint
carthage:
name: Carthage
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Update
run: carthage update --no-use-binaries --no-build
- name: Build
run: carthage build --no-skip-current
SPM-Build:
runs-on: macos-latest
env:
DEVELOPER_DIR: /Applications/Xcode_12_beta.app/Contents/Developer
3a4oT marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Verify that PINCache can be build by SPM
run: xcrun swift build
3a4oT marked this conversation as resolved.
Show resolved Hide resolved
47 changes: 47 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "PINCache",
platforms: [
.macOS(.v10_10),
.iOS(.v9),
.watchOS(.v2),
.tvOS(.v9)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "PINCache",
targets: ["PINCache"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "[email protected]:pinterest/PINOperation.git", .branch("master")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "PINCache",
dependencies: ["PINOperation"],
path: "Source",
exclude: ["Carthage", "docs",
"build_docs.sh", "Cartfile",
"Cartfile.resolved", "Makefile",
"PINCache.podspec", "Info.plist"],
publicHeadersPath: "."),
.testTarget(
name: "PINCacheTests",
dependencies: ["PINCache"],
path: "Tests",
exclude: ["Info.plist"],
resources: [.process("[email protected]")],
cSettings: [
.define("TEST_AS_SPM"),
]),
]
)
8 changes: 4 additions & 4 deletions Source/PINCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#import <Foundation/Foundation.h>

#import <PINCache/PINCacheMacros.h>
#import <PINCache/PINCaching.h>
#import <PINCache/PINDiskCache.h>
#import <PINCache/PINMemoryCache.h>
#import "PINCacheMacros.h"
#import "PINCaching.h"
#import "PINDiskCache.h"
#import "PINMemoryCache.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion Source/PINCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#import "PINCache.h"

#import <PINOperation/PINOperation.h>
@import PINOperation;

static NSString * const PINCachePrefix = @"com.pinterest.PINCache";
static NSString * const PINCacheSharedName = @"PINCacheShared";
Expand Down
6 changes: 3 additions & 3 deletions Source/PINDiskCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#import <Foundation/Foundation.h>

#import <PINCache/PINCacheMacros.h>
#import <PINCache/PINCaching.h>
#import <PINCache/PINCacheObjectSubscripting.h>
#import "PINCacheMacros.h"
#import "PINCaching.h"
#import "PINCacheObjectSubscripting.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion Source/PINDiskCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import <pthread.h>
#import <sys/xattr.h>

#import <PINOperation/PINOperation.h>
@import PINOperation;

#define PINDiskCacheError(error) if (error) { NSLog(@"%@ (%d) ERROR: %@", \
[[NSString stringWithUTF8String:__FILE__] lastPathComponent], \
Expand Down
6 changes: 3 additions & 3 deletions Source/PINMemoryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#import <Foundation/Foundation.h>

#import <PINCache/PINCacheMacros.h>
#import <PINCache/PINCaching.h>
#import <PINCache/PINCacheObjectSubscripting.h>
#import "PINCacheMacros.h"
#import "PINCaching.h"
#import "PINCacheObjectSubscripting.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion Source/PINMemoryCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#import "PINMemoryCache.h"

#import <pthread.h>
#import <PINOperation/PINOperation.h>
@import PINOperation;

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0
#import <UIKit/UIKit.h>
Expand Down
13 changes: 10 additions & 3 deletions Tests/PINCacheTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// Modifications by Garrett Moon
// Copyright (c) 2015 Pinterest. All rights reserved.

@import PINCache;
@import PINOperation;

#import "PINCacheTests.h"
#import "NSDate+PINCacheTests.h"
#import "PINDiskCache+PINCacheTests.h"
#import <PINCache/PINCache.h>
#import <PINOperation/PINOperation.h>


#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
Expand Down Expand Up @@ -79,8 +80,14 @@ - (PINImage *)image
static PINImage *image = nil;

if (!image) {
#ifdef TEST_AS_SPM
NSBundle *bun = [NSBundle bundleWithURL:[[NSBundle bundleForClass:self.class] URLForResource:@"PINCache_PINCacheTests" withExtension:@"bundle"]];
#else
NSBundle *bun = [NSBundle bundleForClass:self.class];

#endif
NSURL *imageURL = [bun URLForResource:@"Default-568h@2x" withExtension:@"png"];
NSError *error = nil;
NSURL *imageURL = [[NSBundle bundleForClass:self.class] URLForResource:@"Default-568h@2x" withExtension:@"png"];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL
options:NSDataReadingUncached
error:&error];
Expand Down
2 changes: 1 addition & 1 deletion Tests/PINDiskCache+PINCacheTests.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import <PINCache/PINCache.h>
#import "PINCache.h"

@interface PINDiskCache (PINCacheTests)

Expand Down
2 changes: 1 addition & 1 deletion Tests/PINDiskCache+PINCacheTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ @implementation PINDiskCache (PINCacheTests)
- (void)setTtlCacheSync:(BOOL)ttlCache
{
[self lock];
self->_ttlCache = ttlCache;
[self setValue:@(ttlCache) forKey:@"_ttlCache"];
3a4oT marked this conversation as resolved.
Show resolved Hide resolved
[self unlock];
}

Expand Down