Skip to content

Commit

Permalink
Merge pull request #31 from swiftty/spm
Browse files Browse the repository at this point in the history
Support Swift Package Manager
  • Loading branch information
gabriel authored Jul 10, 2021
2 parents 9bd6e63 + 641df63 commit b4a8d81
Show file tree
Hide file tree
Showing 37 changed files with 315 additions and 158 deletions.
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,17 @@ Pods
Cartfile.resolved
Carthage
build

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
.swiftpm

.build/
8 changes: 5 additions & 3 deletions MPMessagePack.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ Pod::Spec.new do |s|
s.dependency "GHODictionary"

s.ios.deployment_target = "6.0"
s.ios.source_files = "MPMessagePack/**/*.{c,h,m}", "RPC/**/*.{c,h,m}"
s.ios.source_files = "MPMessagePack/**/*.{c,h,m}"
s.ios.exclude_files = "MPMessagePack/XPC/**/*.{c,h,m}", "MPMessagePack/include/XPC/**/*.{c,h,m}"

s.tvos.deployment_target = "10.0"
s.tvos.source_files = "MPMessagePack/**/*.{c,h,m}", "RPC/**/*.{c,h,m}"
s.tvos.source_files = "MPMessagePack/**/*.{c,h,m}"
s.tvos.exclude_files = "MPMessagePack/XPC/**/*.{c,h,m}", "MPMessagePack/include/XPC/**/*.{c,h,m}"

s.osx.deployment_target = "10.8"
s.osx.source_files = "MPMessagePack/**/*.{c,h,m}", "RPC/**/*.{c,h,m}", "XPC/**/*.{c,h,m}"
s.osx.source_files = "MPMessagePack/**/*.{c,h,m}"

end
325 changes: 177 additions & 148 deletions MPMessagePack.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions MPMessagePack/MPMessagePackReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#include "cmp.h"
#import "MPDefines.h"

#if SWIFT_PACKAGE
@import GHODictionary;
#else
#import <GHODictionary/GHODictionary.h>
#endif

@interface MPMessagePackReader ()
@property NSData *data;
Expand Down
5 changes: 5 additions & 0 deletions MPMessagePack/MPMessagePackWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

#include "cmp.h"

#if SWIFT_PACKAGE
@import GHODictionary;
#else
#import <GHODictionary/GHODictionary.h>
#endif

#import "MPDefines.h"

@interface MPMessagePackWriter ()
Expand Down
4 changes: 4 additions & 0 deletions MPMessagePack/NSData+MPMessagePack.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

#import "NSData+MPMessagePack.h"

#if SWIFT_PACKAGE
@import GHODictionary;
#else
#import <GHODictionary/GHODictionary.h>
#endif

@implementation NSData (MPMessagePack)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "MPMessagePackClient.h"

#import "MPMessagePack.h"
#import "MPRequestor.h"
#import "MPDispatchRequest.h"
#include <sys/socket.h>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions XPC/MPXPCClient.m → MPMessagePack/XPC/MPXPCClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MPXPCClient.h"
#import "MPXDefines.h"

#if ENABLE_XPC_SUPPORT

#import "MPDefines.h"
#import "NSArray+MPMessagePack.h"
Expand Down Expand Up @@ -187,3 +190,5 @@ - (void)_sendRequest:(NSString *)method params:(NSArray *)params attempt:(NSInte
}

@end

#endif
5 changes: 5 additions & 0 deletions XPC/MPXPCProtocol.m → MPMessagePack/XPC/MPXPCProtocol.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MPXPCProtocol.h"
#import "MPXDefines.h"

#if ENABLE_XPC_SUPPORT

