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

Swift3.0 #7

Merged
merged 3 commits into from Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions UTIKit.xcodeproj/project.pbxproj
Expand Up @@ -202,17 +202,19 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = cockscomb.info;
TargetAttributes = {
09F886601A98D47E00ADF55F = {
CreatedOnToolsVersion = 6.1.1;
};
09FD213A1A962FC00071BF6B = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0800;
};
09FD21451A962FC00071BF6B = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -339,6 +341,7 @@
PRODUCT_NAME = UTIKit;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
Expand Down Expand Up @@ -366,6 +369,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -412,6 +416,7 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand Down Expand Up @@ -445,6 +450,7 @@
PRODUCT_NAME = UTIKit;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -464,16 +470,14 @@
PRODUCT_BUNDLE_IDENTIFIER = "info.cockscomb.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = UTIKit;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
09FD21551A962FC00071BF6B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -482,20 +486,19 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "info.cockscomb.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
09FD21561A962FC00071BF6B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = UTIKitTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "info.cockscomb.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
50 changes: 25 additions & 25 deletions UTIKit/UTI.swift
Expand Up @@ -64,17 +64,17 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata

// MARK: -

private static func UTIsForTagClass(tagClass: String, tag: String, conformingToUTI: UTI?) -> [UTI] {
private static func UTIsForTagClass(_ tagClass: String, tag: String, conformingToUTI: UTI?) -> [UTI] {
let conformingToUTIString: CFString? = conformingToUTI?.UTIString
guard let rawUTIs = UTTypeCreateAllIdentifiersForTag(tagClass, tag, conformingToUTIString)?.takeRetainedValue() else { return [] }
return (rawUTIs as NSArray as? [String] ?? []).map { UTI($0) }
}

public static func UTIsFromFilenameExtension(filenameExtension: String, conformingToUTI: UTI? = nil) -> [UTI] {
public static func UTIsFromFilenameExtension(_ filenameExtension: String, conformingToUTI: UTI? = nil) -> [UTI] {
return UTIsForTagClass(kUTTagClassFilenameExtension as String, tag: filenameExtension, conformingToUTI: conformingToUTI)
}

public static func UTIsFromMIMEType(MIMEType: String, conformingToUTI: UTI? = nil) -> [UTI] {
public static func UTIsFromMIMEType(_ MIMEType: String, conformingToUTI: UTI? = nil) -> [UTI] {
return UTIsForTagClass(kUTTagClassMIMEType as String, tag: MIMEType, conformingToUTI: conformingToUTI)
}

Expand All @@ -90,13 +90,13 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata

// MARK: - Tags

private func tagWithClass(tagClass: String) -> String? {
private func tagWithClass(_ tagClass: String) -> String? {
return UTTypeCopyPreferredTagWithClass(UTIString, tagClass)?.takeRetainedValue() as String?
}

@available(OSX, introduced=10.10)
@available(iOS, introduced=8.0)
private func tagsWithClass(tagClass: String) -> [String] {
@available(OSX, introduced:10.10)
@available(iOS, introduced:8.0)
private func tagsWithClass(_ tagClass: String) -> [String] {
guard let tags = UTTypeCopyAllTagsWithClass(UTIString, tagClass)?.takeRetainedValue() else { return [] }
return tags as NSArray as? [String] ?? []
}
Expand All @@ -105,8 +105,8 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata
return tagWithClass(kUTTagClassFilenameExtension as String)
}

@available(OSX, introduced=10.10)
@available(iOS, introduced=8.0)
@available(OSX, introduced:10.10)
@available(iOS, introduced:8.0)
public var filenameExtensions: [String] {
return tagsWithClass(kUTTagClassFilenameExtension as String)
}
Expand All @@ -115,8 +115,8 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata
return tagWithClass(kUTTagClassMIMEType as String)
}

@available(OSX, introduced=10.10)
@available(iOS, introduced=8.0)
@available(OSX, introduced:10.10)
@available(iOS, introduced:8.0)
public var MIMETypes: [String] {
return tagsWithClass(kUTTagClassMIMEType as String)
}
Expand All @@ -126,7 +126,7 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata
return tagWithClass(kUTTagClassNSPboardType as String)
}

@available(OSX, introduced=10.10)
@available(OSX, introduced:10.10)
public var pasteBoardTypes: [String] {
return tagsWithClass(kUTTagClassNSPboardType as String)
}
Expand All @@ -135,22 +135,22 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata
return tagWithClass(kUTTagClassOSType as String)
}

@available(OSX, introduced=10.10)
@available(OSX, introduced:10.10)
public var OSTypes: [String] {
return tagsWithClass(kUTTagClassOSType as String)
}
#endif

// MARK: - Status

@available(OSX, introduced=10.10)
@available(iOS, introduced=8.0)
@available(OSX, introduced:10.10)
@available(iOS, introduced:8.0)
public var isDeclared: Bool {
return UTTypeIsDeclared(UTIString)
}

@available(OSX, introduced=10.10)
@available(iOS, introduced=8.0)
@available(OSX, introduced:10.10)
@available(iOS, introduced:8.0)
public var isDynamic: Bool {
return UTTypeIsDynamic(UTIString)
}
Expand Down Expand Up @@ -191,9 +191,9 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata
return raw[kUTTypeIconFileKey] as? String
}

