diff --git a/DEVELOP.md b/DEVELOP.md new file mode 100644 index 0000000..d61735f --- /dev/null +++ b/DEVELOP.md @@ -0,0 +1,105 @@ + + + + + + +## 开发 + +多语言 + +https://medium.com/lean-localization/ios-localization-tutorial-938231f9f881 + + + +finderSync + +https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html + + + +简单的教程 + +https://github.com/DeveloperLx/macOS_Development_Tutorials_translation + + + +App Extension没有权限读~ + +取homeDirectory返回app的沙盒地址,直接写用户地址,报无法读 + +==> appEx默认打开了sandbox,并且无法关闭。把原~/.macnewfile改在app的sandbox的home目录下file:///Users/ch3n/Library/Containers/co.ch3n.MacNewFile.NewFileEx/Data/ + +(关于sandbox) + +https://medium.com/macos-app-development/using-app-sandbox-for-macos-app-9bc90556f9ce + + + +还是没法写 + +在supporting FIles下面的entitlements里面加 + +com.apple.security.temporary-exception.files.home-relative-path.read-write + +https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AppSandboxTemporaryExceptionEntitlements.html + + + +Appicon + +https://github.com/kuyawa/AppIcons + + + +App签名 + +http://nixwang.com/2015/01/07/sign-your-mac-app-with-developer-id/ + +https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/DistributingApplicationsOutside/DistributingApplicationsOutside.html + +关键是要交钱688 + +查看签名 + +``` + codesign -dv /Applications/Whatever.app +``` + + + +Release Build + +Choose **Product** -> **Scheme** -> **Edit Scheme**. Change the `Build Configuration` under the `Info` tab. + + + +DMG + +与拖动安装 + +https://github.com/sindresorhus/create-dmg + +手动对DMG进行签名 + +``` +codesign -s --keychain +``` + + + +签名的原理 + +identity是什么 + +https://developer.apple.com/library/content/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW2 + +https://developer.apple.com/library/content/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html + + + +TODO + +Donate 觉得好用,赞助吃鸡 + +Blog link \ No newline at end of file diff --git a/MacNewFile.xcodeproj/project.pbxproj b/MacNewFile.xcodeproj/project.pbxproj index 4d9dc7a..3fdd59c 100644 --- a/MacNewFile.xcodeproj/project.pbxproj +++ b/MacNewFile.xcodeproj/project.pbxproj @@ -7,13 +7,47 @@ objects = { /* Begin PBXBuildFile section */ + 10D4B84F1F594C6300A3B604 /* FinderSync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10D4B84E1F594C6300A3B604 /* FinderSync.swift */; }; + 10D4B8531F594C6300A3B604 /* NewFileEx.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 10D4B84A1F594C6300A3B604 /* NewFileEx.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 10D4B85B1F59573600A3B604 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 10D4B8591F59573600A3B604 /* Localizable.strings */; }; 10E991191F594C3200F148EF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10E991181F594C3200F148EF /* AppDelegate.swift */; }; 10E9911B1F594C3200F148EF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10E9911A1F594C3200F148EF /* ViewController.swift */; }; 10E9911D1F594C3200F148EF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 10E9911C1F594C3200F148EF /* Assets.xcassets */; }; 10E991201F594C3200F148EF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 10E9911E1F594C3200F148EF /* Main.storyboard */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 10D4B8511F594C6300A3B604 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 10E9910D1F594C3200F148EF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 10D4B8491F594C6300A3B604; + remoteInfo = NewFileEx; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 10D4B8571F594C6300A3B604 /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 10D4B8531F594C6300A3B604 /* NewFileEx.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ + 10D4B84A1F594C6300A3B604 /* NewFileEx.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NewFileEx.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 10D4B84D1F594C6300A3B604 /* NewFileEx.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NewFileEx.entitlements; sourceTree = ""; }; + 10D4B84E1F594C6300A3B604 /* FinderSync.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinderSync.swift; sourceTree = ""; }; + 10D4B8501F594C6300A3B604 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 10D4B8581F59563000A3B604 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; + 10D4B85A1F59573600A3B604 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; + 10D4B85C1F59575500A3B604 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 10E991151F594C3200F148EF /* MacNewFile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacNewFile.app; sourceTree = BUILT_PRODUCTS_DIR; }; 10E991181F594C3200F148EF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 10E9911A1F594C3200F148EF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; @@ -23,6 +57,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 10D4B8471F594C6300A3B604 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 10E991121F594C3200F148EF /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -33,10 +74,29 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 10D4B84B1F594C6300A3B604 /* NewFileEx */ = { + isa = PBXGroup; + children = ( + 10D4B84E1F594C6300A3B604 /* FinderSync.swift */, + 10D4B8501F594C6300A3B604 /* Info.plist */, + 10D4B84C1F594C6300A3B604 /* Supporting Files */, + ); + path = NewFileEx; + sourceTree = ""; + }; + 10D4B84C1F594C6300A3B604 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 10D4B84D1F594C6300A3B604 /* NewFileEx.entitlements */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; 10E9910C1F594C3200F148EF = { isa = PBXGroup; children = ( 10E991171F594C3200F148EF /* MacNewFile */, + 10D4B84B1F594C6300A3B604 /* NewFileEx */, 10E991161F594C3200F148EF /* Products */, ); sourceTree = ""; @@ -45,6 +105,7 @@ isa = PBXGroup; children = ( 10E991151F594C3200F148EF /* MacNewFile.app */, + 10D4B84A1F594C6300A3B604 /* NewFileEx.appex */, ); name = Products; sourceTree = ""; @@ -56,6 +117,7 @@ 10E9911A1F594C3200F148EF /* ViewController.swift */, 10E9911C1F594C3200F148EF /* Assets.xcassets */, 10E9911E1F594C3200F148EF /* Main.storyboard */, + 10D4B8591F59573600A3B604 /* Localizable.strings */, 10E991211F594C3200F148EF /* Info.plist */, ); path = MacNewFile; @@ -64,6 +126,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 10D4B8491F594C6300A3B604 /* NewFileEx */ = { + isa = PBXNativeTarget; + buildConfigurationList = 10D4B8561F594C6300A3B604 /* Build configuration list for PBXNativeTarget "NewFileEx" */; + buildPhases = ( + 10D4B8461F594C6300A3B604 /* Sources */, + 10D4B8471F594C6300A3B604 /* Frameworks */, + 10D4B8481F594C6300A3B604 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NewFileEx; + productName = NewFileEx; + productReference = 10D4B84A1F594C6300A3B604 /* NewFileEx.appex */; + productType = "com.apple.product-type.app-extension"; + }; 10E991141F594C3200F148EF /* MacNewFile */ = { isa = PBXNativeTarget; buildConfigurationList = 10E991241F594C3200F148EF /* Build configuration list for PBXNativeTarget "MacNewFile" */; @@ -71,10 +150,12 @@ 10E991111F594C3200F148EF /* Sources */, 10E991121F594C3200F148EF /* Frameworks */, 10E991131F594C3200F148EF /* Resources */, + 10D4B8571F594C6300A3B604 /* Embed App Extensions */, ); buildRules = ( ); dependencies = ( + 10D4B8521F594C6300A3B604 /* PBXTargetDependency */, ); name = MacNewFile; productName = MacNewFile; @@ -91,8 +172,19 @@ LastUpgradeCheck = 0830; ORGANIZATIONNAME = MajorEssense; TargetAttributes = { + 10D4B8491F594C6300A3B604 = { + CreatedOnToolsVersion = 8.3.3; + DevelopmentTeam = SLJHUQ5M9G; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 0; + }; + }; + }; 10E991141F594C3200F148EF = { CreatedOnToolsVersion = 8.3.3; + DevelopmentTeam = SLJHUQ5M9G; ProvisioningStyle = Automatic; }; }; @@ -104,6 +196,7 @@ knownRegions = ( en, Base, + "zh-Hans", ); mainGroup = 10E9910C1F594C3200F148EF; productRefGroup = 10E991161F594C3200F148EF /* Products */; @@ -111,16 +204,25 @@ projectRoot = ""; targets = ( 10E991141F594C3200F148EF /* MacNewFile */, + 10D4B8491F594C6300A3B604 /* NewFileEx */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 10D4B8481F594C6300A3B604 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 10E991131F594C3200F148EF /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 10E9911D1F594C3200F148EF /* Assets.xcassets in Resources */, + 10D4B85B1F59573600A3B604 /* Localizable.strings in Resources */, 10E991201F594C3200F148EF /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -128,6 +230,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 10D4B8461F594C6300A3B604 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 10D4B84F1F594C6300A3B604 /* FinderSync.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 10E991111F594C3200F148EF /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -139,11 +249,29 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 10D4B8521F594C6300A3B604 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 10D4B8491F594C6300A3B604 /* NewFileEx */; + targetProxy = 10D4B8511F594C6300A3B604 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ + 10D4B8591F59573600A3B604 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 10D4B85A1F59573600A3B604 /* Base */, + 10D4B85C1F59575500A3B604 /* zh-Hans */, + ); + name = Localizable.strings; + sourceTree = ""; + }; 10E9911E1F594C3200F148EF /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 10E9911F1F594C3200F148EF /* Base */, + 10D4B8581F59563000A3B604 /* zh-Hans */, ); name = Main.storyboard; sourceTree = ""; @@ -151,10 +279,46 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 10D4B8541F594C6300A3B604 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = NewFileEx/NewFileEx.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = SLJHUQ5M9G; + INFOPLIST_FILE = NewFileEx/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = co.ch3n.MacNewFile.NewFileEx; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 10D4B8551F594C6300A3B604 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = NewFileEx/NewFileEx.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; + COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = SLJHUQ5M9G; + INFOPLIST_FILE = NewFileEx/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks"; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = co.ch3n.MacNewFile.NewFileEx; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; 10E991221F594C3200F148EF /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -205,6 +369,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -238,6 +403,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; @@ -246,12 +412,16 @@ 10E991251F594C3200F148EF /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = SLJHUQ5M9G; INFOPLIST_FILE = MacNewFile/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = co.ch3n.MacNewFile; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 3.0; }; name = Debug; @@ -259,12 +429,17 @@ 10E991261F594C3200F148EF /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = SLJHUQ5M9G; INFOPLIST_FILE = MacNewFile/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = co.ch3n.MacNewFile; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 3.0; }; name = Release; @@ -272,6 +447,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 10D4B8561F594C6300A3B604 /* Build configuration list for PBXNativeTarget "NewFileEx" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 10D4B8541F594C6300A3B604 /* Debug */, + 10D4B8551F594C6300A3B604 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 10E991101F594C3200F148EF /* Build configuration list for PBXProject "MacNewFile" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -288,6 +472,7 @@ 10E991261F594C3200F148EF /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/MacNewFile.xcscheme b/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/MacNewFile.xcscheme index 015fcc0..89093a9 100644 --- a/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/MacNewFile.xcscheme +++ b/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/MacNewFile.xcscheme @@ -5,6 +5,22 @@ + + + + + + + + + + + + + + @@ -35,6 +70,16 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> + + + + diff --git a/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/NewFileEx.xcscheme b/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/NewFileEx.xcscheme new file mode 100644 index 0000000..de6ecb8 --- /dev/null +++ b/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/NewFileEx.xcscheme @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/xcschememanagement.plist b/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/xcschememanagement.plist index f56b7f1..65d635a 100644 --- a/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/MacNewFile.xcodeproj/xcuserdata/ch3n.xcuserdatad/xcschemes/xcschememanagement.plist @@ -9,9 +9,19 @@ orderHint 0 + NewFileEx.xcscheme + + orderHint + 1 + SuppressBuildableAutocreation + 10D4B8491F594C6300A3B604 + + primary + + 10E991141F594C3200F148EF primary diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/Contents.json b/MacNewFile/Assets.xcassets/AppIcon.appiconset/Contents.json index 2db2b1c..e868a08 100644 --- a/MacNewFile/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/MacNewFile/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,53 +1,63 @@ { "images" : [ { - "idiom" : "mac", "size" : "16x16", + "idiom" : "mac", + "filename" : "mac016pts1x.png", "scale" : "1x" }, { - "idiom" : "mac", "size" : "16x16", + "idiom" : "mac", + "filename" : "mac016pts2x.png", "scale" : "2x" }, { - "idiom" : "mac", "size" : "32x32", + "idiom" : "mac", + "filename" : "mac032pts1x.png", "scale" : "1x" }, { - "idiom" : "mac", "size" : "32x32", + "idiom" : "mac", + "filename" : "mac032pts2x.png", "scale" : "2x" }, { - "idiom" : "mac", "size" : "128x128", + "idiom" : "mac", + "filename" : "mac128pts1x.png", "scale" : "1x" }, { - "idiom" : "mac", "size" : "128x128", + "idiom" : "mac", + "filename" : "mac128pts2x.png", "scale" : "2x" }, { - "idiom" : "mac", "size" : "256x256", + "idiom" : "mac", + "filename" : "mac256pts1x.png", "scale" : "1x" }, { - "idiom" : "mac", "size" : "256x256", + "idiom" : "mac", + "filename" : "mac256pts2x.png", "scale" : "2x" }, { - "idiom" : "mac", "size" : "512x512", + "idiom" : "mac", + "filename" : "mac512pts1x.png", "scale" : "1x" }, { - "idiom" : "mac", "size" : "512x512", + "idiom" : "mac", + "filename" : "mac512pts2x.png", "scale" : "2x" } ], diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac016pts1x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac016pts1x.png new file mode 100644 index 0000000..b483552 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac016pts1x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac016pts2x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac016pts2x.png new file mode 100644 index 0000000..b6944d0 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac016pts2x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac032pts1x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac032pts1x.png new file mode 100644 index 0000000..b6944d0 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac032pts1x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac032pts2x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac032pts2x.png new file mode 100644 index 0000000..c28d8c4 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac032pts2x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac128pts1x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac128pts1x.png new file mode 100644 index 0000000..577702f Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac128pts1x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac128pts2x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac128pts2x.png new file mode 100644 index 0000000..497edba Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac128pts2x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac256pts1x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac256pts1x.png new file mode 100644 index 0000000..497edba Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac256pts1x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac256pts2x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac256pts2x.png new file mode 100644 index 0000000..76d6902 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac256pts2x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac512pts1x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac512pts1x.png new file mode 100644 index 0000000..76d6902 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac512pts1x.png differ diff --git a/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac512pts2x.png b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac512pts2x.png new file mode 100644 index 0000000..a563e73 Binary files /dev/null and b/MacNewFile/Assets.xcassets/AppIcon.appiconset/mac512pts2x.png differ diff --git a/MacNewFile/Assets.xcassets/Contents.json b/MacNewFile/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/MacNewFile/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MacNewFile/Base.lproj/Localizable.strings b/MacNewFile/Base.lproj/Localizable.strings new file mode 100644 index 0000000..d68ff5b --- /dev/null +++ b/MacNewFile/Base.lproj/Localizable.strings @@ -0,0 +1,9 @@ +/* + Localizable.strings + MacNewFile + + Created by 陈冰峰 on 01/09/2017. + Copyright © 2017 MajorEssense. All rights reserved. +*/ + +"PutFileTo" = "Put new file's template files to =>"; diff --git a/MacNewFile/Base.lproj/Main.storyboard b/MacNewFile/Base.lproj/Main.storyboard index af2e9bf..b7b4b7c 100644 --- a/MacNewFile/Base.lproj/Main.storyboard +++ b/MacNewFile/Base.lproj/Main.storyboard @@ -1,7 +1,9 @@ - - + + - + + + @@ -653,7 +655,7 @@ - + @@ -662,7 +664,7 @@ - + @@ -679,11 +681,47 @@ - + + + + + + + + + + + + + + + + + diff --git a/MacNewFile/ViewController.swift b/MacNewFile/ViewController.swift index 8cc8f76..3d2a9e8 100644 --- a/MacNewFile/ViewController.swift +++ b/MacNewFile/ViewController.swift @@ -8,12 +8,21 @@ import Cocoa + +extension String { + var localized: String { + return NSLocalizedString(self, tableName: nil, bundle: Bundle.main, value: "", comment: "") + } +} + class ViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. + + self.labelMain.stringValue = "PutFileTo".localized } override var representedObject: Any? { @@ -21,7 +30,56 @@ class ViewController: NSViewController { // Update the view, if already loaded. } } + + @IBAction func onclick(_ sender: NSButton) { + openMyFolder() + } + + + @IBAction func showSite(_ sender: NSButton) { + if let url = URL(string: "https://github.com/majoressense/macnewfile"), NSWorkspace.shared().open(url) { + print("default browser was successfully opened") + } + } + + func makeSureTheFolder() + { + + // check ~/.macnewfile path, if not exist, create it + let fullPath = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Library/Containers/co.ch3n.MacNewFile.NewFileEx/Data/MacNewFile") + + if !FileManager.default.fileExists(atPath: fullPath.path) { + // file does not exist + do { + NSLog(fullPath.absoluteString) + try FileManager.default.createDirectory(at: fullPath, withIntermediateDirectories: false, attributes: nil) + } catch let error as NSError { + NSLog(error.localizedDescription); + } + NSLog("not exist") + } + } + + func openMyFolder() + { + // check ~/.macnewfile path, if not exist, create it, finally, open it in finder window + let fullPath = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("Library/Containers/co.ch3n.MacNewFile.NewFileEx/Data/MacNewFile") + + makeSureTheFolder() + + NSWorkspace.shared().selectFile(nil, inFileViewerRootedAtPath: fullPath.path) + + do { + let directoryContents = try FileManager.default.contentsOfDirectory(atPath: fullPath.path) + print(directoryContents) + } catch let error as NSError { + print(error.localizedDescription) + } + } + @IBOutlet weak var labelMain: NSTextField! + + } diff --git a/MacNewFile/zh-Hans.lproj/Localizable.strings b/MacNewFile/zh-Hans.lproj/Localizable.strings new file mode 100644 index 0000000..8f53f7d --- /dev/null +++ b/MacNewFile/zh-Hans.lproj/Localizable.strings @@ -0,0 +1,9 @@ +/* + Localizable.strings + MacNewFile + + Created by 陈冰峰 on 01/09/2017. + Copyright © 2017 MajorEssense. All rights reserved. +*/ + +"PutFileTo" = "把新建文件的模板放到这里=>"; diff --git a/MacNewFile/zh-Hans.lproj/Main.strings b/MacNewFile/zh-Hans.lproj/Main.strings new file mode 100644 index 0000000..34f360b --- /dev/null +++ b/MacNewFile/zh-Hans.lproj/Main.strings @@ -0,0 +1,399 @@ + +/* Class = "NSMenuItem"; title = "Customize Toolbar…"; ObjectID = "1UK-8n-QPP"; */ +"1UK-8n-QPP.title" = "Customize Toolbar…"; + +/* Class = "NSMenuItem"; title = "MacNewFile"; ObjectID = "1Xt-HY-uBw"; */ +"1Xt-HY-uBw.title" = "MacNewFile"; + +/* Class = "NSMenu"; title = "Find"; ObjectID = "1b7-l0-nxx"; */ +"1b7-l0-nxx.title" = "Find"; + +/* Class = "NSMenuItem"; title = "Lower"; ObjectID = "1tx-W0-xDw"; */ +"1tx-W0-xDw.title" = "Lower"; + +/* Class = "NSMenuItem"; title = "Raise"; ObjectID = "2h7-ER-AoG"; */ +"2h7-ER-AoG.title" = "Raise"; + +/* Class = "NSMenuItem"; title = "Transformations"; ObjectID = "2oI-Rn-ZJC"; */ +"2oI-Rn-ZJC.title" = "Transformations"; + +/* Class = "NSMenu"; title = "Spelling"; ObjectID = "3IN-sU-3Bg"; */ +"3IN-sU-3Bg.title" = "Spelling"; + +/* Class = "NSMenuItem"; title = "Use Default"; ObjectID = "3Om-Ey-2VK"; */ +"3Om-Ey-2VK.title" = "Use Default"; + +/* Class = "NSMenu"; title = "Speech"; ObjectID = "3rS-ZA-NoH"; */ +"3rS-ZA-NoH.title" = "Speech"; + +/* Class = "NSMenuItem"; title = "Tighten"; ObjectID = "46P-cB-AYj"; */ +"46P-cB-AYj.title" = "Tighten"; + +/* Class = "NSMenuItem"; title = "Find"; ObjectID = "4EN-yA-p0u"; */ +"4EN-yA-p0u.title" = "Find"; + +/* Class = "NSMenuItem"; title = "Enter Full Screen"; ObjectID = "4J7-dP-txa"; */ +"4J7-dP-txa.title" = "Enter Full Screen"; + +/* Class = "NSMenuItem"; title = "Quit MacNewFile"; ObjectID = "4sb-4s-VLi"; */ +"4sb-4s-VLi.title" = "Quit MacNewFile"; + +/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "5QF-Oa-p0T"; */ +"5QF-Oa-p0T.title" = "Edit"; + +/* Class = "NSMenuItem"; title = "Copy Style"; ObjectID = "5Vv-lz-BsD"; */ +"5Vv-lz-BsD.title" = "Copy Style"; + +/* Class = "NSMenuItem"; title = "About MacNewFile"; ObjectID = "5kV-Vb-QxS"; */ +"5kV-Vb-QxS.title" = "About MacNewFile"; + +/* Class = "NSMenuItem"; title = "Redo"; ObjectID = "6dh-zS-Vam"; */ +"6dh-zS-Vam.title" = "Redo"; + +/* Class = "NSMenuItem"; title = "Correct Spelling Automatically"; ObjectID = "78Y-hA-62v"; */ +"78Y-hA-62v.title" = "Correct Spelling Automatically"; + +/* Class = "NSMenu"; title = "Writing Direction"; ObjectID = "8mr-sm-Yjd"; */ +"8mr-sm-Yjd.title" = "Writing Direction"; + +/* Class = "NSMenuItem"; title = "Substitutions"; ObjectID = "9ic-FL-obx"; */ +"9ic-FL-obx.title" = "Substitutions"; + +/* Class = "NSMenuItem"; title = "Smart Copy/Paste"; ObjectID = "9yt-4B-nSM"; */ +"9yt-4B-nSM.title" = "Smart Copy/Paste"; + +/* Class = "NSMenu"; title = "Main Menu"; ObjectID = "AYu-sK-qS6"; */ +"AYu-sK-qS6.title" = "Main Menu"; + +/* Class = "NSMenuItem"; title = "Preferences…"; ObjectID = "BOF-NM-1cW"; */ +"BOF-NM-1cW.title" = "Preferences…"; + +/* Class = "NSMenuItem"; title = "\tLeft to Right"; ObjectID = "BgM-ve-c93"; */ +"BgM-ve-c93.title" = "\tLeft to Right"; + +/* Class = "NSMenuItem"; title = "Save As…"; ObjectID = "Bw7-FT-i3A"; */ +"Bw7-FT-i3A.title" = "Save As…"; + +/* Class = "NSMenuItem"; title = "Close"; ObjectID = "DVo-aG-piG"; */ +"DVo-aG-piG.title" = "Close"; + +/* Class = "NSMenuItem"; title = "Spelling and Grammar"; ObjectID = "Dv1-io-Yv7"; */ +"Dv1-io-Yv7.title" = "Spelling and Grammar"; + +/* Class = "NSMenu"; title = "Help"; ObjectID = "F2S-fz-NVQ"; */ +"F2S-fz-NVQ.title" = "Help"; + +/* Class = "NSMenuItem"; title = "MacNewFile Help"; ObjectID = "FKE-Sm-Kum"; */ +"FKE-Sm-Kum.title" = "MacNewFile Help"; + +/* Class = "NSMenuItem"; title = "Text"; ObjectID = "Fal-I4-PZk"; */ +"Fal-I4-PZk.title" = "Text"; + +/* Class = "NSMenu"; title = "Substitutions"; ObjectID = "FeM-D8-WVr"; */ +"FeM-D8-WVr.title" = "Substitutions"; + +/* Class = "NSMenuItem"; title = "Bold"; ObjectID = "GB9-OM-e27"; */ +"GB9-OM-e27.title" = "Bold"; + +/* Class = "NSMenu"; title = "Format"; ObjectID = "GEO-Iw-cKr"; */ +"GEO-Iw-cKr.title" = "Format"; + +/* Class = "NSMenuItem"; title = "Use Default"; ObjectID = "GUa-eO-cwY"; */ +"GUa-eO-cwY.title" = "Use Default"; + +/* Class = "NSMenuItem"; title = "Font"; ObjectID = "Gi5-1S-RQB"; */ +"Gi5-1S-RQB.title" = "Font"; + +/* Class = "NSMenuItem"; title = "Writing Direction"; ObjectID = "H1b-Si-o9J"; */ +"H1b-Si-o9J.title" = "Writing Direction"; + +/* Class = "NSMenuItem"; title = "View"; ObjectID = "H8h-7b-M4v"; */ +"H8h-7b-M4v.title" = "View"; + +/* Class = "NSMenuItem"; title = "Text Replacement"; ObjectID = "HFQ-gK-NFA"; */ +"HFQ-gK-NFA.title" = "Text Replacement"; + +/* Class = "NSMenuItem"; title = "Show Spelling and Grammar"; ObjectID = "HFo-cy-zxI"; */ +"HFo-cy-zxI.title" = "Show Spelling and Grammar"; + +/* Class = "NSMenu"; title = "View"; ObjectID = "HyV-fh-RgO"; */ +"HyV-fh-RgO.title" = "View"; + +/* Class = "NSMenuItem"; title = "Subscript"; ObjectID = "I0S-gh-46l"; */ +"I0S-gh-46l.title" = "Subscript"; + +/* Class = "NSMenuItem"; title = "Open…"; ObjectID = "IAo-SY-fd9"; */ +"IAo-SY-fd9.title" = "Open…"; + +/* Class = "NSWindow"; title = "Window"; ObjectID = "IQv-IB-iLA"; */ +"IQv-IB-iLA.title" = "Window"; + +/* Class = "NSMenuItem"; title = "Justify"; ObjectID = "J5U-5w-g23"; */ +"J5U-5w-g23.title" = "Justify"; + +/* Class = "NSMenuItem"; title = "Use None"; ObjectID = "J7y-lM-qPV"; */ +"J7y-lM-qPV.title" = "Use None"; + +/* Class = "NSMenuItem"; title = "Revert to Saved"; ObjectID = "KaW-ft-85H"; */ +"KaW-ft-85H.title" = "Revert to Saved"; + +/* Class = "NSMenuItem"; title = "Show All"; ObjectID = "Kd2-mp-pUS"; */ +"Kd2-mp-pUS.title" = "Show All"; + +/* Class = "NSMenuItem"; title = "Bring All to Front"; ObjectID = "LE2-aR-0XJ"; */ +"LE2-aR-0XJ.title" = "Bring All to Front"; + +/* Class = "NSMenuItem"; title = "Paste Ruler"; ObjectID = "LVM-kO-fVI"; */ +"LVM-kO-fVI.title" = "Paste Ruler"; + +/* Class = "NSMenuItem"; title = "\tLeft to Right"; ObjectID = "Lbh-J2-qVU"; */ +"Lbh-J2-qVU.title" = "\tLeft to Right"; + +/* Class = "NSMenuItem"; title = "Copy Ruler"; ObjectID = "MkV-Pr-PK5"; */ +"MkV-Pr-PK5.title" = "Copy Ruler"; + +/* Class = "NSMenuItem"; title = "Services"; ObjectID = "NMo-om-nkz"; */ +"NMo-om-nkz.title" = "Services"; + +/* Class = "NSMenuItem"; title = "\tDefault"; ObjectID = "Nop-cj-93Q"; */ +"Nop-cj-93Q.title" = "\tDefault"; + +/* Class = "NSMenuItem"; title = "Minimize"; ObjectID = "OY7-WF-poV"; */ +"OY7-WF-poV.title" = "Minimize"; + +/* Class = "NSMenuItem"; title = "Baseline"; ObjectID = "OaQ-X3-Vso"; */ +"OaQ-X3-Vso.title" = "Baseline"; + +/* Class = "NSMenuItem"; title = "Hide MacNewFile"; ObjectID = "Olw-nP-bQN"; */ +"Olw-nP-bQN.title" = "Hide MacNewFile"; + +/* Class = "NSMenuItem"; title = "Find Previous"; ObjectID = "OwM-mh-QMV"; */ +"OwM-mh-QMV.title" = "Find Previous"; + +/* Class = "NSMenuItem"; title = "Stop Speaking"; ObjectID = "Oyz-dy-DGm"; */ +"Oyz-dy-DGm.title" = "Stop Speaking"; + +/* Class = "NSMenuItem"; title = "Bigger"; ObjectID = "Ptp-SP-VEL"; */ +"Ptp-SP-VEL.title" = "Bigger"; + +/* Class = "NSMenuItem"; title = "Show Fonts"; ObjectID = "Q5e-8K-NDq"; */ +"Q5e-8K-NDq.title" = "Show Fonts"; + +/* Class = "NSMenuItem"; title = "Zoom"; ObjectID = "R4o-n2-Eq4"; */ +"R4o-n2-Eq4.title" = "Zoom"; + +/* Class = "NSMenuItem"; title = "\tRight to Left"; ObjectID = "RB4-Sm-HuC"; */ +"RB4-Sm-HuC.title" = "\tRight to Left"; + +/* Class = "NSTextFieldCell"; title = "sdfsdfsdfsdfsdffffffffffffffffffffffffffff"; ObjectID = "RfH-jc-Yur"; */ +"RfH-jc-Yur.title" = "sdfsdfsdfsdfsdffffffffffffffffffffffffffff"; + +/* Class = "NSMenuItem"; title = "Superscript"; ObjectID = "Rqc-34-cIF"; */ +"Rqc-34-cIF.title" = "Superscript"; + +/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "Ruw-6m-B2m"; */ +"Ruw-6m-B2m.title" = "Select All"; + +/* Class = "NSMenuItem"; title = "Jump to Selection"; ObjectID = "S0p-oC-mLd"; */ +"S0p-oC-mLd.title" = "Jump to Selection"; + +/* Class = "NSMenu"; title = "Window"; ObjectID = "Td7-aD-5lo"; */ +"Td7-aD-5lo.title" = "Window"; + +/* Class = "NSMenuItem"; title = "Capitalize"; ObjectID = "UEZ-Bs-lqG"; */ +"UEZ-Bs-lqG.title" = "Capitalize"; + +/* Class = "NSMenuItem"; title = "Center"; ObjectID = "VIY-Ag-zcb"; */ +"VIY-Ag-zcb.title" = "Center"; + +/* Class = "NSMenuItem"; title = "Hide Others"; ObjectID = "Vdr-fp-XzO"; */ +"Vdr-fp-XzO.title" = "Hide Others"; + +/* Class = "NSMenuItem"; title = "Italic"; ObjectID = "Vjx-xi-njq"; */ +"Vjx-xi-njq.title" = "Italic"; + +/* Class = "NSMenu"; title = "Edit"; ObjectID = "W48-6f-4Dl"; */ +"W48-6f-4Dl.title" = "Edit"; + +/* Class = "NSMenuItem"; title = "Underline"; ObjectID = "WRG-CD-K1S"; */ +"WRG-CD-K1S.title" = "Underline"; + +/* Class = "NSMenuItem"; title = "New"; ObjectID = "Was-JA-tGl"; */ +"Was-JA-tGl.title" = "New"; + +/* Class = "NSMenuItem"; title = "Paste and Match Style"; ObjectID = "WeT-3V-zwk"; */ +"WeT-3V-zwk.title" = "Paste and Match Style"; + +/* Class = "NSMenuItem"; title = "Find…"; ObjectID = "Xz5-n4-O0W"; */ +"Xz5-n4-O0W.title" = "Find…"; + +/* Class = "NSMenuItem"; title = "Find and Replace…"; ObjectID = "YEy-JH-Tfz"; */ +"YEy-JH-Tfz.title" = "Find and Replace…"; + +/* Class = "NSMenuItem"; title = "\tDefault"; ObjectID = "YGs-j5-SAR"; */ +"YGs-j5-SAR.title" = "\tDefault"; + +/* Class = "NSMenuItem"; title = "Start Speaking"; ObjectID = "Ynk-f8-cLZ"; */ +"Ynk-f8-cLZ.title" = "Start Speaking"; + +/* Class = "NSMenuItem"; title = "Align Left"; ObjectID = "ZM1-6Q-yy1"; */ +"ZM1-6Q-yy1.title" = "Align Left"; + +/* Class = "NSMenuItem"; title = "Paragraph"; ObjectID = "ZvO-Gk-QUH"; */ +"ZvO-Gk-QUH.title" = "Paragraph"; + +/* Class = "NSMenuItem"; title = "Print…"; ObjectID = "aTl-1u-JFS"; */ +"aTl-1u-JFS.title" = "Print…"; + +/* Class = "NSMenuItem"; title = "Window"; ObjectID = "aUF-d1-5bR"; */ +"aUF-d1-5bR.title" = "Window"; + +/* Class = "NSMenu"; title = "Font"; ObjectID = "aXa-aM-Jaq"; */ +"aXa-aM-Jaq.title" = "Font"; + +/* Class = "NSMenuItem"; title = "Use Default"; ObjectID = "agt-UL-0e3"; */ +"agt-UL-0e3.title" = "Use Default"; + +/* Class = "NSMenuItem"; title = "Show Colors"; ObjectID = "bgn-CT-cEk"; */ +"bgn-CT-cEk.title" = "Show Colors"; + +/* Class = "NSMenu"; title = "File"; ObjectID = "bib-Uj-vzu"; */ +"bib-Uj-vzu.title" = "File"; + +/* Class = "NSMenuItem"; title = "Use Selection for Find"; ObjectID = "buJ-ug-pKt"; */ +"buJ-ug-pKt.title" = "Use Selection for Find"; + +/* Class = "NSMenu"; title = "Transformations"; ObjectID = "c8a-y6-VQd"; */ +"c8a-y6-VQd.title" = "Transformations"; + +/* Class = "NSMenuItem"; title = "Use None"; ObjectID = "cDB-IK-hbR"; */ +"cDB-IK-hbR.title" = "Use None"; + +/* Class = "NSMenuItem"; title = "Selection"; ObjectID = "cqv-fj-IhA"; */ +"cqv-fj-IhA.title" = "Selection"; + +/* Class = "NSMenuItem"; title = "Smart Links"; ObjectID = "cwL-P1-jid"; */ +"cwL-P1-jid.title" = "Smart Links"; + +/* Class = "NSMenuItem"; title = "Make Lower Case"; ObjectID = "d9M-CD-aMd"; */ +"d9M-CD-aMd.title" = "Make Lower Case"; + +/* Class = "NSMenu"; title = "Text"; ObjectID = "d9c-me-L2H"; */ +"d9c-me-L2H.title" = "Text"; + +/* Class = "NSMenuItem"; title = "File"; ObjectID = "dMs-cI-mzQ"; */ +"dMs-cI-mzQ.title" = "File"; + +/* Class = "NSMenuItem"; title = "Undo"; ObjectID = "dRJ-4n-Yzg"; */ +"dRJ-4n-Yzg.title" = "Undo"; + +/* Class = "NSMenuItem"; title = "Paste"; ObjectID = "gVA-U4-sdL"; */ +"gVA-U4-sdL.title" = "Paste"; + +/* Class = "NSMenuItem"; title = "Smart Quotes"; ObjectID = "hQb-2v-fYv"; */ +"hQb-2v-fYv.title" = "Smart Quotes"; + +/* Class = "NSMenuItem"; title = "Check Document Now"; ObjectID = "hz2-CU-CR7"; */ +"hz2-CU-CR7.title" = "Check Document Now"; + +/* Class = "NSMenu"; title = "Services"; ObjectID = "hz9-B4-Xy5"; */ +"hz9-B4-Xy5.title" = "Services"; + +/* Class = "NSMenuItem"; title = "Smaller"; ObjectID = "i1d-Er-qST"; */ +"i1d-Er-qST.title" = "Smaller"; + +/* Class = "NSMenu"; title = "Baseline"; ObjectID = "ijk-EB-dga"; */ +"ijk-EB-dga.title" = "Baseline"; + +/* Class = "NSMenuItem"; title = "Kern"; ObjectID = "jBQ-r6-VK2"; */ +"jBQ-r6-VK2.title" = "Kern"; + +/* Class = "NSMenuItem"; title = "\tRight to Left"; ObjectID = "jFq-tB-4Kx"; */ +"jFq-tB-4Kx.title" = "\tRight to Left"; + +/* Class = "NSMenuItem"; title = "Format"; ObjectID = "jxT-CU-nIS"; */ +"jxT-CU-nIS.title" = "Format"; + +/* Class = "NSMenuItem"; title = "Show Sidebar"; ObjectID = "kIP-vf-haE"; */ +"kIP-vf-haE.title" = "Show Sidebar"; + +/* Class = "NSMenuItem"; title = "Check Grammar With Spelling"; ObjectID = "mK6-2p-4JG"; */ +"mK6-2p-4JG.title" = "Check Grammar With Spelling"; + +/* Class = "NSMenuItem"; title = "Ligatures"; ObjectID = "o6e-r0-MWq"; */ +"o6e-r0-MWq.title" = "Ligatures"; + +/* Class = "NSMenu"; title = "Open Recent"; ObjectID = "oas-Oc-fiZ"; */ +"oas-Oc-fiZ.title" = "Open Recent"; + +/* Class = "NSMenuItem"; title = "Loosen"; ObjectID = "ogc-rX-tC1"; */ +"ogc-rX-tC1.title" = "Loosen"; + +/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "pa3-QI-u2k"; */ +"pa3-QI-u2k.title" = "Delete"; + +/* Class = "NSMenuItem"; title = "Save…"; ObjectID = "pxx-59-PXV"; */ +"pxx-59-PXV.title" = "Save…"; + +/* Class = "NSMenuItem"; title = "Find Next"; ObjectID = "q09-fT-Sye"; */ +"q09-fT-Sye.title" = "Find Next"; + +/* Class = "NSMenuItem"; title = "Page Setup…"; ObjectID = "qIS-W8-SiK"; */ +"qIS-W8-SiK.title" = "Page Setup…"; + +/* Class = "NSMenuItem"; title = "Check Spelling While Typing"; ObjectID = "rbD-Rh-wIN"; */ +"rbD-Rh-wIN.title" = "Check Spelling While Typing"; + +/* Class = "NSMenuItem"; title = "Smart Dashes"; ObjectID = "rgM-f4-ycn"; */ +"rgM-f4-ycn.title" = "Smart Dashes"; + +/* Class = "NSMenuItem"; title = "Show Toolbar"; ObjectID = "snW-S8-Cw5"; */ +"snW-S8-Cw5.title" = "Show Toolbar"; + +/* Class = "NSMenuItem"; title = "Data Detectors"; ObjectID = "tRr-pd-1PS"; */ +"tRr-pd-1PS.title" = "Data Detectors"; + +/* Class = "NSMenuItem"; title = "Open Recent"; ObjectID = "tXI-mr-wws"; */ +"tXI-mr-wws.title" = "Open Recent"; + +/* Class = "NSMenu"; title = "Kern"; ObjectID = "tlD-Oa-oAM"; */ +"tlD-Oa-oAM.title" = "Kern"; + +/* Class = "NSMenu"; title = "MacNewFile"; ObjectID = "uQy-DD-JDr"; */ +"uQy-DD-JDr.title" = "MacNewFile"; + +/* Class = "NSMenuItem"; title = "Cut"; ObjectID = "uRl-iY-unG"; */ +"uRl-iY-unG.title" = "Cut"; + +/* Class = "NSMenuItem"; title = "Paste Style"; ObjectID = "vKC-jM-MkH"; */ +"vKC-jM-MkH.title" = "Paste Style"; + +/* Class = "NSMenuItem"; title = "Show Ruler"; ObjectID = "vLm-3I-IUL"; */ +"vLm-3I-IUL.title" = "Show Ruler"; + +/* Class = "NSMenuItem"; title = "Clear Menu"; ObjectID = "vNY-rz-j42"; */ +"vNY-rz-j42.title" = "Clear Menu"; + +/* Class = "NSMenuItem"; title = "Make Upper Case"; ObjectID = "vmV-6d-7jI"; */ +"vmV-6d-7jI.title" = "Make Upper Case"; + +/* Class = "NSMenu"; title = "Ligatures"; ObjectID = "w0m-vy-SC9"; */ +"w0m-vy-SC9.title" = "Ligatures"; + +/* Class = "NSMenuItem"; title = "Align Right"; ObjectID = "wb2-vD-lq4"; */ +"wb2-vD-lq4.title" = "Align Right"; + +/* Class = "NSMenuItem"; title = "Help"; ObjectID = "wpr-3q-Mcd"; */ +"wpr-3q-Mcd.title" = "Help"; + +/* Class = "NSMenuItem"; title = "Copy"; ObjectID = "x3v-GG-iWU"; */ +"x3v-GG-iWU.title" = "Copy"; + +/* Class = "NSMenuItem"; title = "Use All"; ObjectID = "xQD-1f-W4t"; */ +"xQD-1f-W4t.title" = "Use All"; + +/* Class = "NSMenuItem"; title = "Speech"; ObjectID = "xrE-MZ-jX0"; */ +"xrE-MZ-jX0.title" = "Speech"; + +/* Class = "NSMenuItem"; title = "Show Substitutions"; ObjectID = "z6F-FW-3nz"; */ +"z6F-FW-3nz.title" = "Show Substitutions"; diff --git a/NewFileEx/FinderSync.swift b/NewFileEx/FinderSync.swift new file mode 100644 index 0000000..58966bd --- /dev/null +++ b/NewFileEx/FinderSync.swift @@ -0,0 +1,108 @@ +// +// FinderSync.swift +// NewFileEx +// +// Created by 陈冰峰 on 01/09/2017. +// Copyright © 2017 MajorEssense. All rights reserved. +// + +import Cocoa +import FinderSync + +class FinderSync: FIFinderSync { + + var _fullPath = FileManager.default.homeDirectoryForCurrentUser.appendingPathComponent("MacNewFile") + + override init() { + super.init() + } + + + override var toolbarItemName: String { + return "NewFile" + } + + override var toolbarItemToolTip: String { + return "New File" + } + + override var toolbarItemImage: NSImage { + return NSImage(named: NSImageNameAddTemplate)! + } + + + func makeSureTheFolder() { + NSLog("make sure the folder from ext") + + if !FileManager.default.fileExists(atPath: _fullPath.path) { + do { + try FileManager.default.createDirectory(at: _fullPath, withIntermediateDirectories: false, attributes: nil) + NSLog("create the folder") + } catch let error as NSError { + NSLog(error.localizedDescription); + } + NSLog("not exist") + } + } + + func getTemplateFileList() -> [String]{ + + do { + let directoryContents = try FileManager.default.contentsOfDirectory(atPath: _fullPath.path) + print(directoryContents) + return directoryContents + } catch let error as NSError { + print(error.localizedDescription) + } + return [] + } + + override func menu(for menuKind: FIMenuKind) -> NSMenu { + makeSureTheFolder() + let menu = NSMenu(title: "") + var items = getTemplateFileList() + items = items.filter{$0 != ".DS_Store"} + for item in items { + NSLog(item) + menu.addItem(withTitle: item, action: #selector(addFile(_:)), keyEquivalent: "") + + } + return menu + } + + + func genDesUrl(_ fileName:String) -> URL { + var index = 0 + + while index < 100 { + + let little_name = index > 0 ? String.init(format: "%d %@", index, fileName) : fileName + print(little_name) + let des_full_path = FIFinderSyncController.default().targetedURL()?.appendingPathComponent(little_name) + if !FileManager.default.fileExists(atPath: des_full_path!.path) { + return des_full_path! + } + index += 1 + } + return FIFinderSyncController.default().targetedURL()!.appendingPathComponent(fileName) + } + + @IBAction func addFile(_ item: NSMenuItem) { + + let little_path = item.title + let src_full_path = _fullPath.appendingPathComponent(little_path) + NSLog("src = %s", src_full_path.path) + + let des_full_path = genDesUrl(little_path) + print(des_full_path) + + if !FileManager.default.fileExists(atPath: des_full_path.path){ + do { + try FileManager.default.copyItem(at: src_full_path, to: des_full_path) + } catch{ + + } + } + + } +} diff --git a/NewFileEx/Info.plist b/NewFileEx/Info.plist new file mode 100644 index 0000000..440c656 --- /dev/null +++ b/NewFileEx/Info.plist @@ -0,0 +1,41 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + NewFileEx + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSExtension + + NSExtensionAttributes + + NSExtensionPointIdentifier + com.apple.FinderSync + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).FinderSync + + NSHumanReadableCopyright + Copyright © 2017 MajorEssense. All rights reserved. + NSPrincipalClass + NSApplication + + diff --git a/NewFileEx/NewFileEx.entitlements b/NewFileEx/NewFileEx.entitlements new file mode 100644 index 0000000..0f6f17d --- /dev/null +++ b/NewFileEx/NewFileEx.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-write + + com.apple.security.temporary-exception.files.home-relative-path.read-write + / + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..efdac4c --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# MacNewFile + + +### Download + + + + + +### Setup + +- Install + + Open DMG file, drag .app to Applications + +- Open MacNewFile.app + + Click the "Here" button to open the folder + + ![](imgs/a.png) + +- Put your new file templates at the folder + + ![](imgs/b.png) + +- Enjoy with Finder + + ![](imgs/c.png) + + + + + + + + + diff --git a/imgs/a.png b/imgs/a.png new file mode 100644 index 0000000..910c623 Binary files /dev/null and b/imgs/a.png differ diff --git a/imgs/b.png b/imgs/b.png new file mode 100644 index 0000000..3b43d0c Binary files /dev/null and b/imgs/b.png differ diff --git a/imgs/c.png b/imgs/c.png new file mode 100644 index 0000000..5843275 Binary files /dev/null and b/imgs/c.png differ