#import "NSArray+MPMessagePack.h"
#import "NSData+MPMessagePack.h"
Expand Down Expand Up @@ -55,3 +58,5 @@ + (void)requestFromXPCObject:(xpc_object_t)event completion:(void (^)(NSError *e
}

@end

#endif
5 changes: 5 additions & 0 deletions XPC/MPXPCService.m → MPMessagePack/XPC/MPXPCService.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import "MPXPCService.h"
#import "MPXDefines.h"

#if ENABLE_XPC_SUPPORT

#import "NSData+MPMessagePack.h"
#import "NSArray+MPMessagePack.h"
Expand Down Expand Up @@ -181,3 +184,5 @@ - (BOOL)checkCodeRequirement:(NSString *)codeRequirement pid:(pid_t)pid error:(N
}

@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2014 Gabriel Handford. All rights reserved.
//

#import <Foundation/Foundation.h>

#undef MPDebug
#define MPDebug(fmt, ...) do {} while(0)
#undef MPErr
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import <Foundation/Foundation.h>

#import "MPMessagePack.h"
#import "MPMessagePackClient.h"

@interface MPMessagePackServer : NSObject <MPMessagePackClientDelegate>
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions MPMessagePack/include/XPC/MPXDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// MPXDefines.h
// MPMessagePack
//
// Copyright (c) 2014 Gabriel Handford. All rights reserved.
//

#import <Foundation/Foundation.h>

#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED
#define ENABLE_XPC_SUPPORT 1
#else
#define ENABLE_XPC_SUPPORT 0
#endif
5 changes: 5 additions & 0 deletions XPC/MPXPCClient.h → MPMessagePack/include/XPC/MPXPCClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import <Foundation/Foundation.h>
#import "MPXDefines.h"

#if ENABLE_XPC_SUPPORT

#import "MPMessagePackReader.h"
#import "MPLog.h"
Expand All @@ -31,3 +34,5 @@
- (void)close;

@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import <Foundation/Foundation.h>
#import "MPXDefines.h"

#if ENABLE_XPC_SUPPORT
#import <xpc/xpc.h>

typedef NS_ENUM(NSInteger, MPXPCErrorCode) {
Expand All @@ -25,3 +28,5 @@ typedef NS_ENUM(NSInteger, MPXPCErrorCode) {
+ (void)requestFromXPCObject:(xpc_object_t)event completion:(void (^)(NSError *error, NSNumber *messageId, NSString *method, NSArray *params))completion;

@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//

#import <Foundation/Foundation.h>
#import "MPXDefines.h"

#if ENABLE_XPC_SUPPORT
#import <ServiceManagement/ServiceManagement.h>
#import <xpc/xpc.h>

Expand All @@ -20,3 +23,5 @@
- (void)handleRequestWithMethod:(NSString *)method params:(NSArray *)params messageId:(NSNumber *)messageId remote:(xpc_connection_t)remote completion:(void (^)(NSError *error, id value))completion;

@end

#endif
File renamed without changes.
4 changes: 2 additions & 2 deletions MPMessagePackTests/MPMessagePackClientTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <XCTest/XCTestCase.h>

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

@interface MPMessagePackClientTest : XCTestCase
@property MPMessagePackClient *client;
Expand Down Expand Up @@ -151,4 +151,4 @@ - (void)testClientServer {
// [self waitForExpectationsWithTimeout:1.0 handler:nil];
//}

@end
@end
2 changes: 1 addition & 1 deletion MPMessagePackTests/MPMessagePackTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>

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

@interface MPMessagePackTest : XCTestCase
@end
Expand Down
2 changes: 1 addition & 1 deletion MPMessagePackTests/MPRPCProtocolTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>

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

@interface MPRPCProtocolTest : XCTestCase
@end
Expand Down
5 changes: 4 additions & 1 deletion MPMessagePackTests/MPXPCTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>

#import <MPMessagePack/MPMessagePack.h>
#ifdef __MAC_OS_X_VERSION_MAX_ALLOWED

@import MPMessagePack;

@interface MPXPCTest : XCTestCase
@end
Expand Down Expand Up @@ -58,3 +60,4 @@ - (void)testInvalidConnection {

@end

#endif
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "GHODictionary",
"repositoryURL": "https://github.com/gabriel/GHODictionary",
"state": {
"branch": "master",
"revision": "a67b9df6dfc6e6af3910d104fd9900e15dc15de9",
"version": null
}
}
]
},
"version": 1
}
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.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "MPMessagePack",
platforms: [
.iOS(.v8), .tvOS(.v10), .macOS(.v10_10)
],
products: [
.library(
name: "MPMessagePack",
targets: ["MPMessagePack"]),
],
dependencies: [
.package(url: "https://github.com/gabriel/GHODictionary", .branch("master"))
],
targets: [
.target(
name: "MPMessagePack",
dependencies: ["GHODictionary"],
path: "MPMessagePack",
exclude: ["MPMessagePack.h"],
cSettings: [
.headerSearchPath("include"),
.headerSearchPath("include/RPC"),
.headerSearchPath("include/XPC"),
]),
.testTarget(
name: "MPMessagePackTests",
dependencies: ["MPMessagePack"],
path: "MPMessagePackTests",
exclude: ["Info.plist"]),
]
)

0 comments on commit b4a8d81

Please sign in to comment.