Skip to content

Commit

Permalink
add swift package, and remove OBJC code in Swift files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui Sabran committed Jul 9, 2020
1 parent ab3aefa commit a7a8cdf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 75 deletions.
15 changes: 0 additions & 15 deletions Mixpanel/ExceptionWrapper.h

This file was deleted.

25 changes: 0 additions & 25 deletions Mixpanel/ExceptionWrapper.m

This file was deleted.

18 changes: 0 additions & 18 deletions Mixpanel/Mixpanel.h

This file was deleted.

24 changes: 7 additions & 17 deletions Mixpanel/Persistence.swift
Expand Up @@ -159,15 +159,10 @@ class Persistence {
return
}

ExceptionWrapper.try({ [cObject = archiveObject, cPath = path, cType = type] in
if !NSKeyedArchiver.archiveRootObject(cObject, toFile: cPath) {
Logger.error(message: "failed to archive \(cType.rawValue)")
return
}
}, catch: { [cType = type] (error) in
Logger.error(message: "failed to archive \(cType.rawValue) due to an uncaught exception")
if !NSKeyedArchiver.archiveRootObject(archiveObject, toFile: path) {
Logger.error(message: "failed to archive \(type.rawValue)")
return
}, finally: {})
}

addSkipBackupAttributeToItem(at: path)
}
Expand Down Expand Up @@ -283,16 +278,11 @@ class Persistence {

static private func unarchiveWithFilePath(_ filePath: String) -> Any? {
var unarchivedData: Any? = nil
ExceptionWrapper.try({ [filePath] in
unarchivedData = NSKeyedUnarchiver.unarchiveObject(withFile: filePath)
if unarchivedData == nil {
Logger.info(message: "Unable to read file at path: \(filePath)")
removeArchivedFile(atPath: filePath)
}
}, catch: { [filePath] (error) in
unarchivedData = NSKeyedUnarchiver.unarchiveObject(withFile: filePath)
if unarchivedData == nil {
Logger.info(message: "Unable to read file at path: \(filePath)")
removeArchivedFile(atPath: filePath)
Logger.info(message: "Unable to read file at path: \(filePath), error: \(String(describing: error))")
}, finally: {})
}
return unarchivedData
}

Expand Down
32 changes: 32 additions & 0 deletions Package.swift
@@ -0,0 +1,32 @@
// 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: "Mixpanel",
platforms: [
.iOS(.v8),
.tvOS(.v9),
.macOS(.v10_10),
.watchOS(.v3),
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Mixpanel",
targets: ["Mixpanel"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
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 which this package depends on.
.target(
name: "Mixpanel",
dependencies: [],
path: "Mixpanel"),
]
)

0 comments on commit a7a8cdf

Please sign in to comment.