Skip to content

Commit

Permalink
Merge pull request #33 from Nirma/feature/sfsymbols6_grouped_version
Browse files Browse the repository at this point in the history
Implement support for SFSymbol 6.0
  • Loading branch information
Nirma authored Oct 31, 2024
2 parents 75e548c + 81cb793 commit 9cf4df9
Show file tree
Hide file tree
Showing 19 changed files with 28,346 additions and 2,374 deletions.
79 changes: 79 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/SFSymbol.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SFSymbol"
BuildableName = "SFSymbol"
BlueprintName = "SFSymbol"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SFSymbolTests"
BuildableName = "SFSymbolTests"
BlueprintName = "SFSymbolTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SFSymbol"
BuildableName = "SFSymbol"
BlueprintName = "SFSymbol"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version:5.1
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "SFSymbol",
platforms: [
.macOS(.v10_13), .iOS(.v13), .tvOS(.v13), .watchOS(.v6),
.macOS(.v11), .iOS(.v15), .tvOS(.v15), .watchOS(.v6),
],
products: [
.library(
Expand Down
44 changes: 27 additions & 17 deletions SFSymbol.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@

/* Begin PBXBuildFile section */
4E013E782AC1D1DF00A83669 /* SFSymbol5.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E013E772AC1D1DF00A83669 /* SFSymbol5.swift */; };
4E20FF172CD3736800A12711 /* SymbolImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E20FF162CD3736800A12711 /* SymbolImage.swift */; };
4E20FF192CD3739400A12711 /* SFSymbol6.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E20FF182CD3739400A12711 /* SFSymbol6.swift */; };
4E20FF1B2CD3768B00A12711 /* SFSymbol6Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E20FF1A2CD3768900A12711 /* SFSymbol6Tests.swift */; };
4ECFE97624F1598100D672A6 /* SFSymbol2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ECFE97224F1598100D672A6 /* SFSymbol2.swift */; };
E14A2A1B28FEFFA700E07E33 /* SFSymbol4.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14A2A1A28FEFFA700E07E33 /* SFSymbol4.swift */; };
E14A2A2228FF05E200E07E33 /* SFSymbol3.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14A2A2128FF05E200E07E33 /* SFSymbol3.swift */; };
E1546154298FEA770016DACC /* UIImage+SFSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1546151298FEA770016DACC /* UIImage+SFSymbol.swift */; };
E1546155298FEA770016DACC /* Image+SFSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1546152298FEA770016DACC /* Image+SFSymbol.swift */; };
E1546156298FEA770016DACC /* NSImage+SFSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1546153298FEA770016DACC /* NSImage+SFSymbol.swift */; };
E1CE21BD298F9556008E54B8 /* ImageExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1CE21BC298F9556008E54B8 /* ImageExtensionTests.swift */; };
E1CE21BF298F9619008E54B8 /* UIImageExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1CE21BE298F9619008E54B8 /* UIImageExtensionTests.swift */; };
OBJ_27 /* SFSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* SFSymbol.swift */; };
OBJ_34 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; };
OBJ_48 /* SFSymbol.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "SFSymbol::SFSymbol::Product" /* SFSymbol.framework */; };
Expand All @@ -54,6 +56,9 @@

