Skip to content

Commit ae0bdac

Browse files
committed
Make extension instructions dynamic based on OS version
1 parent ae4d0b6 commit ae0bdac

File tree

4 files changed

+71
-15
lines changed

4 files changed

+71
-15
lines changed

EditorExtension/Application/Base.lproj/Main.storyboard

+15-12
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,19 @@
418418
<autoresizingMask key="autoresizingMask"/>
419419
<subviews>
420420
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="RZx-Ps-pFP">
421-
<rect key="frame" x="0.0" y="591" width="498" height="5"/>
421+
<rect key="frame" x="0.0" y="599" width="498" height="5"/>
422422
<constraints>
423423
<constraint firstAttribute="height" constant="1" id="cK6-hE-hqz"/>
424424
</constraints>
425425
</box>
426426
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="33" horizontalPageScroll="10" verticalLineScroll="33" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="vVz-rA-tRS">
427-
<rect key="frame" x="0.0" y="0.0" width="498" height="555"/>
427+
<rect key="frame" x="0.0" y="0.0" width="498" height="563"/>
428428
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="1nY-Z5-cvR">
429-
<rect key="frame" x="0.0" y="0.0" width="498" height="555"/>
429+
<rect key="frame" x="0.0" y="0.0" width="498" height="563"/>
430430
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
431431
<subviews>
432432
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" selectionHighlightStyle="none" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="30" rowSizeStyle="automatic" usesAutomaticRowHeights="YES" viewBased="YES" id="JTc-wy-tJT">
433-
<rect key="frame" x="0.0" y="0.0" width="498" height="555"/>
433+
<rect key="frame" x="0.0" y="0.0" width="498" height="563"/>
434434
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
435435
<size key="intercellSpacing" width="3" height="3"/>
436436
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -574,7 +574,7 @@
574574
</scroller>
575575
</scrollView>
576576
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pHb-Fu-MRN">
577-
<rect key="frame" x="6" y="592" width="190" height="42"/>
577+
<rect key="frame" x="6" y="600" width="190" height="42"/>
578578
<constraints>
579579
<constraint firstAttribute="height" constant="40" id="qEB-fw-FrU"/>
580580
</constraints>
@@ -587,7 +587,7 @@
587587
</connections>
588588
</button>
589589
<popUpButton horizontalHuggingPriority="500" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="YId-jI-Kpd">
590-
<rect key="frame" x="416" y="599" width="78" height="25"/>
590+
<rect key="frame" x="416" y="607" width="78" height="25"/>
591591
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="nhQ-Kk-Ta3" id="JGl-KG-s99">
592592
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
593593
<font key="font" metaFont="menu"/>
@@ -604,15 +604,15 @@
604604
</connections>
605605
</popUpButton>
606606
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8vB-lt-Jpe">
607-
<rect key="frame" x="335" y="605" width="82" height="16"/>
607+
<rect key="frame" x="335" y="613" width="82" height="16"/>
608608
<textFieldCell key="cell" lineBreakMode="clipping" title="Swift version" id="pwb-qe-8jm">
609609
<font key="font" metaFont="system"/>
610610
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
611611
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
612612
</textFieldCell>
613613
</textField>
614614
<searchField wantsLayer="YES" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="g0F-OD-16q">
615-
<rect key="frame" x="8" y="563" width="482" height="22"/>
615+
<rect key="frame" x="8" y="571" width="482" height="22"/>
616616
<searchFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" usesSingleLineMode="YES" bezelStyle="round" id="7UJ-JQ-nkl">
617617
<font key="font" metaFont="system"/>
618618
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -657,7 +657,7 @@
657657
<!--About-->
658658
<scene sceneID="hIz-AP-VOD">
659659
<objects>
660-
<viewController title="About" showSeguePresentationStyle="single" id="XfG-lQ-9wD" sceneMemberID="viewController">
660+
<viewController title="About" showSeguePresentationStyle="single" id="XfG-lQ-9wD" customClass="AboutViewController" customModule="SwiftFormat_for_Xcode" customModuleProvider="target" sceneMemberID="viewController">
661661
<view key="view" wantsLayer="YES" id="m2S-Jp-Qdl">
662662
<rect key="frame" x="0.0" y="0.0" width="385" height="512"/>
663663
<autoresizingMask key="autoresizingMask"/>
@@ -806,14 +806,17 @@
806806
<constraint firstAttribute="bottom" secondItem="aqr-5C-gJh" secondAttribute="bottom" constant="20" symbolic="YES" id="znD-d5-KwB"/>
807807
</constraints>
808808
</view>
809+
<connections>
810+
<outlet property="instructionsLabel" destination="VVr-7o-9zD" id="XyP-vB-iS9"/>
811+
</connections>
809812
</viewController>
810813
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
811814
</objects>
812-
<point key="canvasLocation" x="536" y="1521"/>
815+
<point key="canvasLocation" x="535.5" y="1521"/>
813816
</scene>
814817
</scenes>
815818
<resources>
816-
<image name="NSTouchBarGetInfoTemplate" width="20" height="20"/>
817-
<image name="NSTouchBarTextListTemplate" width="21" height="15"/>
819+
<image name="NSTouchBarGetInfoTemplate" width="15" height="15"/>
820+
<image name="NSTouchBarTextListTemplate" width="16" height="12"/>
818821
</resources>
819822
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// AboutViewController.swift
3+
// SwiftFormat for Xcode
4+
//
5+
// Created by Nick Lockwood on 09/02/2023.
6+
// Copyright 2023 Nick Lockwood
7+
//
8+
// Distributed under the permissive MIT license
9+
// Get the latest version from here:
10+
//
11+
// https://github.com/nicklockwood/SwiftFormat
12+
//
13+
// Permission is hereby granted, free of charge, to any person obtaining a copy
14+
// of this software and associated documentation files (the "Software"), to deal
15+
// in the Software without restriction, including without limitation the rights
16+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
// copies of the Software, and to permit persons to whom the Software is
18+
// furnished to do so, subject to the following conditions:
19+
//
20+
// The above copyright notice and this permission notice shall be included in all
21+
// copies or substantial portions of the Software.
22+
//
23+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
// SOFTWARE.
30+
//
31+
32+
import Cocoa
33+
34+
final class AboutViewController: NSViewController {
35+
@IBOutlet var instructionsLabel: NSTextField!
36+
37+
override func viewDidLoad() {
38+
super.viewDidLoad()
39+
if ProcessInfo.processInfo.operatingSystemVersion.majorVersion < 13 {
40+
instructionsLabel.stringValue = """
41+
1. Open System Preferences
42+
2. Click on "Extensions"
43+
3. Select "Xcode Source Editor"
44+
4. Ensure the checkbox next to "SwiftFormat" is checked
45+
5. Relaunch Xcode
46+
"""
47+
}
48+
}
49+
}