public var referenceURL: NSURL? {
public var referenceURL: URL? {
if let reference = raw[kUTTypeReferenceURLKey] as? String {
return NSURL(string: reference)
return URL(string: reference)
}
return nil
}
Expand All @@ -220,17 +220,17 @@ public struct UTI: CustomStringConvertible, CustomDebugStringConvertible, Equata
return Declaration(declaration: UTTypeCopyDeclaration(self.UTIString)?.takeRetainedValue() as [NSObject: AnyObject]? ?? [:])
}

public var declaringBundle: NSBundle? {
if let URL = UTTypeCopyDeclaringBundleURL(UTIString)?.takeRetainedValue() {
return NSBundle(URL: URL)
public var declaringBundle: Bundle? {
if let url = UTTypeCopyDeclaringBundleURL(UTIString)?.takeRetainedValue() {
return Bundle(url: url as URL)
}
return nil
}

public var iconFileURL: NSURL? {
public var iconFileURL: URL? {
if let iconFile = declaration.iconFile {
return self.declaringBundle?.URLForResource(iconFile, withExtension: nil) ??
self.declaringBundle?.URLForResource(iconFile, withExtension: "icns")
return self.declaringBundle?.urlForResource(iconFile, withExtension: nil) ??
self.declaringBundle?.urlForResource(iconFile, withExtension: "icns")
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions UTIKitTests/UTITests.swift
Expand Up @@ -90,11 +90,11 @@ class UTITests: XCTestCase {
let pages = UTI(filenameExtension: "pages")!
XCTAssertTrue(pages.declaration.exportedTypeDeclarations.isEmpty)
XCTAssertTrue(pages.declaration.importedTypeDeclarations.isEmpty)
XCTAssertEqual(pages.declaration.identifier!, "com.apple.iWork.Pages.pages")
XCTAssertEqual(pages.declaration.identifier?.lowercased(), "com.apple.iwork.pages.pages")
XCTAssertNotNil(pages.declaration.tagSpecification)
XCTAssertEqual(pages.declaration.conformsTo, [ UTI(kUTTypePackage as String), UTI(kUTTypeCompositeContent as String) ])
XCTAssertNil(pages.declaration.iconFile)
XCTAssertEqual(pages.declaration.referenceURL!, NSURL(string: "http://www.apple.com/iwork/pages/")!)
XCTAssertEqual(pages.declaration.referenceURL!, URL(string: "http://www.apple.com/iwork/pages/")!)
XCTAssertNil(pages.declaration.version)
}

Expand Down