/* Begin PBXFileReference section */
4E013E772AC1D1DF00A83669 /* SFSymbol5.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SFSymbol5.swift; sourceTree = "<group>"; };
4E20FF162CD3736800A12711 /* SymbolImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolImage.swift; sourceTree = "<group>"; };
4E20FF182CD3739400A12711 /* SFSymbol6.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SFSymbol6.swift; sourceTree = "<group>"; };
4E20FF1A2CD3768900A12711 /* SFSymbol6Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SFSymbol6Tests.swift; sourceTree = "<group>"; };
4E70E3EB23704F30004B4A4D /* SFSymbol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SFSymbol.h; sourceTree = "<group>"; };
4E70E3EC23704F3C004B4A4D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4ECFE97224F1598100D672A6 /* SFSymbol2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SFSymbol2.swift; sourceTree = "<group>"; };
Expand All @@ -63,7 +68,6 @@
E1546152298FEA770016DACC /* Image+SFSymbol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Image+SFSymbol.swift"; path = "Sources/Extensions/Image+SFSymbol.swift"; sourceTree = "<group>"; };
E1546153298FEA770016DACC /* NSImage+SFSymbol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSImage+SFSymbol.swift"; path = "Sources/Extensions/NSImage+SFSymbol.swift"; sourceTree = "<group>"; };
E1CE21BC298F9556008E54B8 /* ImageExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageExtensionTests.swift; path = Tests/SFSymbolTests/ImageExtensionTests.swift; sourceTree = "<group>"; };
E1CE21BE298F9619008E54B8 /* UIImageExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageExtensionTests.swift; sourceTree = "<group>"; };
OBJ_19 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
OBJ_20 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
OBJ_21 /* SFSymbol.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SFSymbol.podspec; sourceTree = "<group>"; };
Expand Down Expand Up @@ -145,8 +149,8 @@
OBJ_10 /* Tests */ = {
isa = PBXGroup;
children = (
4E20FF1A2CD3768900A12711 /* SFSymbol6Tests.swift */,
E1CE21BC298F9556008E54B8 /* ImageExtensionTests.swift */,
E1CE21BE298F9619008E54B8 /* UIImageExtensionTests.swift */,
);
name = Tests;
sourceTree = SOURCE_ROOT;
Expand Down Expand Up @@ -178,6 +182,7 @@
OBJ_7 /* Sources */ = {
isa = PBXGroup;
children = (
4E20FF162CD3736800A12711 /* SymbolImage.swift */,
E1546150298FEA400016DACC /* Extensions */,
OBJ_8 /* SFSymbol */,
);
Expand All @@ -187,11 +192,12 @@
OBJ_8 /* SFSymbol */ = {
isa = PBXGroup;
children = (
4E013E762AC1D1B900A83669 /* SFSymbol5 */,
E14A2A2028FF001800E07E33 /* SFSymbol4 */,
E14A2A1F28FF000900E07E33 /* SFSymbol3 */,
E14A2A1E28FEFFFD00E07E33 /* SFSymbol2 */,
E14A2A1D28FEFFEC00E07E33 /* SFSymbol1 */,
E14A2A1E28FEFFFD00E07E33 /* SFSymbol2 */,
E14A2A1F28FF000900E07E33 /* SFSymbol3 */,
E14A2A2028FF001800E07E33 /* SFSymbol4 */,
4E013E762AC1D1B900A83669 /* SFSymbol5 */,
4E20FF182CD3739400A12711 /* SFSymbol6.swift */,
);
name = SFSymbol;
path = Sources/SFSymbol;
Expand Down Expand Up @@ -255,7 +261,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftMigration = 9999;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1600;
TargetAttributes = {
"SFSymbol::SFSymbolPackageTests::ProductTarget" = {
LastSwiftMigration = 1420;
Expand Down Expand Up @@ -291,12 +297,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 0;
files = (
4E20FF172CD3736800A12711 /* SymbolImage.swift in Sources */,
E14A2A1B28FEFFA700E07E33 /* SFSymbol4.swift in Sources */,
E1546156298FEA770016DACC /* NSImage+SFSymbol.swift in Sources */,
4ECFE97624F1598100D672A6 /* SFSymbol2.swift in Sources */,
E1546155298FEA770016DACC /* Image+SFSymbol.swift in Sources */,
OBJ_27 /* SFSymbol.swift in Sources */,
E14A2A2228FF05E200E07E33 /* SFSymbol3.swift in Sources */,
4E20FF192CD3739400A12711 /* SFSymbol6.swift in Sources */,
4E013E782AC1D1DF00A83669 /* SFSymbol5.swift in Sources */,
E1546154298FEA770016DACC /* UIImage+SFSymbol.swift in Sources */,
);
Expand All @@ -314,7 +322,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 0;
files = (
E1CE21BF298F9619008E54B8 /* UIImageExtensionTests.swift in Sources */,
4E20FF1B2CD3768B00A12711 /* SFSymbol6Tests.swift in Sources */,
E1CE21BD298F9556008E54B8 /* ImageExtensionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -351,7 +359,7 @@
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 13.5;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited)";
Expand Down Expand Up @@ -383,7 +391,7 @@
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
);
MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)";
MACOSX_DEPLOYMENT_TARGET = 13.5;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited)";
Expand Down Expand Up @@ -442,7 +450,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.5;
ONLY_ACTIVE_ARCH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -DXcode";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -459,6 +467,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "";
LD = /usr/bin/true;
MACOSX_DEPLOYMENT_TARGET = 13.5;
OTHER_SWIFT_FLAGS = "-swift-version 5 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -package-description-version 5.1";
SWIFT_VERSION = 5.0;
};
Expand All @@ -469,6 +478,7 @@
buildSettings = {
CODE_SIGN_IDENTITY = "";
LD = /usr/bin/true;
MACOSX_DEPLOYMENT_TARGET = 13.5;
OTHER_SWIFT_FLAGS = "-swift-version 5 -I $(TOOLCHAIN_DIR)/usr/lib/swift/pm/4_2 -target x86_64-apple-macosx10.10 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -package-description-version 5.1";
SWIFT_VERSION = 5.0;
};
Expand All @@ -483,6 +493,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
Expand All @@ -497,6 +508,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
SWIFT_VERSION = 5.0;
};
name = Release;
Expand Down Expand Up @@ -541,7 +553,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 11.5;
OTHER_SWIFT_FLAGS = "$(inherited) -DXcode";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
Expand All @@ -556,7 +568,6 @@
OBJ_42 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -570,7 +581,7 @@
"@loader_path/../Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 13.5;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited)";
Expand All @@ -586,7 +597,6 @@
OBJ_43 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -600,7 +610,7 @@
"@loader_path/../Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MACOSX_DEPLOYMENT_TARGET = 13.5;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
32 changes: 32 additions & 0 deletions SFSymbol6Tests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// SFSymbolImageTests.swift
// SFSymbol
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

@testable import SFSymbol
import SwiftUI
import XCTest

class SFSymbolImageTests: XCTestCase {
func testAllSFSymbols() {
XCTAssert(SFSymbol6.App.appBadgeCheckmark.image != nil)
}
}

3 changes: 1 addition & 2 deletions Sources/Extensions/Image+SFSymbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@

import SwiftUI

@available(iOS 13, macOS 15, *)
public extension Image {
/// Create Image from SFSymbol
init<T: RawRepresentable>(symbol: T) where T.RawValue == String {
self.init(systemName: symbol.rawValue)
}
}

@available(iOS 16, macOS 15, *)
@available(iOS 16.0, *)
public extension Image {
/// Create Image from SFSymbol with optional `variableValue`
init<T: RawRepresentable>(symbol: T, variableValue: Double? = nil) where T.RawValue == String {
Expand Down
19 changes: 19 additions & 0 deletions Sources/Protocols/SymbolImage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Untitled.swift
// SFSymbol
//
// Created by Nicko on 2024/10/31.
//

import SwiftUI

public protocol SymbolImage where Self: RawRepresentable, Self.RawValue == String {
var image: Image? { get }
}


public extension SymbolImage {
var image: Image? {
Image(systemName: rawValue)
}
}
Loading

0 comments on commit 9cf4df9

Please sign in to comment.