diff --git a/ACCodeSnippetRepository Tests/ACCodeSnippetGitDataStoreTests.m b/ACCodeSnippetRepository Tests/ACCodeSnippetGitDataStoreTests.m index a5adfdc..4a2a2b7 100644 --- a/ACCodeSnippetRepository Tests/ACCodeSnippetGitDataStoreTests.m +++ b/ACCodeSnippetRepository Tests/ACCodeSnippetGitDataStoreTests.m @@ -6,11 +6,11 @@ // Copyright (c) 2014 Arnaud Coomans. All rights reserved. // -#import +#import #import "ACCodeSnippetGitDataStore.h" -@interface ACCodeSnippetGitDataStoreTests : SenTestCase +@interface ACCodeSnippetGitDataStoreTests : XCTestCase @end @implementation ACCodeSnippetGitDataStoreTests diff --git a/ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist b/ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist index 17c7d4b..169b6f7 100644 --- a/ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist +++ b/ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.acoomans.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/ACCodeSnippetRepository Tests/ACCodeSnippetSerializationTests.m b/ACCodeSnippetRepository Tests/ACCodeSnippetSerializationTests.m index 1036ef4..fac0972 100644 --- a/ACCodeSnippetRepository Tests/ACCodeSnippetSerializationTests.m +++ b/ACCodeSnippetRepository Tests/ACCodeSnippetSerializationTests.m @@ -6,10 +6,10 @@ // Copyright (c) 2014 Arnaud Coomans. All rights reserved. // -#import +#import #import "ACCodeSnippetSerialization.h" -@interface ACCodeSnippetSerializationTests : SenTestCase +@interface ACCodeSnippetSerializationTests : XCTestCase @end @implementation ACCodeSnippetSerializationTests @@ -31,14 +31,14 @@ - (void)testSerialize { NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"\n%@", string); - STAssertTrue([string rangeOfString:@"title"].location != NSNotFound, nil); - STAssertTrue([string rangeOfString:@"summary"].location != NSNotFound, nil); - STAssertTrue([string rangeOfString:@"line1\nline2\nline3"].location != NSNotFound, nil); - STAssertTrue([string rangeOfString:@"WhateverKey"].location != NSNotFound, nil); - STAssertTrue([string rangeOfString:@"WhateverValue"].location != NSNotFound, nil); + XCTAssertTrue([string rangeOfString:@"title"].location != NSNotFound); + XCTAssertTrue([string rangeOfString:@"summary"].location != NSNotFound); + XCTAssertTrue([string rangeOfString:@"line1\nline2\nline3"].location != NSNotFound); + XCTAssertTrue([string rangeOfString:@"WhateverKey"].location != NSNotFound); + XCTAssertTrue([string rangeOfString:@"WhateverValue"].location != NSNotFound); - STAssertTrue([string rangeOfString:@"one"].location != NSNotFound, nil); - STAssertTrue([string rangeOfString:@"two"].location != NSNotFound, nil); + XCTAssertTrue([string rangeOfString:@"one"].location != NSNotFound); + XCTAssertTrue([string rangeOfString:@"two"].location != NSNotFound); } - (void)testDeserialize { @@ -50,13 +50,13 @@ - (void)testDeserialize { error:nil]; NSLog(@"\n%@", dict); - STAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"], nil); - STAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"], nil); - STAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"], nil); - STAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"], nil); + XCTAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"]); + XCTAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"]); + XCTAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"]); + XCTAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"]); NSArray *a = @[@"one", @"two"]; - STAssertTrue([dict[@"Array"] isEqualToArray:a], nil); + XCTAssertTrue([dict[@"Array"] isEqualToArray:a]); } - (void)testDeserialize2 { @@ -68,13 +68,13 @@ - (void)testDeserialize2 { error:nil]; NSLog(@"\n%@", dict); - STAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"], nil); - STAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"], nil); - STAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"], nil); - STAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"], nil); + XCTAssertTrue([dict[ACCodeSnippetTitleKey] isEqualToString:@"title"]); + XCTAssertTrue([dict[ACCodeSnippetSummaryKey] isEqualToString:@"summary"]); + XCTAssertTrue([dict[ACCodeSnippetContentsKey] isEqualToString:@"line1\nline2\nline3\n"]); + XCTAssertTrue([dict[@"WhateverKey"] isEqualToString:@"WhateverValue"]); NSArray *a = @[@"one", @"two"]; - STAssertTrue([dict[@"Array"] isEqualToArray:a], nil); + XCTAssertTrue([dict[@"Array"] isEqualToArray:a]); } - (void)testSerializeDeserialize { @@ -96,7 +96,7 @@ - (void)testSerializeDeserialize { options:0 format:ACCodeSnippetSerializationFormatC error:nil]; - STAssertTrue([dict1 isEqualToDictionary:dict2], nil); + XCTAssertTrue([dict1 isEqualToDictionary:dict2]); } diff --git a/ACCodeSnippetRepository Tests/ACGitRepositoryTests.m b/ACCodeSnippetRepository Tests/ACGitRepositoryTests.m index 01c7061..5e527fc 100644 --- a/ACCodeSnippetRepository Tests/ACGitRepositoryTests.m +++ b/ACCodeSnippetRepository Tests/ACGitRepositoryTests.m @@ -6,10 +6,10 @@ // Copyright (c) 2014 Arnaud Coomans. All rights reserved. // -#import +#import #import "ACGitRepository.h" -@interface ACGitRepositoryTests : SenTestCase +@interface ACGitRepositoryTests : XCTestCase @end @implementation ACGitRepositoryTests @@ -23,7 +23,7 @@ - (void)testExample { ACGitRepository *git = [[ACGitRepository alloc] initWithLocalRepositoryDirectory:gitPath]; - //[git forkRemoteRepositoryWithURL:gitURL inDirectory:gitPath]; + //[git cloneRemoteRepositoryWithURL:gitURL inDirectory:gitPath]; //[git removeLocalRepository]; //NSLog(@"%@", [git identifierForCurrentCommit]); //NSLog(@"%@", [git changedFilesSinceCommitWithIdentifier:@"HEAD~6"]); diff --git a/ACCodeSnippetRepository Tests/NSDictionary+MergeTests.m b/ACCodeSnippetRepository Tests/NSDictionary+MergeTests.m index f8137c0..161d0ab 100644 --- a/ACCodeSnippetRepository Tests/NSDictionary+MergeTests.m +++ b/ACCodeSnippetRepository Tests/NSDictionary+MergeTests.m @@ -6,10 +6,10 @@ // Copyright (c) 2014 Arnaud Coomans. All rights reserved. // -#import +#import #import "NSDictionary+Merge.h" -@interface NSDictionary_MergeTests : SenTestCase +@interface NSDictionary_MergeTests : XCTestCase @end @implementation NSDictionary_MergeTests @@ -25,9 +25,9 @@ - (void)testExample { @"c": @"c" }]; - STAssertTrue([r[@"a"] isEqualToString:@"a"], nil); - STAssertTrue([r[@"b"] isEqualToString:@"b"], nil); - STAssertTrue([r[@"c"] isEqualToString:@"c"], nil); + XCTAssertTrue([r[@"a"] isEqualToString:@"a"]); + XCTAssertTrue([r[@"b"] isEqualToString:@"b"]); + XCTAssertTrue([r[@"c"] isEqualToString:@"c"]); } @end diff --git a/ACCodeSnippetRepository.xcodeproj/project.pbxproj b/ACCodeSnippetRepository.xcodeproj/project.pbxproj index b052723..a1a6a3d 100644 --- a/ACCodeSnippetRepository.xcodeproj/project.pbxproj +++ b/ACCodeSnippetRepository.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 012836131B11EC41007236B8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 012836121B11EC41007236B8 /* Images.xcassets */; }; + 012836141B11EC41007236B8 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 012836121B11EC41007236B8 /* Images.xcassets */; }; 51010E0218AC5CB1000AA1F1 /* ACGitRepository.m in Sources */ = {isa = PBXBuildFile; fileRef = 51010E0118AC5CB1000AA1F1 /* ACGitRepository.m */; }; 51010E0318AC5CB1000AA1F1 /* ACGitRepository.m in Sources */ = {isa = PBXBuildFile; fileRef = 51010E0118AC5CB1000AA1F1 /* ACGitRepository.m */; }; 5105B22718AC59520066728E /* NSTask+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = 5105B22618AC59520066728E /* NSTask+Extras.m */; }; @@ -16,11 +18,7 @@ 5153BAA918B3406D00C1E75B /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 5153BAA818B3406D00C1E75B /* NSDictionary+Merge.m */; }; 5153BAAA18B3406D00C1E75B /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 5153BAA818B3406D00C1E75B /* NSDictionary+Merge.m */; }; 5153BAAC18B3410C00C1E75B /* NSDictionary+MergeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5153BAAB18B3410C00C1E75B /* NSDictionary+MergeTests.m */; }; - 5154068518AC4B500065CA33 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5154068418AC4B500065CA33 /* SenTestingKit.framework */; }; 5154068B18AC4B500065CA33 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5154068918AC4B500065CA33 /* InfoPlist.strings */; }; - 515CE9DA18B1DCAA000962EA /* GitHub-Mark-120px-plus.png in Resources */ = {isa = PBXBuildFile; fileRef = 515CE9D718B1DCAA000962EA /* GitHub-Mark-120px-plus.png */; }; - 515CE9DB18B1DCAA000962EA /* GitHub-Mark-32px.png in Resources */ = {isa = PBXBuildFile; fileRef = 515CE9D818B1DCAA000962EA /* GitHub-Mark-32px.png */; }; - 515CE9DC18B1DCAA000962EA /* GitHub-Mark-64px.png in Resources */ = {isa = PBXBuildFile; fileRef = 515CE9D918B1DCAA000962EA /* GitHub-Mark-64px.png */; }; 5162AC2A18AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5162AC2818AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.m */; }; 5162AC2B18AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5162AC2918AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.xib */; }; 517DF2A618AC4BF1008980B3 /* IDECodeSnippetRepositorySwizzler.m in Sources */ = {isa = PBXBuildFile; fileRef = 517DF2A318AC4BF1008980B3 /* IDECodeSnippetRepositorySwizzler.m */; }; @@ -51,6 +49,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 012836121B11EC41007236B8 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 51010E0018AC5CB1000AA1F1 /* ACGitRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACGitRepository.h; sourceTree = ""; }; 51010E0118AC5CB1000AA1F1 /* ACGitRepository.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACGitRepository.m; sourceTree = ""; }; 5105B22518AC59520066728E /* NSTask+Extras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTask+Extras.h"; sourceTree = ""; }; @@ -60,14 +59,10 @@ 5153BAA718B3406D00C1E75B /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+Merge.h"; sourceTree = ""; }; 5153BAA818B3406D00C1E75B /* NSDictionary+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+Merge.m"; sourceTree = ""; }; 5153BAAB18B3410C00C1E75B /* NSDictionary+MergeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+MergeTests.m"; sourceTree = ""; }; - 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ACCodeSnippetRepository Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 5154068418AC4B500065CA33 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ACCodeSnippetRepository Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 5154068818AC4B500065CA33 /* ACCodeSnippetRepository Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ACCodeSnippetRepository Tests-Info.plist"; sourceTree = ""; }; 5154068A18AC4B500065CA33 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 5154068E18AC4B500065CA33 /* ACCodeSnippetRepository Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ACCodeSnippetRepository Tests-Prefix.pch"; sourceTree = ""; }; - 515CE9D718B1DCAA000962EA /* GitHub-Mark-120px-plus.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GitHub-Mark-120px-plus.png"; sourceTree = ""; }; - 515CE9D818B1DCAA000962EA /* GitHub-Mark-32px.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GitHub-Mark-32px.png"; sourceTree = ""; }; - 515CE9D918B1DCAA000962EA /* GitHub-Mark-64px.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GitHub-Mark-64px.png"; sourceTree = ""; }; 5162AC2718AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ACCodeSnippetRepositoryConfigurationWindowController.h; sourceTree = ""; }; 5162AC2818AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ACCodeSnippetRepositoryConfigurationWindowController.m; sourceTree = ""; }; 5162AC2918AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ACCodeSnippetRepositoryConfigurationWindowController.xib; sourceTree = ""; }; @@ -104,7 +99,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5154068518AC4B500065CA33 /* SenTestingKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -145,21 +139,11 @@ 515CE9D518B1DCAA000962EA /* Resources */ = { isa = PBXGroup; children = ( - 515CE9D618B1DCAA000962EA /* Images */, + 012836121B11EC41007236B8 /* Images.xcassets */, ); path = Resources; sourceTree = ""; }; - 515CE9D618B1DCAA000962EA /* Images */ = { - isa = PBXGroup; - children = ( - 515CE9D718B1DCAA000962EA /* GitHub-Mark-120px-plus.png */, - 515CE9D818B1DCAA000962EA /* GitHub-Mark-32px.png */, - 515CE9D918B1DCAA000962EA /* GitHub-Mark-64px.png */, - ); - path = Images; - sourceTree = ""; - }; 5162AC2618AD9FB4000109C9 /* Controllers */ = { isa = PBXGroup; children = ( @@ -247,7 +231,7 @@ isa = PBXGroup; children = ( 518E699F18AC4A8900C57456 /* ACCodeSnippetRepository.xcplugin */, - 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.octest */, + 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.xctest */, ); name = Products; sourceTree = ""; @@ -257,7 +241,6 @@ children = ( 518E69A218AC4A8900C57456 /* AppKit.framework */, 518E69A418AC4A8900C57456 /* Foundation.framework */, - 5154068418AC4B500065CA33 /* SenTestingKit.framework */, ); name = Frameworks; sourceTree = ""; @@ -318,8 +301,8 @@ ); name = "ACCodeSnippetRepository Tests"; productName = "ACCodeSnippetRepository Tests"; - productReference = 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.octest */; - productType = "com.apple.product-type.bundle"; + productReference = 5154068318AC4B500065CA33 /* ACCodeSnippetRepository Tests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; }; 518E699E18AC4A8900C57456 /* ACCodeSnippetRepository */ = { isa = PBXNativeTarget; @@ -344,7 +327,8 @@ 518E699718AC4A8900C57456 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0500; + LastTestingUpgradeCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = "Arnaud Coomans"; TargetAttributes = { 5154068218AC4B500065CA33 = { @@ -376,6 +360,7 @@ buildActionMask = 2147483647; files = ( 5154068B18AC4B500065CA33 /* InfoPlist.strings in Resources */, + 012836141B11EC41007236B8 /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -383,11 +368,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 515CE9DC18B1DCAA000962EA /* GitHub-Mark-64px.png in Resources */, - 515CE9DB18B1DCAA000962EA /* GitHub-Mark-32px.png in Resources */, 5162AC2B18AD9FD0000109C9 /* ACCodeSnippetRepositoryConfigurationWindowController.xib in Resources */, + 012836131B11EC41007236B8 /* Images.xcassets in Resources */, 518E69AB18AC4A8900C57456 /* InfoPlist.strings in Resources */, - 515CE9DA18B1DCAA000962EA /* GitHub-Mark-120px-plus.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -463,6 +446,7 @@ 5154069118AC4B500065CA33 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -474,14 +458,15 @@ "$(inherited)", ); INFOPLIST_FILE = "ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; }; name = Debug; }; 5154069218AC4B500065CA33 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(DEVELOPER_FRAMEWORKS_DIR)", "$(inherited)", @@ -489,8 +474,8 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Prefix.pch"; INFOPLIST_FILE = "ACCodeSnippetRepository Tests/ACCodeSnippetRepository Tests-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; }; name = Release; }; @@ -510,6 +495,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -573,6 +559,7 @@ INFOPLIST_FILE = "ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist"; INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins"; OTHER_LDFLAGS = ""; + PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = xcplugin; }; @@ -589,6 +576,7 @@ INFOPLIST_FILE = "ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist"; INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins"; OTHER_LDFLAGS = ""; + PRODUCT_BUNDLE_IDENTIFIER = "com.acoomans.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = xcplugin; }; diff --git a/ACCodeSnippetRepository.xcodeproj/xcshareddata/xcschemes/ACCodeSnippetRepositoryBreakpoint.xcscheme b/ACCodeSnippetRepository.xcodeproj/xcshareddata/xcschemes/ACCodeSnippetRepositoryBreakpoint.xcscheme new file mode 100644 index 0000000..720a968 --- /dev/null +++ b/ACCodeSnippetRepository.xcodeproj/xcshareddata/xcschemes/ACCodeSnippetRepositoryBreakpoint.xcscheme @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist b/ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist index ee568a4..87682c9 100644 --- a/ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist +++ b/ACCodeSnippetRepository/ACCodeSnippetRepository-Info.plist @@ -9,7 +9,7 @@ CFBundleIconFile CFBundleIdentifier - com.acoomans.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName @@ -31,6 +31,8 @@ FEC992CC-CA4A-4CFD-8881-77300FCB848A A16FF353-8441-459E-A50C-B071F53F51B7 9F75337B-21B4-4ADC-B558-F9CADF7073A7 + AABB7188-E14E-4433-AD3B-5CD791EAD9A3 + 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 NSPrincipalClass ACCodeSnippetRepositoryPlugin diff --git a/ACCodeSnippetRepository/ACCodeSnippetRepositoryPlugin.m b/ACCodeSnippetRepository/ACCodeSnippetRepositoryPlugin.m index 80b1b44..c6ce400 100644 --- a/ACCodeSnippetRepository/ACCodeSnippetRepositoryPlugin.m +++ b/ACCodeSnippetRepository/ACCodeSnippetRepositoryPlugin.m @@ -39,7 +39,12 @@ - (id)initWithBundle:(NSBundle *)plugin { // reference to plugin's bundle, for resource acccess self.bundle = plugin; - + + [[NSNotificationCenter defaultCenter] addObserver: self + selector: @selector(applicationDidFinishLaunching:) + name: NSApplicationDidFinishLaunchingNotification + object: nil]; + // add data stores to Xcode's snippet repository ACCodeSnippetGitDataStore *gitDataStore = [[ACCodeSnippetGitDataStore alloc] init]; [gitDataStore addObserver:self forKeyPath:@"mainQueue.operationCount" options:0 context:NULL]; @@ -58,29 +63,30 @@ - (id)initWithBundle:(NSBundle *)plugin { [self startTimer]; } - // Create menu items, initialize UI, etc. - NSMenu *pluginMenu = [self pluginMenu]; - pluginMenu.autoenablesItems = NO; - - if (pluginMenu) { - - NSMenuItem *actionMenuItem = nil; - - self.updateMenuItem = actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Update snippets" action:@selector(updateAction:) keyEquivalent:@""]; - actionMenuItem.target = self; - [pluginMenu addItem:actionMenuItem]; - - actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Configure snippets repository" action:@selector(configureAction:) keyEquivalent:@""]; - actionMenuItem.target = self; - [pluginMenu addItem:actionMenuItem]; - - //[pluginMenu addItem:[NSMenuItem separatorItem]]; - } - } return self; } +- (void) applicationDidFinishLaunching: (NSNotification *) notification +{ + // Create menu items, initialize UI, etc. + NSMenu *pluginMenu = [self pluginMenu]; + pluginMenu.autoenablesItems = NO; + + if (pluginMenu) { + + NSMenuItem *actionMenuItem = nil; + + self.updateMenuItem = actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Update snippets" action:@selector(updateAction:) keyEquivalent:@""]; + actionMenuItem.target = self; + [pluginMenu addItem:actionMenuItem]; + + actionMenuItem = [[NSMenuItem alloc] initWithTitle:@"Configure snippets repository" action:@selector(configureAction:) keyEquivalent:@""]; + actionMenuItem.target = self; + [pluginMenu addItem:actionMenuItem]; + } +} + - (id)init { return [self initWithBundle:nil]; } @@ -97,10 +103,14 @@ - (NSMenu*)pluginMenu { if (!pluginMenu) { pluginMenu = [[NSMenu alloc] initWithTitle:pluginMenuTitle]; - NSMenuItem *pluginMenuItem = [[NSMenuItem alloc] initWithTitle:pluginMenuTitle action:nil keyEquivalent:@""]; + NSMenuItem *pluginMenuItem = [[NSMenuItem alloc] initWithTitle:pluginMenuTitle action: NULL keyEquivalent:@""]; pluginMenuItem.submenu = pluginMenu; - - [[NSApp mainMenu] addItem:pluginMenuItem]; + + NSMenu *appMenu = [NSApp menu]; + + NSMenuItem *helpMenuItem = [appMenu itemWithTitle: @"Help"]; + + [appMenu insertItem: pluginMenuItem atIndex: [appMenu indexOfItem: helpMenuItem]]; } return pluginMenu; } diff --git a/ACCodeSnippetRepository/Classes/ACGitRepository.h b/ACCodeSnippetRepository/Classes/ACGitRepository.h index c16c951..9c84169 100644 --- a/ACCodeSnippetRepository/Classes/ACGitRepository.h +++ b/ACCodeSnippetRepository/Classes/ACGitRepository.h @@ -29,7 +29,7 @@ extern NSString * const ACGitRepositoryFileChangeUnmergedKey; - (void)initializeLocalRepository; - (void)initializeLocalRepositoryInDirectory:(NSString*)localRepositoryPath; -- (void)forkRemoteRepositoryWithURL:(NSURL*)remoteRepositoryURL inDirectory:(NSString*)localRepositoryPath; +- (void)cloneRemoteRepositoryWithURL:(NSURL*)remoteRepositoryURL inDirectory:(NSString*)localRepositoryPath; - (NSString*)identifierForCurrentCommit; diff --git a/ACCodeSnippetRepository/Classes/ACGitRepository.m b/ACCodeSnippetRepository/Classes/ACGitRepository.m index dd6a579..5329f2d 100644 --- a/ACCodeSnippetRepository/Classes/ACGitRepository.m +++ b/ACCodeSnippetRepository/Classes/ACGitRepository.m @@ -86,7 +86,7 @@ - (void)initializeLocalRepositoryInDirectory:(NSString*)localRepositoryPath { } } -- (void)forkRemoteRepositoryWithURL:(NSURL*)remoteRepositoryURL inDirectory:(NSString*)localRepositoryPath { +- (void)cloneRemoteRepositoryWithURL:(NSURL*)remoteRepositoryURL inDirectory:(NSString*)localRepositoryPath { if ( ![[NSFileManager defaultManager] fileExistsAtPath:localRepositoryPath] && remoteRepositoryURL) { diff --git a/ACCodeSnippetRepository/Classes/DataStores/ACCodeSnippetGitDataStore.m b/ACCodeSnippetRepository/Classes/DataStores/ACCodeSnippetGitDataStore.m index 588b553..adecf17 100644 --- a/ACCodeSnippetRepository/Classes/DataStores/ACCodeSnippetGitDataStore.m +++ b/ACCodeSnippetRepository/Classes/DataStores/ACCodeSnippetGitDataStore.m @@ -21,7 +21,7 @@ - (instancetype)init { - (id)initWithRemoteRepositoryURL:(NSURL*)remoteRepositoryURL { ACGitRepository *gitRepository = [[ACGitRepository alloc] initWithLocalRepositoryDirectory:self.localRepositoryPath]; if (remoteRepositoryURL && !gitRepository.localRepositoryExists) { - [gitRepository forkRemoteRepositoryWithURL:remoteRepositoryURL inDirectory:self.localRepositoryPath]; + [gitRepository cloneRemoteRepositoryWithURL:remoteRepositoryURL inDirectory:self.localRepositoryPath]; } return [self initWithGitRepository:gitRepository]; } @@ -58,7 +58,7 @@ - (void)setRemoteRepositoryURL:(NSURL *)remoteRepositoryURL { - (void)dataStoreWillAdd { NSLog(@"%@ dataStoreWillAdd", self); if (![self.gitRepository localRepositoryExists]) { - [self.gitRepository forkRemoteRepositoryWithURL:self.remoteRepositoryURL inDirectory:self.localRepositoryPath]; + [self.gitRepository cloneRemoteRepositoryWithURL:self.remoteRepositoryURL inDirectory:self.localRepositoryPath]; } } @@ -158,7 +158,7 @@ - (void)exportAllCodeSnippets { for (IDECodeSnippet *snippet in codeSnippetRepository.codeSnippets) { [self addFileInLocalRepositoryForSnippet:snippet overwrite:NO]; } - [self.gitRepository commitWithMessage:@"Imported user code snippets"]; + [self.gitRepository commitWithMessage:@"Pushed user code snippets"]; [self.gitRepository push]; } diff --git a/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.h b/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.h index 1c60f22..596a4b9 100644 --- a/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.h +++ b/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.h @@ -24,7 +24,7 @@ extern NSString * const ACCodeSnippetRepositoryUpdateRegularlyKey; @property (nonatomic, weak) id delegate; @property (nonatomic, weak) IBOutlet NSTextField *remoteRepositoryTextfield; -@property (nonatomic, weak) IBOutlet NSButton *forkRemoteRepositoryButton; +@property (nonatomic, weak) IBOutlet NSButton *cloneRemoteRepositoryButton; @property (nonatomic, weak) IBOutlet NSButton *importButton; @property (nonatomic, weak) IBOutlet NSPanel *progressPanel; diff --git a/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.m b/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.m index 104a5d1..1ed3cef 100644 --- a/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.m +++ b/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.m @@ -57,10 +57,12 @@ - (ACCodeSnippetGitDataStore*)gitDataStore { - (void)controlTextDidChange:(NSNotification *)notification { NSTextField *textField = [notification object]; - if (![[NSURL URLWithString:textField.stringValue] isEqualTo:self.gitDataStore.remoteRepositoryURL]) { - self.forkRemoteRepositoryButton.enabled = YES; + if (([textField stringValue] && + [[textField stringValue] length]) && + ![[NSURL URLWithString:textField.stringValue] isEqualTo:self.gitDataStore.remoteRepositoryURL]) { + self.cloneRemoteRepositoryButton.enabled = YES; } else { - self.forkRemoteRepositoryButton.enabled = NO; + self.cloneRemoteRepositoryButton.enabled = NO; } if ([textField.stringValue length]) { @@ -77,13 +79,13 @@ - (IBAction)updateCheckboxAction:(NSButton*)button { } -- (IBAction)forkRemoteRepositoryAction:(id)sender { - - NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:@"Do you want to fork %@?", self.remoteRepositoryTextfield.stringValue] - defaultButton:@"Fork" +- (IBAction)cloneRemoteRepositoryAction:(id)sender { + + NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:@"Do you want to clone %@?", self.remoteRepositoryTextfield.stringValue] + defaultButton:@"Clone" alternateButton:@"Cancel" otherButton:nil - informativeTextWithFormat:@"This will remove all snippets from the current git repository and replace them with snippets from the new fork."]; + informativeTextWithFormat:@"All snippets from the current git repository will be removed from Xcode and replaced with snippets from the new cloned repository."]; __weak typeof(self)weakSelf = self; [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { @@ -120,8 +122,10 @@ - (IBAction)forkRemoteRepositoryAction:(id)sender { [weakSelf.window endSheet:weakSelf.progressPanel]; [weakSelf.progressIndicator stopAnimation:weakSelf]; }); - - [weakSelf importUserSnippetsAction:weakSelf]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf exportUserSnippetsAction:weakSelf]; + }); }); break; @@ -155,12 +159,12 @@ - (void)backupUserSnippets { } } -- (IBAction)importUserSnippetsAction:(id)sender { - NSAlert *alert = [NSAlert alertWithMessageText:@"Do you want to import your existing user code snippets in the repository?" - defaultButton:@"Import" +- (IBAction)exportUserSnippetsAction:(id)sender { + NSAlert *alert = [NSAlert alertWithMessageText:@"Do you want to export (push) your existing user code snippets to the repository?" + defaultButton:@"Export" alternateButton:@"Cancel" otherButton:nil - informativeTextWithFormat:@"This will import all your user code snippets in the current git repository. System code snippets will not be imported."]; + informativeTextWithFormat:@"This will export all your user code snippets to the current git repository."]; __weak typeof(self)weakSelf = self; @@ -242,7 +246,7 @@ - (IBAction)restoreSystemSnippets:(id)sender { } - (IBAction)openSystemSnippetsDirectoryAction:(id)sender { - [[NSWorkspace sharedWorkspace] selectFile:[self systemSnippetsPath] inFileViewerRootedAtPath:nil]; + [[NSWorkspace sharedWorkspace] selectFile:[self systemSnippetsPath] inFileViewerRootedAtPath: @""]; } - (NSString*)systemSnippetsPath { @@ -270,7 +274,7 @@ - (NSString*)pathForSnippetDirectory { - (NSString*)pathForBackupDirectory { NSDate *currentDate = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; - [dateFormatter setDateFormat:@"YYMMdd-HHmm"]; + [dateFormatter setDateFormat:@"yyMMdd-HHmm"]; return [NSString pathWithComponents:@[self.pathForSnippetDirectory, [NSString stringWithFormat:@"backup-%@", [dateFormatter stringFromDate:currentDate]]]]; } diff --git a/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.xib b/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.xib index f87b810..d56082b 100644 --- a/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.xib +++ b/ACCodeSnippetRepository/Controllers/ACCodeSnippetRepositoryConfigurationWindowController.xib @@ -1,12 +1,13 @@ - + - + + - + @@ -16,18 +17,17 @@ - + - - + + - + - @@ -35,8 +35,7 @@ - - + @@ -51,7 +50,6 @@ - - + @@ -70,8 +67,7 @@ - - + Don't hesitate to contribute by submitting pull requests at @@ -81,8 +77,7 @@ https://github.com/acoomans/ACCodeSnippetRepositoryPlugin - - + @@ -90,8 +85,7 @@ https://github.com/acoomans/ACCodeSnippetRepositoryPlugin - @@ -169,8 +157,7 @@ https://github.com/acoomans/ACCodeSnippetRepositoryPlugin @@ -229,19 +215,19 @@ https://github.com/acoomans/ACCodeSnippetRepositoryPlugin + - + - @@ -257,6 +243,6 @@ https://github.com/acoomans/ACCodeSnippetRepositoryPlugin - + diff --git a/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/Contents.json b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/Contents.json new file mode 100644 index 0000000..6d811ad --- /dev/null +++ b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "GitHub-Mark-32px.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "GitHub-Mark-64px.png" + }, + { + "idiom" : "universal", + "scale" : "3x", + "filename" : "GitHub-Mark-120px-plus.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-120px-plus.png b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-120px-plus.png new file mode 100644 index 0000000..ea6ff54 Binary files /dev/null and b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-120px-plus.png differ diff --git a/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-32px.png b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-32px.png new file mode 100644 index 0000000..8b25551 Binary files /dev/null and b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-32px.png differ diff --git a/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-64px.png b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-64px.png new file mode 100644 index 0000000..182a1a3 Binary files /dev/null and b/ACCodeSnippetRepository/Resources/Images.xcassets/GitHubImage.imageset/GitHub-Mark-64px.png differ diff --git a/README.md b/README.md index b86219b..f2e01bf 100644 --- a/README.md +++ b/README.md @@ -26,17 +26,17 @@ There should be a `Plug-ins` item in the xcode menu: ![screenshots](Screenshots/screenshot01.png) -First configure the plugin by forking a remote repository: +First configure the plugin by cloning a remote repository: ![screenshots](Screenshots/screenshot02.png) -When you fork, all snippets from the repository (with the right format, see below _Format_) will be imported in Xcode. Your existing snippets, that do not belong to any repository yet, will not be affected. +When you clone, all snippets from the repository (with the right format, see below _Format_) will be imported in Xcode. Your existing snippets, that do not belong to any repository yet, will not be affected. -After forking, you will given the choice to import (user) snippets from Xcode to the repository. +After cloning, you will given the choice to import (user) snippets from Xcode to the repository. Also, you can remove the system snippets if you don't use them. -In case of any problem (see below, _Bugs and limitations_), you can go to the user snippets folder and backup your user snippets. Note that user snippets are automatically backed up before any fork. +In case of any problem (see below, _Bugs and limitations_), you can go to the user snippets folder and backup your user snippets. Note that user snippets are automatically backed up before any clone. ## Usage