Skip to content

Commit

Permalink
Build Uiltity module cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Apr 5, 2024
1 parent 02fa739 commit 7a1aad0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 9 deletions.
4 changes: 3 additions & 1 deletion Configurations/Edit.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ DOCUMENT_MODULE_NAME = Document
INFOPLIST_FILE = Edit/Resources/Info.plist
INFOPLIST_KEY_NSMainNibFile = MainMenu
INFOPLIST_KEY_NSPrincipalClass = NSApplication
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) @executable_path/../Frameworks
OTHER_LDFLAGS[config=Debug] = -ObjC -fprofile-instr-generate
OTHER_LDFLAGS[config=Release] = -ObjC
PRODUCT_MODULE_NAME = Chime
PRODUCT_NAME = Chime
SKIP_INSTALL = NO
SUPPORTED_PLATFORMS = macosx
2 changes: 2 additions & 0 deletions Configurations/Module.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
EXECUTABLE_PREFIX = lib
PRODUCT_NAME = $(TARGET_NAME)
SKIP_INSTALL = YES
SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos appletvsimulator appletvos xrsimulator xros
TARGETED_DEVICE_FAMILY = 1,2,3,4,6,7
27 changes: 27 additions & 0 deletions Edit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
C9BDB54B2B00FD89009225FB /* SwiftStandaloneExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9BDB54A2B00FD89009225FB /* SwiftStandaloneExtension.swift */; };
C9BDB5502B00FD89009225FB /* SwiftExtension.appex in Copy Extensions */ = {isa = PBXBuildFile; fileRef = C9BDB5482B00FD89009225FB /* SwiftExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
C9BDB5572B010094009225FB /* ChimeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE52F42A7539B100CACA1A /* ChimeKit.framework */; };
C9BFA1A32BBF4FA200E86487 /* NSUI in Frameworks */ = {isa = PBXBuildFile; productRef = C9BFA1A22BBF4FA200E86487 /* NSUI */; };
C9C568582B7418B60093C068 /* Lowlight in Frameworks */ = {isa = PBXBuildFile; productRef = C9C568572B7418B60093C068 /* Lowlight */; };
C9CDEB552B504485009E252A /* TextSystem+SwiftTreeSitterLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CDEB542B504485009E252A /* TextSystem+SwiftTreeSitterLayer.swift */; };
C9CDEB572B508C3C009E252A /* Theme+Highlighting.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9CDEB562B508C3C009E252A /* Theme+Highlighting.swift */; };
Expand Down Expand Up @@ -1139,6 +1140,7 @@
C9FE53A92A76713900CACA1A /* libStatus.a in Frameworks */,
C9FE53942A766AB300CACA1A /* libSearch.a in Frameworks */,
C9FE53932A766AAD00CACA1A /* libInspector.a in Frameworks */,
C9BFA1A32BBF4FA200E86487 /* NSUI in Frameworks */,
C9FE53B22A7677E100CACA1A /* ScrollViewPlus in Frameworks */,
C9409C662A98CC9800B5D898 /* Outline in Frameworks */,
C97918DA2A9E080C0046EAF1 /* ViewPlus in Frameworks */,
Expand Down Expand Up @@ -2285,6 +2287,7 @@
C9B8AA5C2B370A1800C79606 /* SwiftTreeSitter */,
C9CDEB8E2B56ACA3009E252A /* MainOffender */,
C9C568572B7418B60093C068 /* Lowlight */,
C9BFA1A22BBF4FA200E86487 /* NSUI */,
);
productName = Edit;
productReference = C9FE52992A7525D000CACA1A /* Chime.app */;
Expand Down Expand Up @@ -2563,6 +2566,7 @@
buildRules = (
);
dependencies = (
C9BFA1A52BBF4FD600E86487 /* PBXTargetDependency */,
);
name = Utility;
productName = Utility;
Expand Down Expand Up @@ -2701,6 +2705,7 @@
C9CDEB8D2B56ACA3009E252A /* XCRemoteSwiftPackageReference "MainOffender" */,
C941F0AF2B7102630003B640 /* XCRemoteSwiftPackageReference "tree-sitter-go" */,
C9C568562B7418B60093C068 /* XCRemoteSwiftPackageReference "Lowlight" */,
C9BFA1A12BBF4FA200E86487 /* XCRemoteSwiftPackageReference "nsui" */,
);
productRefGroup = C9FE529A2A7525D000CACA1A /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -3530,6 +3535,10 @@
target = C9FE52F32A7539B100CACA1A /* ChimeKit */;
targetProxy = C9BDB5552B010088009225FB /* PBXContainerItemProxy */;
};
C9BFA1A52BBF4FD600E86487 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = C9BFA1A42BBF4FD600E86487 /* NSUI */;
};
C9CDEB5C2B51621C009E252A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = C9CDEB5B2B51621C009E252A /* ColorToolbox */;
Expand Down Expand Up @@ -4462,6 +4471,14 @@
minimumVersion = 0.7.2;
};
};
C9BFA1A12BBF4FA200E86487 /* XCRemoteSwiftPackageReference "nsui" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/mattmassicotte/nsui.git";
requirement = {
kind = revision;
revision = d7c7aedb5b6b69cc5561f25c5bb02214cd6101b5;
};
};
C9C568562B7418B60093C068 /* XCRemoteSwiftPackageReference "Lowlight" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ChimeHQ/Lowlight";
Expand Down Expand Up @@ -4749,6 +4766,16 @@
package = C9B8A9B52B235EF100C79606 /* XCRemoteSwiftPackageReference "Rearrange" */;
productName = Rearrange;
};
C9BFA1A22BBF4FA200E86487 /* NSUI */ = {
isa = XCSwiftPackageProductDependency;
package = C9BFA1A12BBF4FA200E86487 /* XCRemoteSwiftPackageReference "nsui" */;
productName = NSUI;
};
C9BFA1A42BBF4FD600E86487 /* NSUI */ = {
isa = XCSwiftPackageProductDependency;
package = C9BFA1A12BBF4FA200E86487 /* XCRemoteSwiftPackageReference "nsui" */;
productName = NSUI;
};
C9C568572B7418B60093C068 /* Lowlight */ = {
isa = XCSwiftPackageProductDependency;
package = C9C568562B7418B60093C068 /* XCRemoteSwiftPackageReference "Lowlight" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "f4663614d88fb73a29978bc6785d29ba6e19a30ee8e384cc1dedd1a60e8be2e8",
"originHash" : "6a46234fd40b23ebe8c139195f63abc4f1b1fbe89026db8f889b8fe4ac9966c9",
"pins" : [
{
"identity" : "asyncxpcconnection",
Expand Down Expand Up @@ -121,6 +121,14 @@
"revision" : "834fed55c04bab1e3894070b9b5939700284e4c8"
}
},
{
"identity" : "nsui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattmassicotte/nsui.git",
"state" : {
"revision" : "d7c7aedb5b6b69cc5561f25c5bb02214cd6101b5"
}
},
{
"identity" : "outline",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 1 addition & 1 deletion Edit/Modules/Theme/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extension Theme {
public func typingAttributes(tabWidth: Int, context: Context) -> [NSAttributedString.Key : Any] {
let baseFont = font(for: .source, context: context)

let charWidth = baseFont.advancementForSpaceGlyph.width
let charWidth = baseFont.advancementForSpaceGlyph
let indentationWidth = charWidth * CGFloat(tabWidth)

let style = NSParagraphStyle.with { style in
Expand Down
10 changes: 5 additions & 5 deletions Edit/Modules/Utility/AppKit/NSFont+Measurements.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AppKit
import NSUI

public extension NSFont {
public extension NSUIFont {
var lineHeight: CGFloat {
return heightAboveBaseline + heightBelowBaseline
}
Expand All @@ -13,11 +13,11 @@ public extension NSFont {
return ascender
}

var advancementForSpaceGlyph: NSSize {
return advancement(forGlyph: NSGlyph(" "))
var advancementForSpaceGlyph: CGFloat {
NSAttributedString(string: " ", attributes: [.font: self]).size().width
}
}

public extension NSFont {
public extension NSUIFont {
static let defaultSystemFont = systemFont(ofSize: systemFontSize)
}
2 changes: 1 addition & 1 deletion Edit/Modules/Utility/AppKit/NSParagraphStyle+Helpers.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AppKit
import NSUI

extension NSParagraphStyle {
public static let rightAligned = NSParagraphStyle.with(block: { $0.alignment = .right })
Expand Down

0 comments on commit 7a1aad0

Please sign in to comment.