diff --git a/Bin/VersionIcon b/Bin/VersionIcon index b39b0a6..f5c909d 100755 Binary files a/Bin/VersionIcon and b/Bin/VersionIcon differ diff --git a/Package.resolved b/Package.resolved index 71766e5..0a7bf64 100644 --- a/Package.resolved +++ b/Package.resolved @@ -19,6 +19,15 @@ "version": "0.3.0" } }, + { + "package": "Moderator", + "repositoryURL": "https://github.com/DanielCech/Moderator.git", + "state": { + "branch": "master", + "revision": "b9c7e870caba30204903cf768367b7a5dc4ae3fa", + "version": null + } + }, { "package": "ScriptToolkit", "repositoryURL": "https://github.com/DanielCech/ScriptToolkit.git", diff --git a/Package.swift b/Package.swift index 0f3f5c3..29e24e8 100644 --- a/Package.swift +++ b/Package.swift @@ -10,7 +10,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/JohnSundell/Files.git", from: "4.1.1"), - .package(url: "https://github.com/kareman/Moderator.git", from: "0.5.1"), + .package(url: "https://github.com/DanielCech/Moderator.git", from: "0.5.1"), .package(url: "https://github.com/DanielCech/ScriptToolkit.git", .branch("master")), .package(url: "https://github.com/kareman/SwiftShell.git", from: "5.0.1"), .package(url: "https://github.com/kareman/FileSmith.git", from: "0.3.0"), @@ -20,7 +20,13 @@ let package = Package( // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( name: "VersionIcon", - dependencies: ["Files", "FileSmith", "SwiftShell", "ScriptToolkit", "Moderator"]), + dependencies: ["Files", "FileSmith", "SwiftShell", "ScriptToolkit", "Moderator"], + swiftSettings: + [ + // Macro definition - uncomment only when debugging + // .define("DEBUGGING") + ] + ), .testTarget( name: "VersionIconTests", dependencies: ["VersionIcon"]), diff --git a/Sources/VersionIcon/VersionIconDefinitions.swift b/Sources/VersionIcon/VersionIconDefinitions.swift index 7e121af..1e34ae1 100644 --- a/Sources/VersionIcon/VersionIconDefinitions.swift +++ b/Sources/VersionIcon/VersionIconDefinitions.swift @@ -54,7 +54,7 @@ struct IconMetadata: Codable { func imageInfo(forSize size: String, scale: String) -> ImageInfo? { for image in images { - if (image.size == size) && (image.scale == scale) { + if image.fits(size: size) && image.fits(scale: scale) { return image } } @@ -67,7 +67,17 @@ struct ImageInfo: Codable { var size: String var idiom: String var filename: String? - var scale: String + var scale: String? + + static let singleScale = "1x" + + func fits(size: String) -> Bool { + self.size == size + } + + func fits(scale: String?) -> Bool { + self.scale ?? ImageInfo.singleScale == scale + } } @@ -76,9 +86,9 @@ struct ImageInfo: Codable { /// Getting information about the app with modified icon func getAppSetup(scriptSetup: ScriptSetup) throws -> AppSetup { #if DEBUGGING - let sourceRootPath = "/Users/danielcech/Documents/[Development]/[Projects]/harbor-iOS" - let projectDir = "/Users/danielcech/Documents/[Development]/[Projects]/harbor-iOS" - let infoPlistFile = "Harbor/Application/Info.plist" + let sourceRootPath = "/Users/danielcech/Documents/ios-project-template" + let projectDir = "/Users/danielcech/Documents/ios-project-template" + let infoPlistFile = "Example/Application/Info.plist" #else guard let sourceRootPath = main.env["SRCROOT"], @@ -124,9 +134,8 @@ func iconMetadata(iconFolder: Folder) throws -> IconMetadata { return iconMetadata } catch { - print(error) + throw ScriptError.generalError(message: String(describing: error)) } - fatalError() } /// Get current version and build of the app in prefered format @@ -204,8 +213,12 @@ func generateIcon( // Resizing title let resizedTitleImage = resizeImage(fileName: designStyle.title, size: newSize) - let iconImageData = try Data(contentsOf: URL(fileURLWithPath: originalAppIconFile.path)) - guard let iconImage = NSImage(data: iconImageData) else { throw ScriptError.generalError(message: "Invalid image file") } + guard + let iconImageData = try? Data(contentsOf: URL(fileURLWithPath: originalAppIconFile.path)), + let iconImage = NSImage(data: iconImageData) + else { + return + } var combinedImage = iconImage if let unwrappedResizedRibbonImage = resizedRibbonImage { @@ -252,7 +265,8 @@ func restoreIcon( guard let appIconFileName = appSetup.appIconContents.imageInfo(forSize: size, scale: scale)?.filename else { - throw ScriptError.fileNotFound(message: "Target icon record with \(size):\(scale) not found in \(appSetup.appIconFolder.path) folder") + print(" Icon with size \(size):\(scale) not found") + return } let appIconFilePath = appSetup.appIconFolder.path.appendingPathComponent(path: appIconFileName) diff --git a/Sources/VersionIcon/main.swift b/Sources/VersionIcon/main.swift index 759e144..f5f7573 100644 --- a/Sources/VersionIcon/main.swift +++ b/Sources/VersionIcon/main.swift @@ -114,6 +114,14 @@ do { appSetup: appSetup ) + // Universal iOS marketing icon + try restoreIcon( + size: "1024x1024", + scale: "1x", + scriptSetup: scriptSetup, + appSetup: appSetup + ) + exit(0) } @@ -187,6 +195,16 @@ do { scriptSetup: scriptSetup, appSetup: appSetup ) + + // Universal iOS marketing icon + try generateIcon( + size: "1024x1024", + scale: "1x", + realSize: CGSize(width: 1024, height: 1024), + designStyle: designStyle, + scriptSetup: scriptSetup, + appSetup: appSetup + ) print("✅ Done") } diff --git a/VersionIcon.podspec b/VersionIcon.podspec index f7fc64f..2124ab4 100644 --- a/VersionIcon.podspec +++ b/VersionIcon.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'VersionIcon' s.module_name = 'VersionIcon' - s.version = '1.0.8' + s.version = '1.0.9' s.summary = 'Script written in Swift that prepares the iOS app icon overlay with ribbon, build type and version (build) info' s.homepage = 'https://github.com/DanielCech/VersionIcon' s.license = 'MIT' @@ -9,9 +9,7 @@ Pod::Spec.new do |s| s.platform = :ios, '8.0' s.ios.deployment_target = '8.0' s.requires_arc = true - s.source = { :git => 'https://github.com/DanielCech/VersionIcon.git', :tag => s.version.to_s } - # s.source_files = 'Bin/**/*' - # s.resource_bundle = { 'PKHUDResources' => 'PKHUD/*.xcassets' } + s.source = { :git => 'https://github.com/strvcom/ios-version-icon.git', :tag => s.version.to_s } s.preserve_paths = 'Bin/**/*' s.swift_version = '4.0' end diff --git a/install.sh b/install.sh index 3f041ef..1260535 100755 --- a/install.sh +++ b/install.sh @@ -1,3 +1,3 @@ #! /bin/bash swift build -cp -rf .build/x86_64-apple-macosx/debug/VersionIcon Bin +cp -rf .build/arm64-apple-macosx/debug/VersionIcon Bin