From 3e0e74dc44ea1257d2874927535b446f6d3a2425 Mon Sep 17 00:00:00 2001 From: Sean Henry Date: Sun, 6 Oct 2019 23:56:24 +0100 Subject: [PATCH 1/9] SK fix attempt --- EndToEndTests/EndToEndTests.swift | 16 +- EndToEndTests/MockGeneratorBaseTestCase.swift | 9 +- EndToEndTests/TestLocations.swift | 5 +- Gemfile | 7 - Gemfile.lock | 160 ------------------ MockGenerator.xcodeproj/project.pbxproj | 17 ++ MockGenerator/Generator.swift | 5 +- MockGeneratorApp/Base.lproj/Main.storyboard | 49 +----- MockGeneratorApp/PreferencesView.swift | 6 - MockGeneratorAppTests/PreferencesTests.swift | 18 -- .../XcodeProjectPathFinderTests.swift | 12 +- .../MemberTransformingVisitorTests.swift | 6 +- MockGeneratorTests/MockGeneratorTests.swift | 20 +-- MockGeneratorTests/ProjectFinderTests.swift | 4 +- ...eDeclarationTransformingVisitorTests.swift | 6 +- .../VariableTypeResolverTests.swift | 6 +- MockGeneratorXPC/MockGeneratorXPC.swift | 1 - MockGeneratorXPC/XPCMockGeneratorModel.swift | 6 - Shared/Preferences.swift | 16 +- Shared/XcodeProjectPathFinder.swift | 2 +- XcodePlugin/BaseCommand.swift | 15 +- config/Shared.xcconfig | 2 +- 22 files changed, 78 insertions(+), 310 deletions(-) delete mode 100644 Gemfile delete mode 100644 Gemfile.lock diff --git a/EndToEndTests/EndToEndTests.swift b/EndToEndTests/EndToEndTests.swift index 8cfa36d..38f285f 100644 --- a/EndToEndTests/EndToEndTests.swift +++ b/EndToEndTests/EndToEndTests.swift @@ -159,11 +159,17 @@ class EndToEndTests: MockGeneratorBaseTestCase { assertMockGeneratesExpected("AugmentedClassSubscriptMock") } - func test_returnsErrorWhenSDKPathDoesNotExist() { + func test_returnsErrorWhenProjectURLIsNotProjectOrWorkspace() { let preferences = Preferences() - let moduleCachePath = preferences.moduleCachePath - preferences.moduleCachePath = "/path/to/nowhere" - assertMockGeneratesError(fileName: "SimpleProtocolMock", "The module cache path does not exist. Change it in the companion app.") - preferences.moduleCachePath = moduleCachePath + preferences.automaticallyDetectProjectPath = false + preferences.projectPath = URL(fileURLWithPath: "/not/project") + assertMockGeneratesError(fileName: "SimpleProtocolMock", "The project path '/not/project' must be an .xcodeproj or .xcworkspace file. Change it in the companion app.") + } + + func test_returnsErrorWhenProjectURLDoesNotExist() { + let preferences = Preferences() + preferences.automaticallyDetectProjectPath = false + preferences.projectPath = URL(fileURLWithPath: "/not/project.xcodeproj") + assertMockGeneratesError(fileName: "SimpleProtocolMock", "The project path '/not/project.xcodeproj' does not exist. Change it in the companion app.") } } diff --git a/EndToEndTests/MockGeneratorBaseTestCase.swift b/EndToEndTests/MockGeneratorBaseTestCase.swift index cc6511c..240e07d 100644 --- a/EndToEndTests/MockGeneratorBaseTestCase.swift +++ b/EndToEndTests/MockGeneratorBaseTestCase.swift @@ -10,8 +10,7 @@ class MockGeneratorBaseTestCase: XCTestCase { continueAfterFailure = false let prefs = Preferences() prefs.automaticallyDetectProjectPath = false - prefs.projectPath = URL(fileURLWithPath: testProject) - prefs.moduleCachePath = getValidModuleCachePath() + prefs.projectPath = testProject XPCManager.setUpConnection() } @@ -64,7 +63,7 @@ class MockGeneratorBaseTestCase: XCTestCase { } private func readFile(named fileName: String) -> String { - return try! String(contentsOfFile: testProject + "/" + fileName) + return try! String(contentsOfFile: testProjectPath + "/" + fileName) } class TestCommand: BaseCommand { @@ -98,7 +97,7 @@ class MockGeneratorBaseTestCase: XCTestCase { } } - private func getValidModuleCachePath() -> String { - return "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" + private func getProjectURL() -> URL { + return URL(fileURLWithPath: "/Users/sean/source/plugins/XcodeMockGenerator/MockGenerator.xcworkspace") } } diff --git a/EndToEndTests/TestLocations.swift b/EndToEndTests/TestLocations.swift index 4cdd149..8bcd29d 100644 --- a/EndToEndTests/TestLocations.swift +++ b/EndToEndTests/TestLocations.swift @@ -1,4 +1,7 @@ import Cocoa // The test project is copied to the resources directory build phases -let testProject = Bundle(for: EndToEndTests.self).resourcePath! + "/TestProject" +let testProject = Bundle(for: EndToEndTests.self) + .resourceURL! + .appendingPathComponent("/TestProject/TestProject.xcodeproj") +let testProjectPath = testProject.deletingLastPathComponent().path diff --git a/Gemfile b/Gemfile deleted file mode 100644 index e5142ce..0000000 --- a/Gemfile +++ /dev/null @@ -1,7 +0,0 @@ -source "https://rubygems.org" - -gem "fastlane" -gem "bundler", "1.17.3" - -plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') -eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 5ba4cd2..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,160 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (3.0.0) - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) - atomos (0.1.3) - babosa (1.0.2) - claide (1.0.2) - colored (1.2) - colored2 (3.1.2) - commander-fastlane (4.4.6) - highline (~> 1.7.2) - declarative (0.0.10) - declarative-option (0.1.0) - digest-crc (0.4.1) - domain_name (0.5.20180417) - unf (>= 0.0.5, < 1.0.0) - dotenv (2.7.2) - emoji_regex (1.0.1) - excon (0.62.0) - faraday (0.15.4) - multipart-post (>= 1.2, < 3) - faraday-cookie_jar (0.0.6) - faraday (>= 0.7.4) - http-cookie (~> 1.0.0) - faraday_middleware (0.13.1) - faraday (>= 0.7.4, < 1.0) - fastimage (2.1.5) - fastlane (2.119.0) - CFPropertyList (>= 2.3, < 4.0.0) - addressable (>= 2.3, < 3.0.0) - babosa (>= 1.0.2, < 2.0.0) - bundler (>= 1.12.0, < 3.0.0) - colored - commander-fastlane (>= 4.4.6, < 5.0.0) - dotenv (>= 2.1.1, < 3.0.0) - emoji_regex (>= 0.1, < 2.0) - excon (>= 0.45.0, < 1.0.0) - faraday (~> 0.9) - faraday-cookie_jar (~> 0.0.6) - faraday_middleware (~> 0.9) - fastimage (>= 2.1.0, < 3.0.0) - gh_inspector (>= 1.1.2, < 2.0.0) - google-api-client (>= 0.21.2, < 0.24.0) - google-cloud-storage (>= 1.15.0, < 2.0.0) - highline (>= 1.7.2, < 2.0.0) - json (< 3.0.0) - mini_magick (~> 4.5.1) - multi_json - multi_xml (~> 0.5) - multipart-post (~> 2.0.0) - plist (>= 3.1.0, < 4.0.0) - public_suffix (~> 2.0.0) - rubyzip (>= 1.2.2, < 2.0.0) - security (= 0.1.3) - simctl (~> 1.6.3) - slack-notifier (>= 2.0.0, < 3.0.0) - terminal-notifier (>= 2.0.0, < 3.0.0) - terminal-table (>= 1.4.5, < 2.0.0) - tty-screen (>= 0.6.3, < 1.0.0) - tty-spinner (>= 0.8.0, < 1.0.0) - word_wrap (~> 1.0.0) - xcodeproj (>= 1.8.1, < 2.0.0) - xcpretty (~> 0.3.0) - xcpretty-travis-formatter (>= 0.0.3) - gh_inspector (1.1.3) - google-api-client (0.23.9) - addressable (~> 2.5, >= 2.5.1) - googleauth (>= 0.5, < 0.7.0) - httpclient (>= 2.8.1, < 3.0) - mime-types (~> 3.0) - representable (~> 3.0) - retriable (>= 2.0, < 4.0) - signet (~> 0.9) - google-cloud-core (1.3.0) - google-cloud-env (~> 1.0) - google-cloud-env (1.0.5) - faraday (~> 0.11) - google-cloud-storage (1.16.0) - digest-crc (~> 0.4) - google-api-client (~> 0.23) - google-cloud-core (~> 1.2) - googleauth (>= 0.6.2, < 0.10.0) - googleauth (0.6.7) - faraday (~> 0.12) - jwt (>= 1.4, < 3.0) - memoist (~> 0.16) - multi_json (~> 1.11) - os (>= 0.9, < 2.0) - signet (~> 0.7) - highline (1.7.10) - http-cookie (1.0.3) - domain_name (~> 0.5) - httpclient (2.8.3) - json (2.2.0) - jwt (2.1.0) - memoist (0.16.0) - mime-types (3.2.2) - mime-types-data (~> 3.2015) - mime-types-data (3.2018.0812) - mini_magick (4.5.1) - multi_json (1.13.1) - multi_xml (0.6.0) - multipart-post (2.0.0) - nanaimo (0.2.6) - naturally (2.2.0) - os (1.0.0) - plist (3.5.0) - public_suffix (2.0.5) - representable (3.0.4) - declarative (< 0.1.0) - declarative-option (< 0.2.0) - uber (< 0.2.0) - retriable (3.1.2) - rouge (2.0.7) - rubyzip (1.2.2) - security (0.1.3) - signet (0.11.0) - addressable (~> 2.3) - faraday (~> 0.9) - jwt (>= 1.5, < 3.0) - multi_json (~> 1.10) - simctl (1.6.5) - CFPropertyList - naturally - slack-notifier (2.3.2) - terminal-notifier (2.0.0) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - tty-cursor (0.6.1) - tty-screen (0.6.5) - tty-spinner (0.9.0) - tty-cursor (~> 0.6.0) - uber (0.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.5) - unicode-display_width (1.5.0) - word_wrap (1.0.0) - xcodeproj (1.8.2) - CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.3) - claide (>= 1.0.2, < 2.0) - colored2 (~> 3.1) - nanaimo (~> 0.2.6) - xcpretty (0.3.0) - rouge (~> 2.0.7) - xcpretty-travis-formatter (1.0.0) - xcpretty (~> 0.2, >= 0.0.7) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (= 1.17.3) - fastlane - -BUNDLED WITH - 1.17.3 diff --git a/MockGenerator.xcodeproj/project.pbxproj b/MockGenerator.xcodeproj/project.pbxproj index d9161da..3d4dadc 100644 --- a/MockGenerator.xcodeproj/project.pbxproj +++ b/MockGenerator.xcodeproj/project.pbxproj @@ -89,6 +89,7 @@ 1497FED2215E200100CD670B /* libSwiftLexer.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 149CF7B3217B115B005892B4 /* partial.mustache in Resources */ = {isa = PBXBuildFile; fileRef = 149CF792217B115A005892B4 /* partial.mustache */; }; 149CF7B5217B1301005892B4 /* PartialSpyCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149CF7B4217B1301005892B4 /* PartialSpyCommand.swift */; }; + 149D9289234AA499006FD765 /* Xcode.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 149D9288234AA499006FD765 /* Xcode.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 149DEC711F651B0C007DF43E /* MockGenerator.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 14276C611F4F312E00EA7753 /* MockGenerator.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14B4BC2C208B0A130052A085 /* XcodeProjectPathFinderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDFB741733D825DD2B6508 /* XcodeProjectPathFinderTests.swift */; }; 14B4BC2D208B0A160052A085 /* PreferencesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDF7966B174AC850706CB1 /* PreferencesTests.swift */; }; @@ -349,6 +350,13 @@ remoteGlobalIDString = 14CA2D521F40007000900937; remoteInfo = MockGeneratorApp; }; + 149D9287234AA499006FD765 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 196F972C20EEFA12009A5FD6 /* SwiftToolkit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 14B05550234A938C001BA24F; + remoteInfo = Xcode; + }; 14CA2D751F40009000900937 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 14CA2D4B1F40007000900937 /* Project object */; @@ -633,6 +641,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 149D9289234AA499006FD765 /* Xcode.framework in Embed Frameworks */, 142B023021709A97005DE573 /* UseCases.framework in Embed Frameworks */, 142B022A21709979005DE573 /* SourceKittenFramework.framework in Embed Frameworks */, 142B022B21709979005DE573 /* SWXMLHash.framework in Embed Frameworks */, @@ -1254,6 +1263,7 @@ 1425EBA121528F8F00009D60 /* SwiftierKitTests.xctest */, 1425EBA321528F8F00009D60 /* libSwiftyPluginTest.dylib */, 1425EBA521528F8F00009D60 /* SwiftyPluginTestTests.xctest */, + 149D9288234AA499006FD765 /* Xcode.framework */, ); name = Products; sourceTree = ""; @@ -1789,6 +1799,13 @@ remoteRef = 1425EBA421528F8F00009D60 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 149D9288234AA499006FD765 /* Xcode.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Xcode.framework; + remoteRef = 149D9287234AA499006FD765 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 191EF66820F447D300118C74 /* libFormatter.dylib */ = { isa = PBXReferenceProxy; fileType = archive.ar; diff --git a/MockGenerator/Generator.swift b/MockGenerator/Generator.swift index c0340d1..612187f 100644 --- a/MockGenerator/Generator.swift +++ b/MockGenerator/Generator.swift @@ -18,7 +18,6 @@ public class Generator { public init(fromFileContents fileContents: String, projectURL: URL, - moduleCachePath: String, line: Int, column: Int, templateName: String, @@ -30,8 +29,8 @@ public class Generator { self.templateName = templateName self.useTabsForIndentation = useTabsForIndentation self.indentationWidth = indentationWidth - let sourceFiles = SourceFileFinder(projectRoot: projectURL).findSourceFiles() - self.resolver = ResolverFactory.createResolver(filePaths: Generator.filterUniqueFileNames(sourceFiles), moduleCachePath: moduleCachePath) + let sourceFiles = SourceFileFinder(projectRoot: projectURL.deletingLastPathComponent()).findSourceFiles() + self.resolver = ResolverFactory.createResolver(filePaths: Generator.filterUniqueFileNames(sourceFiles), projectURL: projectURL) } private static func filterUniqueFileNames(_ fileNames: [URL]) -> [String] { diff --git a/MockGeneratorApp/Base.lproj/Main.storyboard b/MockGeneratorApp/Base.lproj/Main.storyboard index 1ff8e80..d018563 100644 --- a/MockGeneratorApp/Base.lproj/Main.storyboard +++ b/MockGeneratorApp/Base.lproj/Main.storyboard @@ -693,10 +693,10 @@ - + - + @@ -742,7 +742,7 @@ - + @@ -750,7 +750,7 @@ - + @@ -783,7 +783,7 @@ - + @@ -859,34 +859,6 @@ - - - - - - - - - - - - - The path to the module cache. This is in your derived data directory named: Module.noindex and should not be changed unless you use a custom derived data directory. - - - - - - - - - - - - - - - @@ -898,13 +870,11 @@ - - @@ -914,9 +884,6 @@ - - - @@ -925,9 +892,6 @@ - - - @@ -940,7 +904,6 @@ - diff --git a/MockGeneratorApp/PreferencesView.swift b/MockGeneratorApp/PreferencesView.swift index a7f6974..09825cc 100644 --- a/MockGeneratorApp/PreferencesView.swift +++ b/MockGeneratorApp/PreferencesView.swift @@ -7,7 +7,6 @@ class PreferencesView: NSView, NSTextFieldDelegate { @IBOutlet private var automaticPathCheckbox: NSButton! @IBOutlet private var projectPathField: NSTextField! - @IBOutlet private var moduleCachePath: NSTextField! private let preferences = Preferences() required init?(coder aDecoder: NSCoder) { @@ -32,7 +31,6 @@ class PreferencesView: NSView, NSTextFieldDelegate { private func updateView() { automaticPathCheckbox.state = preferences.automaticallyDetectProjectPath ? .on : .off - moduleCachePath.stringValue = preferences.moduleCachePath updateContainers() } @@ -49,8 +47,4 @@ class PreferencesView: NSView, NSTextFieldDelegate { projectPathField.stringValue = "Cannot find a project. Make sure a project is open in Xcode." } } - - func controlTextDidChange(_ obj: Notification) { - preferences.moduleCachePath = moduleCachePath.stringValue - } } diff --git a/MockGeneratorAppTests/PreferencesTests.swift b/MockGeneratorAppTests/PreferencesTests.swift index 6ce5a58..867438d 100644 --- a/MockGeneratorAppTests/PreferencesTests.swift +++ b/MockGeneratorAppTests/PreferencesTests.swift @@ -75,22 +75,4 @@ class PreferencesTests: XCTestCase { preferences.automaticallyDetectProjectPath = true XCTAssert(preferences.automaticallyDetectProjectPath) } - - // MARK: - moduleCachePath - - func test_moduleCachePath_shouldHaveDefaultPath() { - XCTAssertEqual(preferences.moduleCachePath, "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex") - } - - func test_moduleCachePath_shouldHaveDefaultPath_whenEmptyString() { - preferences.moduleCachePath = "" - XCTAssertEqual(preferences.moduleCachePath, "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex") - } - - func test_moduleCachePath_shouldChangeValue() { - preferences.moduleCachePath = "/Path" - XCTAssertEqual(preferences.moduleCachePath, "/Path") - preferences.moduleCachePath = "/AnotherPath" - XCTAssertEqual(preferences.moduleCachePath, "/AnotherPath") - } } diff --git a/MockGeneratorAppTests/XcodeProjectPathFinderTests.swift b/MockGeneratorAppTests/XcodeProjectPathFinderTests.swift index 17cf70a..01965f2 100644 --- a/MockGeneratorAppTests/XcodeProjectPathFinderTests.swift +++ b/MockGeneratorAppTests/XcodeProjectPathFinderTests.swift @@ -17,19 +17,19 @@ class XcodeProjectPathFinderTests: XCTestCase { XCTAssertNil(finder.findOpenProjectPath()) } - func test_findOpenProjectPath_shouldReturnParentPath_whenWorkspaceIsFound() { + func test_findOpenProjectPath_shouldReturnWorkspace_whenWorkspaceIsFound() { finder.stubbedFindOpenWorkspacePathResult = "/path/to/workspace.xcworkspace" - XCTAssertEqual(finder.findOpenProjectPath()?.path, "/path/to") + XCTAssertEqual(finder.findOpenProjectPath()?.path, "/path/to/workspace.xcworkspace") } - func test_findOpenProjectPath_shouldReturnParentPath_whenProjectIsFound() { + func test_findOpenProjectPath_shouldReturnProjectPath_whenProjectIsFound() { finder.stubbedFindOpenWorkspacePathResult = "/path/to/project.xcodeproj" - XCTAssertEqual(finder.findOpenProjectPath()?.path, "/path/to") + XCTAssertEqual(finder.findOpenProjectPath()?.path, "/path/to/project.xcodeproj") } - func test_findOpenProjectPath_shouldReturnParentPath_whenRootProjectIsFound() { + func test_findOpenProjectPath_shouldReturnProjectPath_whenRootProjectIsFound() { finder.stubbedFindOpenWorkspacePathResult = "/project.xcodeproj" - XCTAssertEqual(finder.findOpenProjectPath()?.path, "/") + XCTAssertEqual(finder.findOpenProjectPath()?.path, "/project.xcodeproj") } func test_findOpenProjectPath_shouldReturnNil_whenLocalProjectIsFound() { diff --git a/MockGeneratorTests/MemberTransformingVisitorTests.swift b/MockGeneratorTests/MemberTransformingVisitorTests.swift index 01c2d2e..e282586 100644 --- a/MockGeneratorTests/MemberTransformingVisitorTests.swift +++ b/MockGeneratorTests/MemberTransformingVisitorTests.swift @@ -13,7 +13,7 @@ class MemberTransformingVisitorTests: XCTestCase { override func setUp() { super.setUp() - resolver = ResolverFactory.createResolver(filePaths: [], moduleCachePath: getValidModuleCachePath()) + resolver = ResolverFactory.createResolver(filePaths: [], projectURL: getProjectURL()) visitor = MemberTransformingVisitor(resolver: resolver) } @@ -617,7 +617,7 @@ class MemberTransformingVisitorTests: XCTestCase { """ } - private func getValidModuleCachePath() -> String { - return "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" + private func getProjectURL() -> URL { + return URL(fileURLWithPath: "/Users/sean/source/plugins/XcodeMockGenerator/MockGenerator.xcworkspace") } } diff --git a/MockGeneratorTests/MockGeneratorTests.swift b/MockGeneratorTests/MockGeneratorTests.swift index 3087281..0d8e4cf 100644 --- a/MockGeneratorTests/MockGeneratorTests.swift +++ b/MockGeneratorTests/MockGeneratorTests.swift @@ -5,8 +5,9 @@ import TestHelper class MockGeneratorTests: XCTestCase { // The test project is copied to the resources directory build phases - let testProject = Bundle(for: MockGeneratorTests.self).resourcePath! + "/TestProject" - + let testProject = Bundle(for: MockGeneratorTests.self).resourceURL!.appendingPathComponent("/TestProject/TestProject.xcodeproj") + let testProjectPath = Bundle(for: MockGeneratorTests.self).resourcePath! + "/TestProject" + func test_generatesSimpleMock() { assertMockGeneratesExpected("SimpleProtocolMock") } @@ -208,7 +209,7 @@ class MockGeneratorTests: XCTestCase { } while contentsLineColumn.lineColumn != nil XCTAssertGreaterThan(caretLineColumns.count, 0) caretLineColumns.forEach { lineColumn in - let file = try! String(contentsOfFile: testProject + "/SimpleProtocolMock.swift") + let file = try! String(contentsOfFile: testProjectPath + "/SimpleProtocolMock.swift") let (lines, error) = generateMock(file) XCTAssertNil(error, "Failed to generate mock from caret at line: \(lineColumn.line) column: \(lineColumn.column)") StringCompareTestHelper.assertEqualStrings(join(lines), expected) @@ -227,7 +228,7 @@ class MockGeneratorTests: XCTestCase { } while contentsLineColumn.lineColumn != nil XCTAssertGreaterThan(caretLineColumns.count, 0) caretLineColumns.forEach { lineColumn in - let (lines, error) = Generator(fromFileContents: contentsLineColumn.contents, projectURL: URL(fileURLWithPath: testProject), moduleCachePath: getValidModuleCachePath(), line: lineColumn.line, column: lineColumn.column, templateName: "spy", useTabsForIndentation: false, indentationWidth: 4).generateMock() + let (lines, error) = Generator(fromFileContents: contentsLineColumn.contents, projectURL: testProject, line: lineColumn.line, column: lineColumn.column, templateName: "spy", useTabsForIndentation: false, indentationWidth: 4).generateMock() XCTAssertNotNil(error, "Should not be generating a mock from caret at line: \(lineColumn.line) column: \(lineColumn.column)") XCTAssertNil(lines) } @@ -245,7 +246,7 @@ class MockGeneratorTests: XCTestCase { } private func assertMockGeneratesError(fileName: String, _ expectedError: String, line: UInt = #line) { - let contents = try! String(contentsOfFile: testProject + "/" + fileName + ".swift") + let contents = try! String(contentsOfFile: testProjectPath + "/" + fileName + ".swift") assertMockGeneratesError(contents: contents, expectedError, line: line) } @@ -263,7 +264,7 @@ class MockGeneratorTests: XCTestCase { } private func readFile(named fileName: String) -> String { - return try! String(contentsOfFile: testProject + "/" + fileName) + return try! String(contentsOfFile: testProjectPath + "/" + fileName) } private func assertMock(_ mock: String, generates expected: String, templateName: String = "spy", line: UInt = #line) { @@ -275,8 +276,7 @@ class MockGeneratorTests: XCTestCase { private func generateMock(_ mock: String, templateName: String = "spy") -> ([String]?, Error?) { let result = CaretTestHelper.findCaretLineColumn(mock) let (instructions, error) = Generator(fromFileContents: result.contents, - projectURL: URL(fileURLWithPath: testProject), - moduleCachePath: getValidModuleCachePath(), + projectURL: testProject, line: result.lineColumn!.line, column: result.lineColumn!.column, templateName: templateName, @@ -310,8 +310,4 @@ class MockGeneratorTests: XCTestCase { guard let lines = lines else { return nil } return lines.joined() } - - private func getValidModuleCachePath() -> String { - return "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" - } } diff --git a/MockGeneratorTests/ProjectFinderTests.swift b/MockGeneratorTests/ProjectFinderTests.swift index 129db38..63dae14 100644 --- a/MockGeneratorTests/ProjectFinderTests.swift +++ b/MockGeneratorTests/ProjectFinderTests.swift @@ -43,10 +43,10 @@ class ProjectFinderTests: XCTestCase { assertEqualError("Could not detect your project. Enter one in the companion app.") } - func test_getProjectPath_shouldReturnAutomaticProjectPath() { + func test_getProjectPath_shouldReturnAutomaticPathToProjectOrWorkspace() { preferences.automaticallyDetectProjectPath = true mockProjectFinder.stubbedFindOpenWorkspacePathResult = projectFolder - assertEqualProjectPath(projectPath) + assertEqualProjectPath(projectFolder) } // MARK: - Helpers diff --git a/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift b/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift index 6410de6..fec8f6b 100644 --- a/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift +++ b/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift @@ -12,7 +12,7 @@ class TypeDeclarationTransformingVisitorTests: XCTestCase { override func setUp() { super.setUp() - resolver = ResolverFactory.createResolver(filePaths: [], moduleCachePath: getValidModuleCachePath()) + resolver = ResolverFactory.createResolver(filePaths: [], projectURL: getProjectURL()) } override func tearDown() { @@ -190,7 +190,7 @@ class TypeDeclarationTransformingVisitorTests: XCTestCase { """ } - private func getValidModuleCachePath() -> String { - return "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" + private func getProjectURL() -> URL { + return URL(fileURLWithPath: "/Users/sean/source/plugins/XcodeMockGenerator/MockGenerator.xcworkspace") } } diff --git a/MockGeneratorTests/VariableTypeResolverTests.swift b/MockGeneratorTests/VariableTypeResolverTests.swift index 7649486..6fd1f47 100644 --- a/MockGeneratorTests/VariableTypeResolverTests.swift +++ b/MockGeneratorTests/VariableTypeResolverTests.swift @@ -143,14 +143,14 @@ class VariableTypeResolverTests: XCTestCase { struct StructType {} enum EnumType {} """ - return VariableTypeResolver.resolve(try parse(fullText), resolver: ResolverFactory.createResolver(filePaths: [], moduleCachePath: getValidModuleCachePath())) + return VariableTypeResolver.resolve(try parse(fullText), resolver: ResolverFactory.createResolver(filePaths: [], projectURL: getProjectURL())) } private func parse(_ text: String) throws -> Element { return try ParserTestHelper.parseFile(from: text).children[0] } - private func getValidModuleCachePath() -> String { - return "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" + private func getProjectURL() -> URL { + return URL(fileURLWithPath: "/Users/sean/source/plugins/XcodeMockGenerator/MockGenerator.xcworkspace") } } diff --git a/MockGeneratorXPC/MockGeneratorXPC.swift b/MockGeneratorXPC/MockGeneratorXPC.swift index d52b03b..721379f 100644 --- a/MockGeneratorXPC/MockGeneratorXPC.swift +++ b/MockGeneratorXPC/MockGeneratorXPC.swift @@ -6,7 +6,6 @@ import MockGenerator func generateMock(from model: XPCMockGeneratorModel, withReply reply: @escaping (XPCBufferInstructions?, Error?) -> ()) { let (instructions, error) = Generator(fromFileContents: model.contents, projectURL: model.projectURL, - moduleCachePath: model.moduleCachePath, line: model.line, column: model.column, templateName: model.templateName, diff --git a/MockGeneratorXPC/XPCMockGeneratorModel.swift b/MockGeneratorXPC/XPCMockGeneratorModel.swift index 084181f..bba60bb 100644 --- a/MockGeneratorXPC/XPCMockGeneratorModel.swift +++ b/MockGeneratorXPC/XPCMockGeneratorModel.swift @@ -4,7 +4,6 @@ import Foundation let contents: String let projectURL: URL - let moduleCachePath: String let line: Int let column: Int let templateName: String @@ -17,7 +16,6 @@ import Foundation init(contents: String, projectURL: URL, - moduleCachePath: String, line: Int, column: Int, templateName: String, @@ -25,7 +23,6 @@ import Foundation indentationWidth: Int) { self.contents = contents self.projectURL = projectURL - self.moduleCachePath = moduleCachePath self.line = line self.column = column self.templateName = templateName @@ -36,7 +33,6 @@ import Foundation required init?(coder aDecoder: NSCoder) { guard let contents = aDecoder.decodeObject(of: NSString.self, forKey: "contents"), let projectURL = aDecoder.decodeObject(of: NSURL.self, forKey: "projectURL"), - let moduleCachePath = aDecoder.decodeObject(of: NSString.self, forKey: "moduleCachePath"), let line = aDecoder.decodeObject(of: NSNumber.self, forKey: "line"), let column = aDecoder.decodeObject(of: NSNumber.self, forKey: "column"), let templateName = aDecoder.decodeObject(of: NSString.self, forKey: "templateName"), @@ -46,7 +42,6 @@ import Foundation } self.contents = contents as String self.projectURL = projectURL as URL - self.moduleCachePath = moduleCachePath as String self.line = line.intValue self.column = column.intValue self.templateName = templateName as String @@ -57,7 +52,6 @@ import Foundation func encode(with aCoder: NSCoder) { aCoder.encode(contents as NSString, forKey: "contents") aCoder.encode(projectURL as NSURL, forKey: "projectURL") - aCoder.encode(moduleCachePath as NSString, forKey: "moduleCachePath") aCoder.encode(line as NSNumber, forKey: "line") aCoder.encode(column as NSNumber, forKey: "column") aCoder.encode(templateName as NSString, forKey: "templateName") diff --git a/Shared/Preferences.swift b/Shared/Preferences.swift index f0b4ad5..db69ed1 100644 --- a/Shared/Preferences.swift +++ b/Shared/Preferences.swift @@ -14,7 +14,7 @@ class Preferences { private let projectPathHistoryKey = "project.path.history" private let automaticallyDetectProjectPathKey = "project.path.autoDetect" private let sdkPathKey = "sdk.path" // This was once used - private let moduleCachePathKey = "moduleCache.path" + private let moduleCachePathKey = "moduleCache.path" // This was once used init(userDefaults: UserDefaults = UserDefaults(suiteName: "group.codes.seanhenry.MockGenerator")!) { self.userDefaults = userDefaults @@ -61,18 +61,4 @@ class Preferences { return userDefaults.object(forKey: automaticallyDetectProjectPathKey) as? Bool ?? true } } - - var moduleCachePath: String { - set { - userDefaults.set(newValue, forKey: moduleCachePathKey) - } - get { - let path = "/Users/\(NSUserName())/Library/Developer/Xcode/DerivedData/ModuleCache.noindex" - guard let value = userDefaults.string(forKey: moduleCachePathKey), - !value.isEmpty else { - return path - } - return value - } - } } diff --git a/Shared/XcodeProjectPathFinder.swift b/Shared/XcodeProjectPathFinder.swift index 0415597..3a7d4f1 100644 --- a/Shared/XcodeProjectPathFinder.swift +++ b/Shared/XcodeProjectPathFinder.swift @@ -5,7 +5,7 @@ class XcodeProjectPathFinder { func findOpenProjectPath() -> URL? { if let workspace = findOpenWorkspacePath(), workspace.hasPrefix("/") { - return URL(fileURLWithPath: workspace).deletingLastPathComponent() + return URL(fileURLWithPath: workspace) } return nil } diff --git a/XcodePlugin/BaseCommand.swift b/XcodePlugin/BaseCommand.swift index c15ddaa..9c7a5da 100644 --- a/XcodePlugin/BaseCommand.swift +++ b/XcodePlugin/BaseCommand.swift @@ -70,6 +70,12 @@ open class BaseCommand: NSObject, XCSourceEditorCommand { private func generateMock(proxy: MockGeneratorXPCProtocol, invocation: SourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void) { do { let projectURL = try getProjectURLOnMainThread() + guard ["xcodeproj", "xcworkspace"].contains(projectURL.pathExtension) else { + throw createError("The project path '\(projectURL.path)' must be an .xcodeproj or .xcworkspace file. Change it in the companion app.") + } + guard FileManager.default.fileExists(atPath: projectURL.path) else { + throw createError("The project path '\(projectURL.path)' does not exist. Change it in the companion app.") + } try tryToGenerateMock(atProjectURL: projectURL, proxy: proxy, invocation: invocation) { [weak self] (result, error) in self?.handleGenerateMock(invocation: invocation, result: result, error: error, completionHandler: completionHandler) } @@ -83,7 +89,6 @@ open class BaseCommand: NSObject, XCSourceEditorCommand { let model = XPCMockGeneratorModel( contents: invocation.sourceTextBuffer.completeBuffer, projectURL: projectURL, - moduleCachePath: try getModuleCachePath(), line: range.start.line, column: range.start.column, templateName: templateName, @@ -140,12 +145,4 @@ open class BaseCommand: NSObject, XCSourceEditorCommand { private func createError(_ message: String) -> Error { return NSError(domain: "codes.seanhenry.mockgenerator", code: 0, userInfo: [NSLocalizedDescriptionKey: message]) } - - private func getModuleCachePath() throws -> String { - let moduleCachePath = Preferences().moduleCachePath - guard FileManager.default.fileExists(atPath: moduleCachePath) else { - throw createError("The module cache path does not exist. Change it in the companion app.") - } - return moduleCachePath - } } diff --git a/config/Shared.xcconfig b/config/Shared.xcconfig index 4af5e2f..bfc49f0 100644 --- a/config/Shared.xcconfig +++ b/config/Shared.xcconfig @@ -1,6 +1,6 @@ #include "../SwiftToolkit/config/Shared.xcconfig" -VERSION_NUMBER = 0.22 +VERSION_NUMBER = 0.23 CLANG_ANALYZER_NONNULL = YES CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE ENABLE_HARDENED_RUNTIME = YES From 87a08fc14eb71effd95c7440e8ce7bd0fa87b101 Mon Sep 17 00:00:00 2001 From: Sean Henry Date: Wed, 9 Oct 2019 19:10:32 +0100 Subject: [PATCH 2/9] Adds platform to get SDK and target --- EndToEndTests/EndToEndTests.swift | 16 ++-- MockGenerator.xcodeproj/project.pbxproj | 51 ++++++------- MockGenerator/Generator.swift | 3 +- MockGeneratorApp/Base.lproj/Main.storyboard | 75 ++++++++++++++----- .../MockGeneratorApp.entitlements | 2 - MockGeneratorApp/PreferencesView.swift | 21 +++++- MockGeneratorAppTests/PreferencesTests.swift | 19 +++++ .../MemberTransformingVisitorTests.swift | 6 +- MockGeneratorTests/MockGeneratorTests.swift | 3 +- ...eDeclarationTransformingVisitorTests.swift | 6 +- .../VariableTypeResolverTests.swift | 6 +- MockGeneratorXPC/MockGeneratorXPC.swift | 1 + MockGeneratorXPC/XPCMockGeneratorModel.swift | 6 ++ Shared/Preferences.swift | 15 ++++ XcodePlugin/BaseCommand.swift | 11 ++- XcodePlugin/XcodePlugin.entitlements | 2 - 16 files changed, 166 insertions(+), 77 deletions(-) diff --git a/EndToEndTests/EndToEndTests.swift b/EndToEndTests/EndToEndTests.swift index 38f285f..9c7a3bc 100644 --- a/EndToEndTests/EndToEndTests.swift +++ b/EndToEndTests/EndToEndTests.swift @@ -3,6 +3,11 @@ import XCTest class EndToEndTests: MockGeneratorBaseTestCase { + override func setUp() { + super.setUp() + Preferences().platform = "macosx" + } + func test_generatesSimpleMock() { assertMockGeneratesExpected("SimpleProtocolMock") } @@ -159,17 +164,16 @@ class EndToEndTests: MockGeneratorBaseTestCase { assertMockGeneratesExpected("AugmentedClassSubscriptMock") } - func test_returnsErrorWhenProjectURLIsNotProjectOrWorkspace() { + func test_returnsErrorWhenPlatformIsNil() { let preferences = Preferences() - preferences.automaticallyDetectProjectPath = false - preferences.projectPath = URL(fileURLWithPath: "/not/project") - assertMockGeneratesError(fileName: "SimpleProtocolMock", "The project path '/not/project' must be an .xcodeproj or .xcworkspace file. Change it in the companion app.") + preferences.platform = nil + assertMockGeneratesError(fileName: "SimpleProtocolMock", "No platform has been selected. Choose one in the companion app.") } func test_returnsErrorWhenProjectURLDoesNotExist() { let preferences = Preferences() preferences.automaticallyDetectProjectPath = false - preferences.projectPath = URL(fileURLWithPath: "/not/project.xcodeproj") - assertMockGeneratesError(fileName: "SimpleProtocolMock", "The project path '/not/project.xcodeproj' does not exist. Change it in the companion app.") + preferences.projectPath = URL(fileURLWithPath: "/not/project") + assertMockGeneratesError(fileName: "SimpleProtocolMock", "The project path '/not/project' does not exist. Change it in the companion app.") } } diff --git a/MockGenerator.xcodeproj/project.pbxproj b/MockGenerator.xcodeproj/project.pbxproj index 3d4dadc..0ba1fb6 100644 --- a/MockGenerator.xcodeproj/project.pbxproj +++ b/MockGenerator.xcodeproj/project.pbxproj @@ -63,6 +63,7 @@ 14451D351F5F05C500833C61 /* MemberTransformingVisitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDF7A9B1705ADFFC0CB415 /* MemberTransformingVisitorTests.swift */; }; 145290EA1F981ED600947144 /* VersionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 145290E91F981ED600947144 /* VersionView.swift */; }; 147437B61F79746A00241B8A /* TestProject in Copy Test Project */ = {isa = PBXBuildFile; fileRef = 147437B51F79746000241B8A /* TestProject */; }; + 1485244A234E5B19007F3D26 /* libCommandLine.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 14D345DE234DC20700054682 /* libCommandLine.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 14887ABC20FB859B00D50A73 /* MockGenerator.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 14276C611F4F312E00EA7753 /* MockGenerator.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 1497FE77215D0B5C00CD670B /* XcodeAccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1497FE76215D0B5C00CD670B /* XcodeAccess.swift */; }; 1497FE78215E147200CD670B /* libAlgorithms.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 196F974C20EEFA12009A5FD6 /* libAlgorithms.dylib */; }; @@ -89,7 +90,6 @@ 1497FED2215E200100CD670B /* libSwiftLexer.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 149CF7B3217B115B005892B4 /* partial.mustache in Resources */ = {isa = PBXBuildFile; fileRef = 149CF792217B115A005892B4 /* partial.mustache */; }; 149CF7B5217B1301005892B4 /* PartialSpyCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149CF7B4217B1301005892B4 /* PartialSpyCommand.swift */; }; - 149D9289234AA499006FD765 /* Xcode.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 149D9288234AA499006FD765 /* Xcode.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 149DEC711F651B0C007DF43E /* MockGenerator.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 14276C611F4F312E00EA7753 /* MockGenerator.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14B4BC2C208B0A130052A085 /* XcodeProjectPathFinderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDFB741733D825DD2B6508 /* XcodeProjectPathFinderTests.swift */; }; 14B4BC2D208B0A160052A085 /* PreferencesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDF7966B174AC850706CB1 /* PreferencesTests.swift */; }; @@ -105,6 +105,8 @@ 14CA2D911F4000C400900937 /* MockGeneratorXPC.xpc in CopyFiles */ = {isa = PBXBuildFile; fileRef = 14CA2D801F4000AB00900937 /* MockGeneratorXPC.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 14CA2D9E1F40049700900937 /* MockGeneratorXPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14CA2D9D1F40049700900937 /* MockGeneratorXPC.swift */; }; 14CA2DAC1F41349500900937 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14CA2DAB1F41349500900937 /* Preferences.swift */; }; + 14D345DF234DC20700054682 /* libCommandLine.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 14D345DE234DC20700054682 /* libCommandLine.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 14D345E0234DC22000054682 /* libCommandLine.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 14D345DE234DC20700054682 /* libCommandLine.dylib */; }; 14E132281F58E6D300D75943 /* MemberTransformingVisitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35CDFDB834B634E694CF658C /* MemberTransformingVisitor.swift */; }; 14E9A2F9216EEABC00A677FA /* XcodeAccessImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14E9A2F8216EEABC00A677FA /* XcodeAccessImpl.swift */; }; 14E9A31B216EEB6000A677FA /* XcodeAccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14E9A31A216EEB6000A677FA /* XcodeAccessView.swift */; }; @@ -350,13 +352,6 @@ remoteGlobalIDString = 14CA2D521F40007000900937; remoteInfo = MockGeneratorApp; }; - 149D9287234AA499006FD765 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 196F972C20EEFA12009A5FD6 /* SwiftToolkit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 14B05550234A938C001BA24F; - remoteInfo = Xcode; - }; 14CA2D751F40009000900937 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 14CA2D4B1F40007000900937 /* Project object */; @@ -371,6 +366,13 @@ remoteGlobalIDString = 14CA2D7F1F4000AB00900937; remoteInfo = MockGeneratorXPC; }; + 14D345DD234DC20700054682 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 196F972C20EEFA12009A5FD6 /* SwiftToolkit.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 14D345AF234DC0E400054682; + remoteInfo = CommandLine; + }; 14F866C920D9088F00E79758 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 14CA2D4B1F40007000900937 /* Project object */; @@ -641,7 +643,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 149D9289234AA499006FD765 /* Xcode.framework in Embed Frameworks */, + 14D345DF234DC20700054682 /* libCommandLine.dylib in Embed Frameworks */, 142B023021709A97005DE573 /* UseCases.framework in Embed Frameworks */, 142B022A21709979005DE573 /* SourceKittenFramework.framework in Embed Frameworks */, 142B022B21709979005DE573 /* SWXMLHash.framework in Embed Frameworks */, @@ -710,6 +712,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 1485244A234E5B19007F3D26 /* libCommandLine.dylib in Copy Frameworks */, 142B023121709AFF005DE573 /* UseCases.framework in Copy Frameworks */, 142B023621709AFF005DE573 /* SourceKittenFramework.framework in Copy Frameworks */, 142B023721709B00005DE573 /* SWXMLHash.framework in Copy Frameworks */, @@ -924,6 +927,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 14D345E0234DC22000054682 /* libCommandLine.dylib in Frameworks */, 14354103232E4FF80019615B /* Lexer in Frameworks */, 191EF6E420F6C92B00118C74 /* Crashlytics.framework in Frameworks */, 191EF6E520F6C92C00118C74 /* Fabric.framework in Frameworks */, @@ -1236,6 +1240,7 @@ 1425EB8121528F8F00009D60 /* libASTSerialize.dylib */, 1425EB8321528F8F00009D60 /* ASTSerializeTests.xctest */, 1425EB8521528F8F00009D60 /* ASTSerializePerfTests.xctest */, + 14D345DE234DC20700054682 /* libCommandLine.dylib */, 191EF66820F447D300118C74 /* libFormatter.dylib */, 191EF66A20F447D300118C74 /* FormatterTests.xctest */, 1425EB8721528F8F00009D60 /* libIndexer.dylib */, @@ -1263,7 +1268,6 @@ 1425EBA121528F8F00009D60 /* SwiftierKitTests.xctest */, 1425EBA321528F8F00009D60 /* libSwiftyPluginTest.dylib */, 1425EBA521528F8F00009D60 /* SwiftyPluginTestTests.xctest */, - 149D9288234AA499006FD765 /* Xcode.framework */, ); name = Products; sourceTree = ""; @@ -1799,11 +1803,11 @@ remoteRef = 1425EBA421528F8F00009D60 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 149D9288234AA499006FD765 /* Xcode.framework */ = { + 14D345DE234DC20700054682 /* libCommandLine.dylib */ = { isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = Xcode.framework; - remoteRef = 149D9287234AA499006FD765 /* PBXContainerItemProxy */; + fileType = "compiled.mach-o.dylib"; + path = libCommandLine.dylib; + remoteRef = 14D345DD234DC20700054682 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; 191EF66820F447D300118C74 /* libFormatter.dylib */ = { @@ -2035,6 +2039,7 @@ "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libSourceKittenRequests.dylib", "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libSwiftLexer.dylib", "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libIndexer.dylib", + "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libCommandLine.dylib", ); name = "Manually Sign dylib"; outputFileListPaths = ( @@ -2053,10 +2058,6 @@ inputFileListPaths = ( ); inputPaths = ( - "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/Bocho.framework", - "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/Diagnostic.framework", - "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/Lexer.framework", - "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/Source.framework", "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/SourceKittenFramework.framework", "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/SWXMLHash.framework", "$(SRCROOT)/SwiftToolkit/Frameworks/$(CONFIGURATION)/Yams.framework", @@ -2067,10 +2068,6 @@ outputFileListPaths = ( ); outputPaths = ( - "$(BUILT_PRODUCTS_DIR)/Bocho.framework", - "$(BUILT_PRODUCTS_DIR)/Diagnostic.framework", - "$(BUILT_PRODUCTS_DIR)/Lexer.framework", - "$(BUILT_PRODUCTS_DIR)/Source.framework", "$(BUILT_PRODUCTS_DIR)/SourceKittenFramework.framework", "$(BUILT_PRODUCTS_DIR)/SWXMLHash.framework", "$(BUILT_PRODUCTS_DIR)/Yams.framework", @@ -2098,6 +2095,7 @@ "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libSourceKittenRequests.dylib", "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libSwiftLexer.dylib", "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libIndexer.dylib", + "$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/libCommandLine.dylib", ); name = "Manually Sign dylib"; outputPaths = ( @@ -2675,7 +2673,6 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = HU45578K6L; - ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/lib", @@ -2704,7 +2701,6 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = HU45578K6L; - ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/lib", @@ -2728,11 +2724,11 @@ isa = XCBuildConfiguration; baseConfigurationReference = 191EF6A320F451D000118C74 /* Debug.xcconfig */; buildSettings = { + CODE_SIGN_ENTITLEMENTS = MockGeneratorXPC/MockGeneratorXPC.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = HU45578K6L; - ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/lib", @@ -2755,11 +2751,11 @@ isa = XCBuildConfiguration; baseConfigurationReference = 191EF6A520F451D100118C74 /* Release.xcconfig */; buildSettings = { + CODE_SIGN_ENTITLEMENTS = MockGeneratorXPC/MockGeneratorXPC.entitlements; CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = HU45578K6L; - ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/lib", @@ -3033,7 +3029,6 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = HU45578K6L; - ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/lib", @@ -3057,11 +3052,11 @@ isa = XCBuildConfiguration; baseConfigurationReference = 191EF6A420F451D100118C74 /* Profile.xcconfig */; buildSettings = { + CODE_SIGN_ENTITLEMENTS = MockGeneratorXPC/MockGeneratorXPC.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = HU45578K6L; - ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/lib", diff --git a/MockGenerator/Generator.swift b/MockGenerator/Generator.swift index 612187f..11f4fa9 100644 --- a/MockGenerator/Generator.swift +++ b/MockGenerator/Generator.swift @@ -18,6 +18,7 @@ public class Generator { public init(fromFileContents fileContents: String, projectURL: URL, + platform: String, line: Int, column: Int, templateName: String, @@ -30,7 +31,7 @@ public class Generator { self.useTabsForIndentation = useTabsForIndentation self.indentationWidth = indentationWidth let sourceFiles = SourceFileFinder(projectRoot: projectURL.deletingLastPathComponent()).findSourceFiles() - self.resolver = ResolverFactory.createResolver(filePaths: Generator.filterUniqueFileNames(sourceFiles), projectURL: projectURL) + self.resolver = ResolverFactory.createResolver(filePaths: Generator.filterUniqueFileNames(sourceFiles), platform: platform) } private static func filterUniqueFileNames(_ fileNames: [URL]) -> [String] { diff --git a/MockGeneratorApp/Base.lproj/Main.storyboard b/MockGeneratorApp/Base.lproj/Main.storyboard index d018563..b1deba8 100644 --- a/MockGeneratorApp/Base.lproj/Main.storyboard +++ b/MockGeneratorApp/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -686,23 +686,23 @@ - + - + - + - + - + - + @@ -742,7 +742,7 @@ - + @@ -750,7 +750,7 @@ - + - + @@ -783,10 +783,10 @@ - + - + Select the root folder of your project. The mock generator will scan this directory when you generate a mock. Your data will never be stored or shared. @@ -795,7 +795,7 @@ - + @@ -815,7 +815,7 @@ - + @@ -783,7 +783,7 @@ - + @@ -804,7 +804,7 @@ - + @@ -859,38 +859,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -916,9 +884,6 @@ - - - @@ -927,9 +892,6 @@ - - - @@ -942,7 +904,6 @@ - @@ -957,7 +918,7 @@ - + diff --git a/MockGeneratorApp/PreferencesView.swift b/MockGeneratorApp/PreferencesView.swift index cf5d144..2b068b9 100644 --- a/MockGeneratorApp/PreferencesView.swift +++ b/MockGeneratorApp/PreferencesView.swift @@ -6,7 +6,6 @@ class PreferencesView: NSView { @IBOutlet private var automaticContainer: NSView! @IBOutlet private var automaticPathCheckbox: NSButton! @IBOutlet private var projectPathField: NSTextField! - @IBOutlet private var platformPopUpButton: NSPopUpButton! private let preferences = Preferences() @@ -33,7 +32,6 @@ class PreferencesView: NSView { private func updateView() { automaticPathCheckbox.state = preferences.automaticallyDetectProjectPath ? .on : .off updateContainers() - updatePlatformPopUpButton() } private func updateContainers() { @@ -49,21 +47,4 @@ class PreferencesView: NSView { projectPathField.stringValue = "Cannot find a project. Make sure a project is open in Xcode." } } - - @IBAction private func comboBoxSelectionDidChange(_ sender: Any) { - switch platformPopUpButton.selectedItem?.title { - case "macOS": preferences.platform = "macosx" - case "iOS": preferences.platform = "iphonesimulator" - default: preferences.platform = nil - } - updatePlatformPopUpButton() - } - - private func updatePlatformPopUpButton() { - switch preferences.platform { - case "macosx": platformPopUpButton.selectItem(withTitle: "macOS") - case "iphonesimulator": platformPopUpButton.selectItem(withTitle: "iOS") - default: platformPopUpButton.selectItem(at: -1) - } - } } diff --git a/MockGeneratorAppTests/PreferencesTests.swift b/MockGeneratorAppTests/PreferencesTests.swift index 2985d03..867438d 100644 --- a/MockGeneratorAppTests/PreferencesTests.swift +++ b/MockGeneratorAppTests/PreferencesTests.swift @@ -75,23 +75,4 @@ class PreferencesTests: XCTestCase { preferences.automaticallyDetectProjectPath = true XCTAssert(preferences.automaticallyDetectProjectPath) } - - // MARK: - platform - - func testPlatformIsNilByDefault() { - XCTAssertNil(preferences.platform) - } - - func testPlatformShouldChangeValue() { - preferences.platform = "macosx" - XCTAssertEqual(preferences.platform, "macosx") - preferences.platform = "iphonesimulator" - XCTAssertEqual(preferences.platform, "iphonesimulator") - } - - func testPlatformRemovesKeyWhenSettingToNil() { - preferences.platform = "macosx" - preferences.platform = nil - XCTAssertNil(preferences.platform) - } } diff --git a/MockGeneratorXPC/MockGeneratorXPC.swift b/MockGeneratorXPC/MockGeneratorXPC.swift index 7e94f58..721379f 100644 --- a/MockGeneratorXPC/MockGeneratorXPC.swift +++ b/MockGeneratorXPC/MockGeneratorXPC.swift @@ -6,7 +6,6 @@ import MockGenerator func generateMock(from model: XPCMockGeneratorModel, withReply reply: @escaping (XPCBufferInstructions?, Error?) -> ()) { let (instructions, error) = Generator(fromFileContents: model.contents, projectURL: model.projectURL, - platform: model.platform, line: model.line, column: model.column, templateName: model.templateName, diff --git a/MockGeneratorXPC/XPCMockGeneratorModel.swift b/MockGeneratorXPC/XPCMockGeneratorModel.swift index 3d6e3e0..bba60bb 100644 --- a/MockGeneratorXPC/XPCMockGeneratorModel.swift +++ b/MockGeneratorXPC/XPCMockGeneratorModel.swift @@ -4,7 +4,6 @@ import Foundation let contents: String let projectURL: URL - let platform: String let line: Int let column: Int let templateName: String @@ -17,7 +16,6 @@ import Foundation init(contents: String, projectURL: URL, - platform: String, line: Int, column: Int, templateName: String, @@ -25,7 +23,6 @@ import Foundation indentationWidth: Int) { self.contents = contents self.projectURL = projectURL - self.platform = platform self.line = line self.column = column self.templateName = templateName @@ -36,7 +33,6 @@ import Foundation required init?(coder aDecoder: NSCoder) { guard let contents = aDecoder.decodeObject(of: NSString.self, forKey: "contents"), let projectURL = aDecoder.decodeObject(of: NSURL.self, forKey: "projectURL"), - let platform = aDecoder.decodeObject(of: NSString.self, forKey: "platform"), let line = aDecoder.decodeObject(of: NSNumber.self, forKey: "line"), let column = aDecoder.decodeObject(of: NSNumber.self, forKey: "column"), let templateName = aDecoder.decodeObject(of: NSString.self, forKey: "templateName"), @@ -46,7 +42,6 @@ import Foundation } self.contents = contents as String self.projectURL = projectURL as URL - self.platform = platform as String self.line = line.intValue self.column = column.intValue self.templateName = templateName as String @@ -57,7 +52,6 @@ import Foundation func encode(with aCoder: NSCoder) { aCoder.encode(contents as NSString, forKey: "contents") aCoder.encode(projectURL as NSURL, forKey: "projectURL") - aCoder.encode(platform as NSString, forKey: "platform") aCoder.encode(line as NSNumber, forKey: "line") aCoder.encode(column as NSNumber, forKey: "column") aCoder.encode(templateName as NSString, forKey: "templateName") diff --git a/MockGeneratorXPC/main.m b/MockGeneratorXPC/main.m index ad58c46..0ad23d9 100644 --- a/MockGeneratorXPC/main.m +++ b/MockGeneratorXPC/main.m @@ -28,7 +28,6 @@ - (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConne int main(int argc, const char *argv[]) { - [Analytics initCrashlytics]; // Create the delegate for the service. ServiceDelegate *delegate = [ServiceDelegate new]; diff --git a/Shared/Analytics.swift b/Shared/Analytics.swift deleted file mode 100644 index 341fbc6..0000000 --- a/Shared/Analytics.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation - -public class Analytics: NSObject { - - @objc public static func initCrashlytics() { - } - - public static func track(_ name: String, attributes: [String: Any]) { - } -} diff --git a/Shared/Preferences.swift b/Shared/Preferences.swift index 0f6d097..20629ec 100644 --- a/Shared/Preferences.swift +++ b/Shared/Preferences.swift @@ -15,7 +15,7 @@ class Preferences { private let automaticallyDetectProjectPathKey = "project.path.autoDetect" private let sdkPathKey = "sdk.path" // This was once used private let moduleCachePathKey = "moduleCache.path" // This was once used - private let platformKey = "platform" + private let platformKey = "platform" // This was once used init(userDefaults: UserDefaults = UserDefaults(suiteName: "group.codes.seanhenry.MockGenerator")!) { self.userDefaults = userDefaults @@ -62,18 +62,4 @@ class Preferences { return userDefaults.object(forKey: automaticallyDetectProjectPathKey) as? Bool ?? true } } - - var platform: String? { - set { - if let value = newValue { - userDefaults.set(value, forKey: platformKey) - } else { - userDefaults.removeObject(forKey: platformKey) - } - userDefaults.synchronize() - } - get { - return userDefaults.string(forKey: platformKey) - } - } } diff --git a/XcodePlugin/BaseCommand.swift b/XcodePlugin/BaseCommand.swift index dfe14c8..9193841 100644 --- a/XcodePlugin/BaseCommand.swift +++ b/XcodePlugin/BaseCommand.swift @@ -86,7 +86,6 @@ open class BaseCommand: NSObject, XCSourceEditorCommand { let model = XPCMockGeneratorModel( contents: invocation.sourceTextBuffer.completeBuffer, projectURL: projectURL, - platform: try getPlatform(), line: range.start.line, column: range.start.column, templateName: templateName, @@ -127,7 +126,6 @@ open class BaseCommand: NSObject, XCSourceEditorCommand { let tracker = GoogleAnalyticsTracker() if let insertCount = instructions?.linesToInsert.count { tracker.track(category: templateName, action: "generated", value: insertCount) - Analytics.track(templateName, attributes: ["lines": insertCount]) } } @@ -136,18 +134,10 @@ open class BaseCommand: NSObject, XCSourceEditorCommand { if let error = error { let version = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String tracker.track(category: templateName, action: "\(version)_\(error.localizedDescription)") - Analytics.track("error", attributes: ["version": version, "description": error.localizedDescription]) } } private func createError(_ message: String) -> Error { return NSError(domain: "codes.seanhenry.mockgenerator", code: 0, userInfo: [NSLocalizedDescriptionKey: message]) } - - private func getPlatform() throws -> String { - guard let platform = Preferences().platform else { - throw createError("No platform has been selected. Choose one in the companion app.") - } - return platform - } } diff --git a/XcodePlugin/SourceEditorExtension.swift b/XcodePlugin/SourceEditorExtension.swift index 973b42a..453d6e4 100644 --- a/XcodePlugin/SourceEditorExtension.swift +++ b/XcodePlugin/SourceEditorExtension.swift @@ -6,7 +6,6 @@ import XcodePluginProxy class SourceEditorExtension: NSObject, XCSourceEditorExtension { func extensionDidFinishLaunching() { - Analytics.initCrashlytics() XPCManager.setUpConnection() } } From f57cd2d16de48d9fba95dedc3b3428a672569eab Mon Sep 17 00:00:00 2001 From: Sean Henry Date: Mon, 21 Oct 2019 22:28:00 +0100 Subject: [PATCH 9/9] Removes unused code --- EndToEndTests/EndToEndTests.swift | 11 ------- MockGenerator.xcodeproj/project.pbxproj | 33 ------------------- .../MemberTransformingVisitorTests.swift | 2 +- MockGeneratorTests/MockGeneratorTests.swift | 3 +- ...eDeclarationTransformingVisitorTests.swift | 2 +- .../VariableTypeResolverTests.swift | 2 +- MockGeneratorXPC/MockGeneratorXPC.swift | 6 ---- MockGeneratorXPC/MockGeneratorXPCProtocol.h | 6 ---- config/Debug.xcconfig | 2 +- config/Profile.xcconfig | 2 +- config/Release.xcconfig | 2 +- 11 files changed, 7 insertions(+), 64 deletions(-) diff --git a/EndToEndTests/EndToEndTests.swift b/EndToEndTests/EndToEndTests.swift index 9c7a3bc..b27300b 100644 --- a/EndToEndTests/EndToEndTests.swift +++ b/EndToEndTests/EndToEndTests.swift @@ -3,11 +3,6 @@ import XCTest class EndToEndTests: MockGeneratorBaseTestCase { - override func setUp() { - super.setUp() - Preferences().platform = "macosx" - } - func test_generatesSimpleMock() { assertMockGeneratesExpected("SimpleProtocolMock") } @@ -164,12 +159,6 @@ class EndToEndTests: MockGeneratorBaseTestCase { assertMockGeneratesExpected("AugmentedClassSubscriptMock") } - func test_returnsErrorWhenPlatformIsNil() { - let preferences = Preferences() - preferences.platform = nil - assertMockGeneratesError(fileName: "SimpleProtocolMock", "No platform has been selected. Choose one in the companion app.") - } - func test_returnsErrorWhenProjectURLDoesNotExist() { let preferences = Preferences() preferences.automaticallyDetectProjectPath = false diff --git a/MockGenerator.xcodeproj/project.pbxproj b/MockGenerator.xcodeproj/project.pbxproj index 38e98e7..209fab2 100644 --- a/MockGenerator.xcodeproj/project.pbxproj +++ b/MockGenerator.xcodeproj/project.pbxproj @@ -42,17 +42,10 @@ 142B0213216FA39E005DE573 /* libIndexer.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 1425EB8721528F8F00009D60 /* libIndexer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 142B0214216FA39E005DE573 /* libParser.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975020EEFA12009A5FD6 /* libParser.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 142B0215216FA39E005DE573 /* libResolver.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975420EEFA12009A5FD6 /* libResolver.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 142B0216216FA39E005DE573 /* libSourceKittenRequests.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975820EEFA12009A5FD6 /* libSourceKittenRequests.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 142B0217216FA39E005DE573 /* libSwiftLexer.dylib in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 142B0218216FA3A7005DE573 /* MockGenerator.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 14276C611F4F312E00EA7753 /* MockGenerator.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142B022A21709979005DE573 /* SourceKittenFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 142B02252170994B005DE573 /* SourceKittenFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142B022B21709979005DE573 /* SWXMLHash.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 142B02222170994A005DE573 /* SWXMLHash.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142B022C21709979005DE573 /* Yams.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 142B02242170994B005DE573 /* Yams.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 142B023021709A97005DE573 /* UseCases.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 142B022F21709A85005DE573 /* UseCases.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 142B023121709AFF005DE573 /* UseCases.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 142B022F21709A85005DE573 /* UseCases.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142B023621709AFF005DE573 /* SourceKittenFramework.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 142B02252170994B005DE573 /* SourceKittenFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142B023721709B00005DE573 /* SWXMLHash.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 142B02222170994A005DE573 /* SWXMLHash.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142B023821709B00005DE573 /* Yams.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 142B02242170994B005DE573 /* Yams.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 142B023A21709BFB005DE573 /* libGRMustache7-MacOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 142B023921709BC5005DE573 /* libGRMustache7-MacOS.a */; }; 14354103232E4FF80019615B /* Lexer in Frameworks */ = {isa = PBXBuildFile; productRef = 14354102232E4FF80019615B /* Lexer */; }; 14354104232E4FF80019615B /* Lexer in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 14354102232E4FF80019615B /* Lexer */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -73,7 +66,6 @@ 1497FE7E215E147200CD670B /* libIndexer.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1425EB8721528F8F00009D60 /* libIndexer.dylib */; }; 1497FE7F215E147200CD670B /* libParser.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975020EEFA12009A5FD6 /* libParser.dylib */; }; 1497FE80215E147200CD670B /* libResolver.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975420EEFA12009A5FD6 /* libResolver.dylib */; }; - 1497FE81215E147200CD670B /* libSourceKittenRequests.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975820EEFA12009A5FD6 /* libSourceKittenRequests.dylib */; }; 1497FE82215E147200CD670B /* libSwiftLexer.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */; }; 1497FEC8215E200100CD670B /* libAlgorithms.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F974C20EEFA12009A5FD6 /* libAlgorithms.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1497FEC9215E200100CD670B /* libAST.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F974020EEFA12009A5FD6 /* libAST.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -84,7 +76,6 @@ 1497FECE215E200100CD670B /* libIndexer.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1425EB8721528F8F00009D60 /* libIndexer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1497FECF215E200100CD670B /* libParser.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975020EEFA12009A5FD6 /* libParser.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1497FED0215E200100CD670B /* libResolver.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975420EEFA12009A5FD6 /* libResolver.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - 1497FED1215E200100CD670B /* libSourceKittenRequests.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975820EEFA12009A5FD6 /* libSourceKittenRequests.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 1497FED2215E200100CD670B /* libSwiftLexer.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 149CF7B3217B115B005892B4 /* partial.mustache in Resources */ = {isa = PBXBuildFile; fileRef = 149CF792217B115A005892B4 /* partial.mustache */; }; 149CF7B5217B1301005892B4 /* PartialSpyCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149CF7B4217B1301005892B4 /* PartialSpyCommand.swift */; }; @@ -516,13 +507,6 @@ remoteGlobalIDString = 19821CE020EE2C260084C6C1; remoteInfo = ResolverTests; }; - 196F975720EEFA12009A5FD6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 196F972C20EEFA12009A5FD6 /* SwiftToolkit.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 19821D1E20EE2C5D0084C6C1; - remoteInfo = SourceKittenRequests; - }; 196F975920EEFA12009A5FD6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 196F972C20EEFA12009A5FD6 /* SwiftToolkit.xcodeproj */; @@ -634,9 +618,6 @@ files = ( 14D345DF234DC20700054682 /* libCommandLine.dylib in Embed Frameworks */, 142B023021709A97005DE573 /* UseCases.framework in Embed Frameworks */, - 142B022A21709979005DE573 /* SourceKittenFramework.framework in Embed Frameworks */, - 142B022B21709979005DE573 /* SWXMLHash.framework in Embed Frameworks */, - 142B022C21709979005DE573 /* Yams.framework in Embed Frameworks */, 1497FEC8215E200100CD670B /* libAlgorithms.dylib in Embed Frameworks */, 14354104232E4FF80019615B /* Lexer in Embed Frameworks */, 1497FEC9215E200100CD670B /* libAST.dylib in Embed Frameworks */, @@ -647,7 +628,6 @@ 1497FECE215E200100CD670B /* libIndexer.dylib in Embed Frameworks */, 1497FECF215E200100CD670B /* libParser.dylib in Embed Frameworks */, 1497FED0215E200100CD670B /* libResolver.dylib in Embed Frameworks */, - 1497FED1215E200100CD670B /* libSourceKittenRequests.dylib in Embed Frameworks */, 1497FED2215E200100CD670B /* libSwiftLexer.dylib in Embed Frameworks */, 14887ABC20FB859B00D50A73 /* MockGenerator.framework in Embed Frameworks */, ); @@ -703,9 +683,6 @@ files = ( 1485244A234E5B19007F3D26 /* libCommandLine.dylib in Copy Frameworks */, 142B023121709AFF005DE573 /* UseCases.framework in Copy Frameworks */, - 142B023621709AFF005DE573 /* SourceKittenFramework.framework in Copy Frameworks */, - 142B023721709B00005DE573 /* SWXMLHash.framework in Copy Frameworks */, - 142B023821709B00005DE573 /* Yams.framework in Copy Frameworks */, 142B0218216FA3A7005DE573 /* MockGenerator.framework in Copy Frameworks */, 1435412B232E50610019615B /* Lexer in Copy Frameworks */, 142B020D216FA39E005DE573 /* libAlgorithms.dylib in Copy Frameworks */, @@ -717,7 +694,6 @@ 142B0213216FA39E005DE573 /* libIndexer.dylib in Copy Frameworks */, 142B0214216FA39E005DE573 /* libParser.dylib in Copy Frameworks */, 142B0215216FA39E005DE573 /* libResolver.dylib in Copy Frameworks */, - 142B0216216FA39E005DE573 /* libSourceKittenRequests.dylib in Copy Frameworks */, 142B0217216FA39E005DE573 /* libSwiftLexer.dylib in Copy Frameworks */, ); name = "Copy Frameworks"; @@ -885,7 +861,6 @@ 1497FE7E215E147200CD670B /* libIndexer.dylib in Frameworks */, 1497FE7F215E147200CD670B /* libParser.dylib in Frameworks */, 1497FE80215E147200CD670B /* libResolver.dylib in Frameworks */, - 1497FE81215E147200CD670B /* libSourceKittenRequests.dylib in Frameworks */, 1497FE82215E147200CD670B /* libSwiftLexer.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1227,7 +1202,6 @@ 196F975420EEFA12009A5FD6 /* libResolver.dylib */, 196F975620EEFA12009A5FD6 /* ResolverTests.xctest */, 1425EB8D21528F8F00009D60 /* ResolverPerfTests.xctest */, - 196F975820EEFA12009A5FD6 /* libSourceKittenRequests.dylib */, 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */, 196F975C20EEFA12009A5FD6 /* SwiftLexerTests.xctest */, 196F975E20EEFA12009A5FD6 /* libTestHelper.dylib */, @@ -1887,13 +1861,6 @@ remoteRef = 196F975520EEFA12009A5FD6 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 196F975820EEFA12009A5FD6 /* libSourceKittenRequests.dylib */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libSourceKittenRequests.dylib; - remoteRef = 196F975720EEFA12009A5FD6 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 196F975A20EEFA12009A5FD6 /* libSwiftLexer.dylib */ = { isa = PBXReferenceProxy; fileType = archive.ar; diff --git a/MockGeneratorTests/MemberTransformingVisitorTests.swift b/MockGeneratorTests/MemberTransformingVisitorTests.swift index 11578c5..c1d998a 100644 --- a/MockGeneratorTests/MemberTransformingVisitorTests.swift +++ b/MockGeneratorTests/MemberTransformingVisitorTests.swift @@ -13,7 +13,7 @@ class MemberTransformingVisitorTests: XCTestCase { override func setUp() { super.setUp() - resolver = ResolverFactory.createResolver(filePaths: [], platform: "macosx") + resolver = ResolverFactory.createResolver(filePaths: []) visitor = MemberTransformingVisitor(resolver: resolver) } diff --git a/MockGeneratorTests/MockGeneratorTests.swift b/MockGeneratorTests/MockGeneratorTests.swift index bbd9636..f5f04ec 100644 --- a/MockGeneratorTests/MockGeneratorTests.swift +++ b/MockGeneratorTests/MockGeneratorTests.swift @@ -227,7 +227,7 @@ class MockGeneratorTests: XCTestCase { } while contentsLineColumn.lineColumn != nil XCTAssertGreaterThan(caretLineColumns.count, 0) caretLineColumns.forEach { lineColumn in - let (lines, error) = Generator(fromFileContents: contentsLineColumn.contents, projectURL: URL(fileURLWithPath: testProject), platform: "macosx", line: lineColumn.line, column: lineColumn.column, templateName: "spy", useTabsForIndentation: false, indentationWidth: 4).generateMock() + let (lines, error) = Generator(fromFileContents: contentsLineColumn.contents, projectURL: URL(fileURLWithPath: testProject), line: lineColumn.line, column: lineColumn.column, templateName: "spy", useTabsForIndentation: false, indentationWidth: 4).generateMock() XCTAssertNotNil(error, "Should not be generating a mock from caret at line: \(lineColumn.line) column: \(lineColumn.column)") XCTAssertNil(lines) } @@ -276,7 +276,6 @@ class MockGeneratorTests: XCTestCase { let result = CaretTestHelper.findCaretLineColumn(mock) let (instructions, error) = Generator(fromFileContents: result.contents, projectURL: URL(fileURLWithPath: testProject), - platform: "macosx", line: result.lineColumn!.line, column: result.lineColumn!.column, templateName: templateName, diff --git a/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift b/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift index 528609c..3c22932 100644 --- a/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift +++ b/MockGeneratorTests/TypeDeclarationTransformingVisitorTests.swift @@ -12,7 +12,7 @@ class TypeDeclarationTransformingVisitorTests: XCTestCase { override func setUp() { super.setUp() - resolver = ResolverFactory.createResolver(filePaths: [], platform: "macosx") + resolver = ResolverFactory.createResolver(filePaths: []) } override func tearDown() { diff --git a/MockGeneratorTests/VariableTypeResolverTests.swift b/MockGeneratorTests/VariableTypeResolverTests.swift index 037de87..59954a7 100644 --- a/MockGeneratorTests/VariableTypeResolverTests.swift +++ b/MockGeneratorTests/VariableTypeResolverTests.swift @@ -143,7 +143,7 @@ class VariableTypeResolverTests: XCTestCase { struct StructType {} enum EnumType {} """ - return VariableTypeResolver.resolve(try parse(fullText), resolver: ResolverFactory.createResolver(filePaths: [], platform: "macosx")) + return VariableTypeResolver.resolve(try parse(fullText), resolver: ResolverFactory.createResolver(filePaths: [])) } private func parse(_ text: String) throws -> Element { diff --git a/MockGeneratorXPC/MockGeneratorXPC.swift b/MockGeneratorXPC/MockGeneratorXPC.swift index 721379f..8f324ab 100644 --- a/MockGeneratorXPC/MockGeneratorXPC.swift +++ b/MockGeneratorXPC/MockGeneratorXPC.swift @@ -20,10 +20,4 @@ import MockGenerator } reply(transformed, error) } - - #if DEBUG - func crash() { - fatalError() - } - #endif } diff --git a/MockGeneratorXPC/MockGeneratorXPCProtocol.h b/MockGeneratorXPC/MockGeneratorXPCProtocol.h index a713454..b590778 100644 --- a/MockGeneratorXPC/MockGeneratorXPCProtocol.h +++ b/MockGeneratorXPC/MockGeneratorXPCProtocol.h @@ -9,12 +9,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)generateMockFrom:(XPCMockGeneratorModel *)model withReply:(void (^)(XPCBufferInstructions *_Nullable, NSError *_Nullable))reply; -#ifdef DEBUG - -- (void)crash; - -#endif - NS_ASSUME_NONNULL_END @end diff --git a/config/Debug.xcconfig b/config/Debug.xcconfig index 0f31992..117b6f9 100644 --- a/config/Debug.xcconfig +++ b/config/Debug.xcconfig @@ -1,7 +1,7 @@ #include "../SwiftToolkit/config/Debug.xcconfig" #include "Shared.xcconfig" -FRAMEWORK_SEARCH_PATHS = $DEVELOPER_FRAMEWORKS_DIR $PROJECT_DIR/SwiftToolkit/Frameworks/Debug $PROJECT_DIR/lib/Debug +FRAMEWORK_SEARCH_PATHS = $DEVELOPER_FRAMEWORKS_DIR $PROJECT_DIR/lib/Debug HEADER_SEARCH_PATHS = $PROJECT_DIR/lib/Debug/include/GRMustache LIBRARY_SEARCH_PATHS = $PROJECT_DIR/lib/Debug OTHER_SWIFT_FLAGS = -Xcc -fmodule-map-file=$PROJECT_DIR/lib/Debug/include/GRMustache/module.modulemap diff --git a/config/Profile.xcconfig b/config/Profile.xcconfig index 131ec41..ac500c5 100644 --- a/config/Profile.xcconfig +++ b/config/Profile.xcconfig @@ -1,7 +1,7 @@ #include "../SwiftToolkit/config/Profile.xcconfig" #include "Shared.xcconfig" -FRAMEWORK_SEARCH_PATHS = $DEVELOPER_FRAMEWORKS_DIR $PROJECT_DIR/SwiftToolkit/Frameworks/Release $PROJECT_DIR/lib/Release +FRAMEWORK_SEARCH_PATHS = $DEVELOPER_FRAMEWORKS_DIR $PROJECT_DIR/lib/Release HEADER_SEARCH_PATHS = $PROJECT_DIR/lib/Release/include/GRMustache LIBRARY_SEARCH_PATHS = $PROJECT_DIR/lib/Release OTHER_SWIFT_FLAGS = -Xcc -fmodule-map-file=$PROJECT_DIR/lib/Release/include/GRMustache/module.modulemap diff --git a/config/Release.xcconfig b/config/Release.xcconfig index 2ffc18c..eca1352 100644 --- a/config/Release.xcconfig +++ b/config/Release.xcconfig @@ -1,7 +1,7 @@ #include "../SwiftToolkit/config/Release.xcconfig" #include "Shared.xcconfig" -FRAMEWORK_SEARCH_PATHS = $DEVELOPER_FRAMEWORKS_DIR $PROJECT_DIR/SwiftToolkit/Frameworks/Release $PROJECT_DIR/lib/Release +FRAMEWORK_SEARCH_PATHS = $DEVELOPER_FRAMEWORKS_DIR $PROJECT_DIR/lib/Release HEADER_SEARCH_PATHS = $PROJECT_DIR/lib/Release/include/GRMustache LIBRARY_SEARCH_PATHS = $PROJECT_DIR/lib/Release OTHER_SWIFT_FLAGS = -Xcc -fmodule-map-file=$PROJECT_DIR/lib/Release/include/GRMustache/module.modulemap