diff --git a/Cocoa Plug-ins/SwiftSidebar/.gitignore b/Cocoa Plug-ins/SwiftSidebar/.gitignore new file mode 100644 index 0000000..779b359 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/.gitignore @@ -0,0 +1,21 @@ +# Apple's Swift libs +SwiftLibs/* + +# Xcode +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate + diff --git a/Cocoa Plug-ins/SwiftSidebar/README.md b/Cocoa Plug-ins/SwiftSidebar/README.md new file mode 100644 index 0000000..cb30a65 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/README.md @@ -0,0 +1,160 @@ +#Swift Sidebar Coda Plugin + +##Introduction +SwiftSidebar is an Coda2 Sidebar to demonstrate using Apple's Swift language to +create a sidebar. + +*Note: This project should be considered as **Experimental** as at this point +Swift is still having problems dealing with the realities of a Plug-in Bundle. Look +for Notes on the areas where I worked around the problems* + +##Contact Information +> Bill Heaton + [http://winkwinknodnod.net/about](http://winkwinknodnod.net/about) + +##Development Environment + +* The Coda Plugin was generated using Xcode Version 6.2 available from the + Apple App Store: [https://itunes.apple.com/us/app/xcode/id49779983](https://itunes.apple.com/us/app/xcode/id49779983) +* The plugin uses the Coda Plugin Source code Version 7 available from + [https://github.com/panicinc/CodaPluginKit](https://github.com/panicinc/CodaPluginKit) + +## Creating A Sidebar Plugin Project + +This is how I created the project in Xcode6: + +* File/New/Project... +* Select OS X "Framework & Library", "Bundle" Then "Next" +* Bundle Extension = codasidebar +* Edit your Info.plist +* Add the Coda2 Information and "Principal Class" information + +> +| Name | Type | Description | +| ------------------------------- | -------- | ------------------------------------- | +| CodaAuthorString | [String] | The Authors name | +| CodaDescriptionString | [String] | Sidebar Description | +| CodaIconHighlightHexColor | [String] | #9100FF | +| CodaIconMaskFile | [String] | Your Sidebar Icon File | +| CodaPlugInSupportedAPIVersion | [Number] | 7 | +| Principal Class | [String] | . | + +* Note: According To Apple for Principal Class: "...In this case that occurs because Swift classes have + namespaced runtime names. Your principal class should therefore be of the form 'MyFramework.MyClass'." +* Create a pdf of your icon for the home view. 200px x 200px black and white image + for best results with the name you have in the "CodaIconMaskFile" entry. +* Create your principal class where the class name is what your set in your info.plist: + "File" / "File.." / "OS X" / "Source" / "Swift File" / Save as +* When it asks you to create a bridging Header, Agree. +* Here's a starter for your Starting Class: + + ``` + import Foundation + import Cocoa + + class YourStartingClass { + } + ``` +* Here a Starter for your bridging Header: + + ``` + #import "CodaPluginsController.h" + ``` + +## Swift Dynalib Workaround + +Currently xcode doesn't know to copy the libswift* files to the bundle. The workaround is +to copy the dylibs from the xcode.app directory to the our source tree and then add a copy +files phase. + +*The means that anytime you update xcode you'll need to snag a copy until +Apple fixes the problem.* + +If you missing one of the librarys you'll get a: "Library not loaded: @rpath/libswiftXXXXX.dylib" +in your debug output. + +Here's a list of the ones that I added for this project: + + * @rpath/libswiftAppKit.dylib + * @rpath/libswiftCore.dylib + * @rpath/libswiftCoreGraphics.dylib + * @rpath/libswiftDarwin.dylib + * @rpath/libswiftDispatch.dylib + * @rpath/libswiftFoundation.dylib + * @rpath/libswiftObjectiveC.dylib + * @rpath/libswiftQuartzCore.dylib + * @rpath/libswiftSecurity.dylib + +### Create The Swift Dynalibs directory + * mkdir SwiftLibs + * cd Swiftlibs + * Copy/Paste: + + ``` + cp /applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/libswift* . + ``` + +### Add the Dynalibs to your project + * Select your plugin target + * Select "Build Phases" tab + * Click "+" and select "New Copy Files Phase" + * Click the "Copy Files" line + * Set "Destinaton" to "Frameworks" + * For each file missing; Click "+" and browse for the dylib needed in the SwiftLibs directory. + +## Swift PrincipalClass Note +Swift will override the PrincipalClass item in info.plist without warning using the class name +found in the first file compiled if it can't find the fully namespaced classname in PrincipalClass. +You'll need to use . (i.e. "SwiftSidebar.SwiftSidebar") to maintain your +sanity. + +## Debugging the Project +To Setup Debugging — [Thank-you to http://ngs.io](http://ngs.io/2012/05/25/debugging-coda-plug-in-with-lldb/) + + * Project -> Scheme -> Edit Scheme... + * Select Run Debug from sidebar. + * Select "Other" from the "Executable" drop down + * Browse to your Coda2 application + * Click "Choose" button then "Close" button + * Select your your plug-in target. + * Select Build Settings tab, click Add Build Setting, select Add User-Defined Setting and + set name as INSTALL_BUNDLE, and value as 1 for Debug configuration. + * Switch to Build Phase tab, click Add Build Phase button and select Add Run Script, Copy + and paste the script below: + + ``` + if [ $INSTALL_BUNDLE == 1 ]; then + DEST="$USER_LIBRARY_DIR/Application Support/Coda 2/Plug-ins/$FULL_PRODUCT_NAME" + ORG="$TARGET_BUILD_DIR/$FULL_PRODUCT_NAME" + rm -rf "$DEST" + cp -R "$ORG" "$DEST" + fi + ``` +*Note: Original script used "mv" which caused xcode not to create/copy the nib File +"cp" works around the problem.* + +## License Terms +©2015 by William J. Heaton — All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar.xcodeproj/project.pbxproj b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar.xcodeproj/project.pbxproj new file mode 100644 index 0000000..38acb77 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar.xcodeproj/project.pbxproj @@ -0,0 +1,376 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 2BCC56A91ACD9A20002C3E80 /* SwitftSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BCC56A81ACD9A20002C3E80 /* SwitftSidebar.swift */; }; + 2BDD21E91ADB0CFA00480F72 /* SwiftSidebarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BDD21E71ADB0CFA00480F72 /* SwiftSidebarView.swift */; }; + 2BDD21EA1ADB0CFA00480F72 /* SwiftSidebarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2BDD21E81ADB0CFA00480F72 /* SwiftSidebarView.xib */; }; + 2BDFB9A51ACFBC5500DB3D71 /* SwiftLogo.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 2BDFB9A31ACFBC5500DB3D71 /* SwiftLogo.pdf */; }; + 2BDFB9B11ACFE9E600DB3D71 /* libswiftCore.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9B01ACFE9E600DB3D71 /* libswiftCore.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9B31ACFEA6C00DB3D71 /* libswiftCoreGraphics.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9B21ACFEA6C00DB3D71 /* libswiftCoreGraphics.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9B51ACFEA8100DB3D71 /* libswiftDarwin.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9B41ACFEA8100DB3D71 /* libswiftDarwin.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9B71ACFEAA800DB3D71 /* libswiftDispatch.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9B61ACFEAA800DB3D71 /* libswiftDispatch.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9B91ACFEAC200DB3D71 /* libswiftFoundation.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9B81ACFEAC200DB3D71 /* libswiftFoundation.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9BB1ACFEAD900DB3D71 /* libswiftObjectiveC.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9BA1ACFEAD900DB3D71 /* libswiftObjectiveC.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9BD1ACFEAED00DB3D71 /* libswiftQuartzCore.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9BC1ACFEAED00DB3D71 /* libswiftQuartzCore.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9BF1ACFEAFD00DB3D71 /* libswiftSecurity.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9BE1ACFEAFD00DB3D71 /* libswiftSecurity.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2BDFB9C21ACFEE5000DB3D71 /* libswiftAppKit.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 2BDFB9C11ACFEE5000DB3D71 /* libswiftAppKit.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 2BDFB9AD1ACFE82300DB3D71 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 2BDFB9C21ACFEE5000DB3D71 /* libswiftAppKit.dylib in CopyFiles */, + 2BDFB9BF1ACFEAFD00DB3D71 /* libswiftSecurity.dylib in CopyFiles */, + 2BDFB9BD1ACFEAED00DB3D71 /* libswiftQuartzCore.dylib in CopyFiles */, + 2BDFB9BB1ACFEAD900DB3D71 /* libswiftObjectiveC.dylib in CopyFiles */, + 2BDFB9B91ACFEAC200DB3D71 /* libswiftFoundation.dylib in CopyFiles */, + 2BDFB9B71ACFEAA800DB3D71 /* libswiftDispatch.dylib in CopyFiles */, + 2BDFB9B51ACFEA8100DB3D71 /* libswiftDarwin.dylib in CopyFiles */, + 2BDFB9B31ACFEA6C00DB3D71 /* libswiftCoreGraphics.dylib in CopyFiles */, + 2BDFB9B11ACFE9E600DB3D71 /* libswiftCore.dylib in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 2BCC569C1ACD99BE002C3E80 /* SwiftSidebar.codasidebar */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftSidebar.codasidebar; sourceTree = BUILT_PRODUCTS_DIR; }; + 2BCC56A01ACD99BE002C3E80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2BCC56A71ACD9A1F002C3E80 /* SwiftSidebar-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftSidebar-Bridging-Header.h"; sourceTree = ""; }; + 2BCC56A81ACD9A20002C3E80 /* SwitftSidebar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwitftSidebar.swift; sourceTree = ""; }; + 2BCC56AA1ACD9B35002C3E80 /* CodaPlugInsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CodaPlugInsController.h; path = ../../CodaPlugInsController.h; sourceTree = ""; }; + 2BDD21E71ADB0CFA00480F72 /* SwiftSidebarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftSidebarView.swift; sourceTree = ""; }; + 2BDD21E81ADB0CFA00480F72 /* SwiftSidebarView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SwiftSidebarView.xib; sourceTree = ""; }; + 2BDFB9A31ACFBC5500DB3D71 /* SwiftLogo.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = SwiftLogo.pdf; sourceTree = ""; }; + 2BDFB9AE1ACFE93600DB3D71 /* libswiftAppKit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftAppKit.dylib; path = SwiftLibs/libswiftAppKit.dylib; sourceTree = ""; }; + 2BDFB9B01ACFE9E600DB3D71 /* libswiftCore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftCore.dylib; path = SwiftLibs/libswiftCore.dylib; sourceTree = SOURCE_ROOT; }; + 2BDFB9B21ACFEA6C00DB3D71 /* libswiftCoreGraphics.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftCoreGraphics.dylib; path = SwiftLibs/libswiftCoreGraphics.dylib; sourceTree = ""; }; + 2BDFB9B41ACFEA8100DB3D71 /* libswiftDarwin.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftDarwin.dylib; path = SwiftLibs/libswiftDarwin.dylib; sourceTree = ""; }; + 2BDFB9B61ACFEAA800DB3D71 /* libswiftDispatch.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftDispatch.dylib; path = SwiftLibs/libswiftDispatch.dylib; sourceTree = ""; }; + 2BDFB9B81ACFEAC200DB3D71 /* libswiftFoundation.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftFoundation.dylib; path = SwiftLibs/libswiftFoundation.dylib; sourceTree = ""; }; + 2BDFB9BA1ACFEAD900DB3D71 /* libswiftObjectiveC.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftObjectiveC.dylib; path = SwiftLibs/libswiftObjectiveC.dylib; sourceTree = ""; }; + 2BDFB9BC1ACFEAED00DB3D71 /* libswiftQuartzCore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftQuartzCore.dylib; path = SwiftLibs/libswiftQuartzCore.dylib; sourceTree = ""; }; + 2BDFB9BE1ACFEAFD00DB3D71 /* libswiftSecurity.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftSecurity.dylib; path = SwiftLibs/libswiftSecurity.dylib; sourceTree = ""; }; + 2BDFB9C11ACFEE5000DB3D71 /* libswiftAppKit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libswiftAppKit.dylib; path = SwiftLibs/libswiftAppKit.dylib; sourceTree = ""; }; + 2BE85AB11AE40FB800E5A287 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2BCC56991ACD99BE002C3E80 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2BCC56931ACD99BE002C3E80 = { + isa = PBXGroup; + children = ( + 2BCC569E1ACD99BE002C3E80 /* SwiftSidebar */, + 2BCC569D1ACD99BE002C3E80 /* Products */, + ); + sourceTree = ""; + }; + 2BCC569D1ACD99BE002C3E80 /* Products */ = { + isa = PBXGroup; + children = ( + 2BCC569C1ACD99BE002C3E80 /* SwiftSidebar.codasidebar */, + ); + name = Products; + sourceTree = ""; + }; + 2BCC569E1ACD99BE002C3E80 /* SwiftSidebar */ = { + isa = PBXGroup; + children = ( + 2BCC56A61ACD99D2002C3E80 /* Source */, + 2BDFB9C01ACFEBA000DB3D71 /* SwiftLibS */, + 2BCC569F1ACD99BE002C3E80 /* Supporting Files */, + ); + path = SwiftSidebar; + sourceTree = ""; + }; + 2BCC569F1ACD99BE002C3E80 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 2BE85AB11AE40FB800E5A287 /* README.md */, + 2BDFB9A31ACFBC5500DB3D71 /* SwiftLogo.pdf */, + 2BCC56AA1ACD9B35002C3E80 /* CodaPlugInsController.h */, + 2BCC56A01ACD99BE002C3E80 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 2BCC56A61ACD99D2002C3E80 /* Source */ = { + isa = PBXGroup; + children = ( + 2BCC56A81ACD9A20002C3E80 /* SwitftSidebar.swift */, + 2BDD21E71ADB0CFA00480F72 /* SwiftSidebarView.swift */, + 2BDD21E81ADB0CFA00480F72 /* SwiftSidebarView.xib */, + 2BCC56A71ACD9A1F002C3E80 /* SwiftSidebar-Bridging-Header.h */, + ); + name = Source; + sourceTree = ""; + }; + 2BDFB9C01ACFEBA000DB3D71 /* SwiftLibS */ = { + isa = PBXGroup; + children = ( + 2BDFB9C11ACFEE5000DB3D71 /* libswiftAppKit.dylib */, + 2BDFB9BE1ACFEAFD00DB3D71 /* libswiftSecurity.dylib */, + 2BDFB9BC1ACFEAED00DB3D71 /* libswiftQuartzCore.dylib */, + 2BDFB9BA1ACFEAD900DB3D71 /* libswiftObjectiveC.dylib */, + 2BDFB9B81ACFEAC200DB3D71 /* libswiftFoundation.dylib */, + 2BDFB9B61ACFEAA800DB3D71 /* libswiftDispatch.dylib */, + 2BDFB9B41ACFEA8100DB3D71 /* libswiftDarwin.dylib */, + 2BDFB9B21ACFEA6C00DB3D71 /* libswiftCoreGraphics.dylib */, + 2BDFB9B01ACFE9E600DB3D71 /* libswiftCore.dylib */, + 2BDFB9AE1ACFE93600DB3D71 /* libswiftAppKit.dylib */, + ); + name = SwiftLibS; + path = ..; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2BCC569B1ACD99BE002C3E80 /* SwiftSidebar */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2BCC56A31ACD99BE002C3E80 /* Build configuration list for PBXNativeTarget "SwiftSidebar" */; + buildPhases = ( + 2BCC56981ACD99BE002C3E80 /* Sources */, + 2BCC56991ACD99BE002C3E80 /* Frameworks */, + 2BCC569A1ACD99BE002C3E80 /* Resources */, + 2BDFB9AD1ACFE82300DB3D71 /* CopyFiles */, + 2BDFB9A71ACFBEF300DB3D71 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftSidebar; + productName = SwiftSidebar; + productReference = 2BCC569C1ACD99BE002C3E80 /* SwiftSidebar.codasidebar */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2BCC56941ACD99BE002C3E80 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0620; + ORGANIZATIONNAME = "WinkWinkNodNod, LLC"; + TargetAttributes = { + 2BCC569B1ACD99BE002C3E80 = { + CreatedOnToolsVersion = 6.2; + }; + }; + }; + buildConfigurationList = 2BCC56971ACD99BE002C3E80 /* Build configuration list for PBXProject "SwiftSidebar" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 2BCC56931ACD99BE002C3E80; + productRefGroup = 2BCC569D1ACD99BE002C3E80 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2BCC569B1ACD99BE002C3E80 /* SwiftSidebar */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2BCC569A1ACD99BE002C3E80 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2BDFB9A51ACFBC5500DB3D71 /* SwiftLogo.pdf in Resources */, + 2BDD21EA1ADB0CFA00480F72 /* SwiftSidebarView.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 2BDFB9A71ACFBEF300DB3D71 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ $INSTALL_BUNDLE == 1 ]; then\n DEST=\"$USER_LIBRARY_DIR/Application Support/Coda 2/Plug-ins/$FULL_PRODUCT_NAME\"\n ORG=\"$TARGET_BUILD_DIR/$FULL_PRODUCT_NAME\"\n rm -rf \"$DEST\"\n cp -R \"$ORG\" \"$DEST\"\nfi"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2BCC56981ACD99BE002C3E80 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2BDD21E91ADB0CFA00480F72 /* SwiftSidebarView.swift in Sources */, + 2BCC56A91ACD9A20002C3E80 /* SwitftSidebar.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 2BCC56A11ACD99BE002C3E80 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 2BCC56A21ACD99BE002C3E80 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 2BCC56A41ACD99BE002C3E80 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + COMBINE_HIDPI_IMAGES = YES; + CREATE_INFOPLIST_SECTION_IN_BINARY = NO; + INFOPLIST_FILE = SwiftSidebar/Info.plist; + INSTALL_BUNDLE = 1; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OBJC_BRIDGING_HEADER = "SwiftSidebar/SwiftSidebar-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + WRAPPER_EXTENSION = codasidebar; + }; + name = Debug; + }; + 2BCC56A51ACD99BE002C3E80 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + COMBINE_HIDPI_IMAGES = YES; + CREATE_INFOPLIST_SECTION_IN_BINARY = NO; + INFOPLIST_FILE = SwiftSidebar/Info.plist; + INSTALL_BUNDLE = ""; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_OBJC_BRIDGING_HEADER = "SwiftSidebar/SwiftSidebar-Bridging-Header.h"; + WRAPPER_EXTENSION = codasidebar; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2BCC56971ACD99BE002C3E80 /* Build configuration list for PBXProject "SwiftSidebar" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2BCC56A11ACD99BE002C3E80 /* Debug */, + 2BCC56A21ACD99BE002C3E80 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2BCC56A31ACD99BE002C3E80 /* Build configuration list for PBXNativeTarget "SwiftSidebar" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2BCC56A41ACD99BE002C3E80 /* Debug */, + 2BCC56A51ACD99BE002C3E80 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2BCC56941ACD99BE002C3E80 /* Project object */; +} diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..fecd65b --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/Info.plist b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/Info.plist new file mode 100644 index 0000000..bdbdf82 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + Com.WinkWinkNodNod.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright © 2015 William J Heaton. All rights reserved. See README.md for license terms + NSPrincipalClass + SwiftSidebar.SwiftSidebar + CodaPlugInSupportedAPIVersion + 7 + CodaAuthorString + WinkWinkNodNod + CodaDescriptionString + Swift Example Sidebar + CodaIconHighlightHexColor + #9100FF + CodaIconMaskFile + SwiftLogo + + diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftLogo.pdf b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftLogo.pdf new file mode 100644 index 0000000..8b784fe Binary files /dev/null and b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftLogo.pdf differ diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebar-Bridging-Header.h b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebar-Bridging-Header.h new file mode 100644 index 0000000..ac6c061 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebar-Bridging-Header.h @@ -0,0 +1,9 @@ +/** + * SwithSidebar-Bridging-Header.h - Import Objective-c Classes + * + * (c) 2015 by William J. Heaton - All Rights Reserved. + * See license terms in README.md + */ +#import "CodaPluginsController.h" + + diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebarView.swift b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebarView.swift new file mode 100644 index 0000000..8b860de --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebarView.swift @@ -0,0 +1,55 @@ +/** +* SwiftViewController.swift - Interface to the sidebar view +* +* (c) 2015 by William J. Heaton - All Rights Reserved. +* See license terms in README.md +*/ + +import Foundation +import Cocoa + +/** + * Swift Sidebar View + * + * This is the view controller for out sidebar. We load our nib from the bundle that passed to use. + * + */ + +class SwiftSidebarView: NSViewController, CodaSidebarViewController { + + /// The plugin controller pointer we received so that we can talk to Coda. + var plugInController:AnyObject! = nil + + /// Label for Coda Version + @IBOutlet weak var labelVersion: NSTextField! + + /** + * This is the equvalence of: "- (id)initWithNibName:(NSString*)nibName + * plugInBundle:(id )plugInBundle + * plugInController:(CodaPlugInsController*)aController + * + * :param: plugInController A pointer to the plugin controller + * :param: plugInBundle A pointer the bundle we were loaded from + */ + required init?( nibName: String, plugInController:AnyObject!, plugInBundle:AnyObject! ) + { + self.plugInController = plugInController + super.init( nibName: nibName, bundle: plugInBundle as? NSBundle) + } + + /// Workaround for Swift wanting this init + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + /** + * Action Routine for the Button. Proves that we can hear button pushes and that we + * can effect view elements. A side effect is that we prove that we can call the Coda API + * + * :param: sender The ID of the sending button + */ + @IBAction func actioniButton(sender: AnyObject) { + labelVersion.stringValue = "Coda Version " + self.plugInController.codaVersion() + } + +} \ No newline at end of file diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebarView.xib b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebarView.xib new file mode 100644 index 0000000..a0720d9 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwiftSidebarView.xib @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwitftSidebar.swift b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwitftSidebar.swift new file mode 100644 index 0000000..6d446b8 --- /dev/null +++ b/Cocoa Plug-ins/SwiftSidebar/SwiftSidebar/SwitftSidebar.swift @@ -0,0 +1,68 @@ +/** + * SwithSidebar.swift - Principal Class for Swift Sidebar + * + * (c) 2015 by William J. Heaton - All Rights Reserved. + * See license terms in README.md + */ + +import Foundation +import Cocoa + +/** + * Swift Sidebar + * + * This class provides the principal interface that Coda 2 uses to communicate with the our + * plugin. The name of the class should match the NSPrincipalClass item in info.plist or + * you'll get an obnoxious error message that diffcult to trace down. + */ +@objc class SwiftSidebar : NSObject, CodaSidebarPlugIn, CodaPlugIn { + + /// The plugin controller pointer we received so that we can talk to Coda. + var plugInController:AnyObject! = nil + + /// The Plugin Bundle pointer we received so that we can access our bundle. + var plugInBundle:CodaPlugInBundle! = nil + + /** + * The equivalent of "- (NSString*)name;" A Required function to return + * the name of the plugin. + * + * :returns: String with our name + */ + func name() -> String { + return "Swift Sidebar" + } + + /** + * The equivalent of "-(id)initWithPlugInController:(CodaPlugInsController*)aController" + * plugInBundle:(id )plugInBundle;The default initalization method for + * your plug-in's principal class. + * + * :param: plugInController A pointer to the plugin controller + * :param: plugInBundle A pointer the bundle we were loaded from + */ + required init(plugInController:CodaPlugInsController!, plugInBundle:CodaPlugInBundle!) + { + self.plugInController = plugInController; + self.plugInBundle = plugInBundle; + super.init() + } + + /// Workaround Swift wanting this init + required init(plugInController: CodaPlugInsController!, bundle: NSBundle!) + { + fatalError("Sorry, The Swift Plugin requires Coda 2.0.1 or later.") + } + + /** + * Return a new sidebar view controller for our sidebar. Return a new autoreleased view + * controller to be inserted into the sidebar, will be called once per window. + * + * :returns: A view controller which conforms to the CodaSidebarViewController protocol. + */ + func viewController() -> NSViewController! { + return SwiftSidebarView(nibName:"SwiftSidebarView", + plugInController:self.plugInController, + plugInBundle:self.plugInBundle ) + } +} \ No newline at end of file