From 2fdce6d3b8e90fdb89465716861a7cc6bda71743 Mon Sep 17 00:00:00 2001 From: own2pwn Date: Sun, 3 Jun 2018 12:54:38 +0300 Subject: [PATCH 1/4] + Project --- .../ClassFinalizer.xcodeproj/project.pbxproj | 316 ++++++++ .../contents.xcworkspacedata | 7 + .../ClassFinalizer/AppDelegate.swift | 20 + .../AppIcon.appiconset/Contents.json | 58 ++ .../ClassFinalizer/Base.lproj/Main.storyboard | 717 ++++++++++++++++++ .../ClassFinalizer.entitlements | 10 + ClassFinalizer/ClassFinalizer/Info.plist | 32 + .../ClassFinalizer/ViewController.swift | 38 + 8 files changed, 1198 insertions(+) create mode 100644 ClassFinalizer/ClassFinalizer.xcodeproj/project.pbxproj create mode 100644 ClassFinalizer/ClassFinalizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 ClassFinalizer/ClassFinalizer/AppDelegate.swift create mode 100644 ClassFinalizer/ClassFinalizer/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 ClassFinalizer/ClassFinalizer/Base.lproj/Main.storyboard create mode 100644 ClassFinalizer/ClassFinalizer/ClassFinalizer.entitlements create mode 100644 ClassFinalizer/ClassFinalizer/Info.plist create mode 100644 ClassFinalizer/ClassFinalizer/ViewController.swift diff --git a/ClassFinalizer/ClassFinalizer.xcodeproj/project.pbxproj b/ClassFinalizer/ClassFinalizer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..38cc579 --- /dev/null +++ b/ClassFinalizer/ClassFinalizer.xcodeproj/project.pbxproj @@ -0,0 +1,316 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + B9C8544020C3F1F9009CE02B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9C8543F20C3F1F9009CE02B /* AppDelegate.swift */; }; + B9C8544220C3F1F9009CE02B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9C8544120C3F1F9009CE02B /* ViewController.swift */; }; + B9C8544420C3F1F9009CE02B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B9C8544320C3F1F9009CE02B /* Assets.xcassets */; }; + B9C8544720C3F1F9009CE02B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B9C8544520C3F1F9009CE02B /* Main.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B9C8543C20C3F1F9009CE02B /* ClassFinalizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClassFinalizer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B9C8543F20C3F1F9009CE02B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + B9C8544120C3F1F9009CE02B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + B9C8544320C3F1F9009CE02B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + B9C8544620C3F1F9009CE02B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + B9C8544820C3F1F9009CE02B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B9C8544920C3F1F9009CE02B /* ClassFinalizer.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ClassFinalizer.entitlements; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B9C8543920C3F1F9009CE02B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B9C8543320C3F1F9009CE02B = { + isa = PBXGroup; + children = ( + B9C8543E20C3F1F9009CE02B /* ClassFinalizer */, + B9C8543D20C3F1F9009CE02B /* Products */, + ); + sourceTree = ""; + }; + B9C8543D20C3F1F9009CE02B /* Products */ = { + isa = PBXGroup; + children = ( + B9C8543C20C3F1F9009CE02B /* ClassFinalizer.app */, + ); + name = Products; + sourceTree = ""; + }; + B9C8543E20C3F1F9009CE02B /* ClassFinalizer */ = { + isa = PBXGroup; + children = ( + B9C8543F20C3F1F9009CE02B /* AppDelegate.swift */, + B9C8544120C3F1F9009CE02B /* ViewController.swift */, + B9C8544320C3F1F9009CE02B /* Assets.xcassets */, + B9C8544520C3F1F9009CE02B /* Main.storyboard */, + B9C8544820C3F1F9009CE02B /* Info.plist */, + B9C8544920C3F1F9009CE02B /* ClassFinalizer.entitlements */, + ); + path = ClassFinalizer; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B9C8543B20C3F1F9009CE02B /* ClassFinalizer */ = { + isa = PBXNativeTarget; + buildConfigurationList = B9C8544C20C3F1F9009CE02B /* Build configuration list for PBXNativeTarget "ClassFinalizer" */; + buildPhases = ( + B9C8543820C3F1F9009CE02B /* Sources */, + B9C8543920C3F1F9009CE02B /* Frameworks */, + B9C8543A20C3F1F9009CE02B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ClassFinalizer; + productName = ClassFinalizer; + productReference = B9C8543C20C3F1F9009CE02B /* ClassFinalizer.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B9C8543420C3F1F9009CE02B /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0920; + ORGANIZATIONNAME = Evgeniy; + TargetAttributes = { + B9C8543B20C3F1F9009CE02B = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = B9C8543720C3F1F9009CE02B /* Build configuration list for PBXProject "ClassFinalizer" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B9C8543320C3F1F9009CE02B; + productRefGroup = B9C8543D20C3F1F9009CE02B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B9C8543B20C3F1F9009CE02B /* ClassFinalizer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B9C8543A20C3F1F9009CE02B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B9C8544420C3F1F9009CE02B /* Assets.xcassets in Resources */, + B9C8544720C3F1F9009CE02B /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B9C8543820C3F1F9009CE02B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B9C8544220C3F1F9009CE02B /* ViewController.swift in Sources */, + B9C8544020C3F1F9009CE02B /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B9C8544520C3F1F9009CE02B /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B9C8544620C3F1F9009CE02B /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B9C8544A20C3F1F9009CE02B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + B9C8544B20C3F1F9009CE02B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + 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; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + }; + name = Release; + }; + B9C8544D20C3F1F9009CE02B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = ClassFinalizer/ClassFinalizer.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ClassFinalizer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = own2pwn.pp.ClassFinalizer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + }; + name = Debug; + }; + B9C8544E20C3F1F9009CE02B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = ClassFinalizer/ClassFinalizer.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ClassFinalizer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = own2pwn.pp.ClassFinalizer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B9C8543720C3F1F9009CE02B /* Build configuration list for PBXProject "ClassFinalizer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B9C8544A20C3F1F9009CE02B /* Debug */, + B9C8544B20C3F1F9009CE02B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B9C8544C20C3F1F9009CE02B /* Build configuration list for PBXNativeTarget "ClassFinalizer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B9C8544D20C3F1F9009CE02B /* Debug */, + B9C8544E20C3F1F9009CE02B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B9C8543420C3F1F9009CE02B /* Project object */; +} diff --git a/ClassFinalizer/ClassFinalizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ClassFinalizer/ClassFinalizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9b10e8a --- /dev/null +++ b/ClassFinalizer/ClassFinalizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ClassFinalizer/ClassFinalizer/AppDelegate.swift b/ClassFinalizer/ClassFinalizer/AppDelegate.swift new file mode 100644 index 0000000..e1bb15e --- /dev/null +++ b/ClassFinalizer/ClassFinalizer/AppDelegate.swift @@ -0,0 +1,20 @@ +// +// AppDelegate.swift +// ClassFinalizer +// +// Created by Evgeniy on 03.06.18. +// Copyright © 2018 Evgeniy. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +final class AppDelegate: NSObject, NSApplicationDelegate { + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + } +} diff --git a/ClassFinalizer/ClassFinalizer/Assets.xcassets/AppIcon.appiconset/Contents.json b/ClassFinalizer/ClassFinalizer/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/ClassFinalizer/ClassFinalizer/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ClassFinalizer/ClassFinalizer/Base.lproj/Main.storyboard b/ClassFinalizer/ClassFinalizer/Base.lproj/Main.storyboard new file mode 100644 index 0000000..83ccbb2 --- /dev/null +++ b/ClassFinalizer/ClassFinalizer/Base.lproj/Main.storyboard @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ClassFinalizer/ClassFinalizer/ClassFinalizer.entitlements b/ClassFinalizer/ClassFinalizer/ClassFinalizer.entitlements new file mode 100644 index 0000000..51a7cc5 --- /dev/null +++ b/ClassFinalizer/ClassFinalizer/ClassFinalizer.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/ClassFinalizer/ClassFinalizer/Info.plist b/ClassFinalizer/ClassFinalizer/Info.plist new file mode 100644 index 0000000..9ddb6db --- /dev/null +++ b/ClassFinalizer/ClassFinalizer/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2018 Evgeniy. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/ClassFinalizer/ClassFinalizer/ViewController.swift b/ClassFinalizer/ClassFinalizer/ViewController.swift new file mode 100644 index 0000000..fd7a48c --- /dev/null +++ b/ClassFinalizer/ClassFinalizer/ViewController.swift @@ -0,0 +1,38 @@ +// +// ViewController.swift +// ClassFinalizer +// +// Created by Evgeniy on 03.06.18. +// Copyright © 2018 Evgeniy. All rights reserved. +// + +import Cocoa + +final class ViewController: NSViewController { + + // MARK: - Outlets + + // MARK: - Overrides + + override func viewDidLoad() { + super.viewDidLoad() + + setupScreen() + } + + // MARK: - Members + + // MARK: - Methods + + private func setupScreen() { + setup() + } + + private func setup() { + let setup = [setColors] + setup.forEach { $0() } + } + + private func setColors() { + } +} From 9e01e4fd66d0ef64db57e436f1eea79e3c4add4f Mon Sep 17 00:00:00 2001 From: own2pwn Date: Sun, 3 Jun 2018 14:02:57 +0300 Subject: [PATCH 2/4] v 0.1 --- .../ClassFinalizer/ViewController.swift | 107 +++++++++++++++++- 1 file changed, 105 insertions(+), 2 deletions(-) diff --git a/ClassFinalizer/ClassFinalizer/ViewController.swift b/ClassFinalizer/ClassFinalizer/ViewController.swift index fd7a48c..499f943 100644 --- a/ClassFinalizer/ClassFinalizer/ViewController.swift +++ b/ClassFinalizer/ClassFinalizer/ViewController.swift @@ -8,6 +8,29 @@ import Cocoa +public typealias JSON = [String: Any] +public typealias JSONDict = [String: JSON] + +public final class FClass { + + // MARK: - Interface + + public let name: String + + public let isFinal: Bool + + public var childs: [FClass] = [] + + // MARK: - Init + + public init(name: String, isFinal: Bool) { + self.name = name + self.isFinal = isFinal + } +} + +public typealias ClassMapping = [String: FClass] + final class ViewController: NSViewController { // MARK: - Outlets @@ -22,6 +45,8 @@ final class ViewController: NSViewController { // MARK: - Members + private var mapping: ClassMapping = [:] + // MARK: - Methods private func setupScreen() { @@ -29,10 +54,88 @@ final class ViewController: NSViewController { } private func setup() { - let setup = [setColors] + let setup = [testFinalizer] setup.forEach { $0() } } - private func setColors() { + private func testFinalizer() { + let json = parseJson() + + let files: [JSON] = json.map { $0.values.first! } + for file in files { + processFile(file) + } + + let final = mapping.values.filter { !$0.isFinal && $0.childs.isEmpty } + print("we can make \(final.count) classess final! / total: \(mapping.count)") + } + + private func processFile(_ file: JSON) { + if let fs = file["key.substructure"] as? [JSON] { + for se in fs { + processFS(se) + } + } + } + + private func processFS(_ fs: JSON) { + // TODO: ignore NSObject, UIViewController, etc + + guard + let kind = fs["key.kind"] as? String, + let className = fs["key.name"] as? String, + kind == "source.lang.swift.decl.class" else { return } + + let isFinal = isClassFinal(fs) + + guard + let inheritanceArrray = fs["key.inheritedtypes"] as? NSArray, + let inheritedTypeDict = inheritanceArrray.firstObject as? [String: String], + let inheritedType = inheritedTypeDict.values.first else { + + let baseClass = FClass(name: className, isFinal: isFinal) + mapping[className] = baseClass + + return + } + + let child = FClass(name: className, isFinal: isFinal) + let parent: FClass + + if let parentClass: FClass = mapping[inheritedType] { + parent = parentClass + } else { + parent = FClass(name: inheritedType, isFinal: false) + mapping[inheritedType] = parent + } + + parent.childs.append(child) + mapping[className] = child + } + + private func isClassFinal(_ c: JSON) -> Bool { + guard + let attributes = c["key.attributes"] as? NSArray, + let attributesDict = attributes as? Array else { return false } + + for attribute in attributesDict { + guard + let finalAttribute = attribute["key.attribute"] as? String else { continue } + + if finalAttribute == "source.decl.attribute.final" { return true } + } + + return false + } + + private func parseJson() -> [JSONDict] { + let filePath = "/Dev/source-kitten-doc.json" + guard + let url = URL(string: "file://\(filePath)"), + let data = try? Data(contentsOf: url), + let object = try? JSONSerialization.jsonObject(with: data, options: []), + let json = object as? [JSONDict] else { fatalError() } + + return json } } From 73b820412704160055b1db83bd06dab87b046283 Mon Sep 17 00:00:00 2001 From: own2pwn Date: Sun, 3 Jun 2018 14:20:39 +0300 Subject: [PATCH 3/4] A bit more info about project --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a91e9bd..92846a1 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ -ClassFinalizer +## You no longer have to care about class attributes +Provided JSON info about project by [sourcekitten](https://github.com/jpsim/SourceKitten) analysis it and tries to figure out which classes could be final + +### EX +```swift +sourcekitten doc -- -workspace MegafonTV.xcworkspace -scheme MegafonTV > /Dev/source-kitten-doc.json +``` From a947e912cab2c8474117678664c567164d409231 Mon Sep 17 00:00:00 2001 From: own2pwn <7850039+own2pwn@users.noreply.github.com> Date: Thu, 7 Mar 2019 15:56:14 +0300 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92846a1..9451668 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,5 @@ Provided JSON info about project by [sourcekitten](https://github.com/jpsim/Sour ### EX ```swift -sourcekitten doc -- -workspace MegafonTV.xcworkspace -scheme MegafonTV > /Dev/source-kitten-doc.json +sourcekitten doc -- -workspace YourProject.xcworkspace -scheme YourProject > /Dev/source-kitten-doc.json ```