SwiftFormat.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
01567D30225B2BFD00B22D41 /* ParsingHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01567D2E225B2BFD00B22D41 /* ParsingHelpers.swift */; };
2626
015AF2C01DC6A538008F0A8C /* SwiftFormat.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01A0EAA41D5DB4CF00A0A8E3 /* SwiftFormat.framework */; };
2727
015AF2CA1DC6A58C008F0A8C /* PerformanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 015AF2C91DC6A58C008F0A8C /* PerformanceTests.swift */; };
28+
015D3A562995A0340065B2D9 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 015D3A552995A0340065B2D9 /* AboutViewController.swift */; };
2829
018541CF1DBA0F17000F82E3 /* XCSourceTextBuffer+SwiftFormat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 018541CE1DBA0F17000F82E3 /* XCSourceTextBuffer+SwiftFormat.swift */; };
2930
018E82751D62E730008CA0F8 /* TokenizerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 018E82741D62E730008CA0F8 /* TokenizerTests.swift */; };
3031
01A0EAA81D5DB4CF00A0A8E3 /* SwiftFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 01A0EAA71D5DB4CF00A0A8E3 /* SwiftFormat.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -177,6 +178,7 @@
177178
01567D2E225B2BFD00B22D41 /* ParsingHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParsingHelpers.swift; sourceTree = "<group>"; };
178179
015AF2C51DC6A538008F0A8C /* SwiftFormatPerfTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftFormatPerfTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
179180
015AF2C91DC6A58C008F0A8C /* PerformanceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTests.swift; sourceTree = "<group>"; };
181+
015D3A552995A0340065B2D9 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
180182
018541CE1DBA0F17000F82E3 /* XCSourceTextBuffer+SwiftFormat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCSourceTextBuffer+SwiftFormat.swift"; sourceTree = "<group>"; };
181183
018E82741D62E730008CA0F8 /* TokenizerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TokenizerTests.swift; sourceTree = "<group>"; };
182184
01A0EAA41D5DB4CF00A0A8E3 /* SwiftFormat.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftFormat.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -485,6 +487,7 @@
485487
E41CB5C22026CACD00C1BEDE /* ListSelectionTableCellView.swift */,
486488
E4872124201D980D0014845E /* BinarySelectionTableCellView.swift */,
487489
E487211C201D885A0014845E /* RulesViewController.swift */,
490+
015D3A552995A0340065B2D9 /* AboutViewController.swift */,
488491
E41CB5BE2025761D00C1BEDE /* UserSelection.swift */,
489492
);
490493
path = Source;
@@ -826,6 +829,7 @@
826829
files = (
827830
E4083191202C049200CAF11D /* SwiftFormat.swift in Sources */,
828831
E4FABAD7202FEF060065716E /* OptionDescriptor.swift in Sources */,
832+
015D3A562995A0340065B2D9 /* AboutViewController.swift in Sources */,
829833
E41CB5C52027700100C1BEDE /* FreeTextTableCellView.swift in Sources */,
830834
E4872125201D980D0014845E /* BinarySelectionTableCellView.swift in Sources */,
831835
E487211D201D885A0014845E /* RulesViewController.swift in Sources */,

Tests/SwiftFormatTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SwiftFormatTests: XCTestCase {
6767
return { files.append(inputURL) }
6868
}
6969
XCTAssertEqual(errors.count, 0)
70-
XCTAssertEqual(files.count, 62)
70+
XCTAssertEqual(files.count, 63)
7171
}
7272

7373
func testInputFilesMatchOutputFilesForSameOutput() {
@@ -78,7 +78,7 @@ class SwiftFormatTests: XCTestCase {
7878
return { files.append(inputURL) }
7979
}
8080
XCTAssertEqual(errors.count, 0)
81-
XCTAssertEqual(files.count, 62)
81+
XCTAssertEqual(files.count, 63)
8282
}
8383

8484
func testInputFileNotEnumeratedWhenExcluded() {
@@ -93,7 +93,7 @@ class SwiftFormatTests: XCTestCase {
9393
return { files.append(inputURL) }
9494
}
9595
XCTAssertEqual(errors.count, 0)
96-
XCTAssertEqual(files.count, 39)
96+
XCTAssertEqual(files.count, 40)
9797
}
9898

9999
// MARK: format function

0 commit comments

Comments
 (0)