mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
4455919be3
* Squashed commit of the following: commit 0bcdce0d1f0f1d13fb5a284404e4eaea4e805a89 Author: Vlad Gorlov <volodymyr.gorlov@gmail.com> Date: Fri Jun 18 00:58:50 2021 +0200 [#1092] Dependency version update. commit 0040c46fd4ce9f42102faeb744104027b6c2c757 Author: Bruce Evans <bruce.evans.dev@gmail.com> Date: Wed Jun 16 09:12:01 2021 +0900 Add Support for DocC in Xcode 13 (#1091) * Add support for DocC DocC "files" are actually folders `.docc` appended to the name, but Xcode 13 treats them differently. Therefore, we need to exclude them from the normal BuildPhase. Resolves #1089 * Add tests for DocC Expanded an existing test to include .docc support. Also added a .docc catalog to the Test Project. * Update changelog.md * Update changelog.md to get the correct PR Link commit 5bb7ef4e1c632f80f63c49ee280d64b8dab1603f Author: Vlad Gorlov <volodymyr.gorlov@gmail.com> Date: Wed Jun 16 01:03:42 2021 +0200 Added support for missed product types. commit 3f8bfdf749d0d15da8490550b95a31cf961d8649 Author: Vlad Gorlov <volodymyr.gorlov@gmail.com> Date: Wed Jun 16 00:01:47 2021 +0200 Added support for missed product types. commit 235ebe4fe906716a6a37421346318fc6515836ce Author: Vlad Gorlov <volodymyr.gorlov@gmail.com> Date: Tue Jun 15 23:53:52 2021 +0200 Added support for missed product types. * [#1094] Fixes failing tests. * [#1094] Added test project targets. * [#1094] Making iig-file type of source code. * [#1094] Attempt to fix CI failure.
109 lines
3.2 KiB
Swift
109 lines
3.2 KiB
Swift
import Foundation
|
|
import PathKit
|
|
import XcodeProj
|
|
|
|
extension PBXProductType {
|
|
|
|
init?(string: String) {
|
|
if let type = PBXProductType(rawValue: string) {
|
|
self = type
|
|
} else if let type = PBXProductType(rawValue: "com.apple.product-type.\(string)") {
|
|
self = type
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
|
|
public var isFramework: Bool {
|
|
self == .framework || self == .staticFramework
|
|
}
|
|
|
|
public var isLibrary: Bool {
|
|
self == .staticLibrary || self == .dynamicLibrary
|
|
}
|
|
|
|
public var isExtension: Bool {
|
|
fileExtension == "appex"
|
|
}
|
|
|
|
public var isSystemExtension: Bool {
|
|
fileExtension == "dext" || fileExtension == "systemextension"
|
|
}
|
|
|
|
public var isApp: Bool {
|
|
fileExtension == "app"
|
|
}
|
|
|
|
public var isTest: Bool {
|
|
fileExtension == "xctest"
|
|
}
|
|
|
|
public var isExecutable: Bool {
|
|
isApp || isExtension || isSystemExtension || isTest || self == .commandLineTool
|
|
}
|
|
|
|
public var name: String {
|
|
rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "")
|
|
}
|
|
|
|
public var canSkipCompileSourcesBuildPhase: Bool {
|
|
switch self {
|
|
case .bundle, .stickerPack, .messagesApplication:
|
|
// Bundles, sticker packs and simple messages applications without sources should not include a
|
|
// compile sources build phase. Doing so can cause Xcode to produce an error on build.
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
/// Function to determine when a dependendency should be embedded into the target
|
|
public func shouldEmbed(_ dependencyTarget: Target) -> Bool {
|
|
switch dependencyTarget.defaultLinkage {
|
|
case .static:
|
|
// Static dependencies should never embed
|
|
return false
|
|
case .dynamic, .none:
|
|
if isApp {
|
|
// If target is an app, all dependencies should be embed (unless they're static)
|
|
return true
|
|
} else if isTest, [.framework, .bundle].contains(dependencyTarget.type) {
|
|
// If target is test, some dependencies should be embed (depending on their type)
|
|
return true
|
|
} else {
|
|
// If none of the above, do not embed the dependency
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Platform {
|
|
|
|
public var emoji: String {
|
|
switch self {
|
|
case .iOS: return "📱"
|
|
case .watchOS: return "⌚️"
|
|
case .tvOS: return "📺"
|
|
case .macOS: return "🖥"
|
|
}
|
|
}
|
|
}
|
|
|
|
extension Target {
|
|
public var shouldExecuteOnLaunch: Bool {
|
|
// This is different from `type.isExecutable`, because we don't want to "run" a test
|
|
type.isApp || type.isExtension || type.isSystemExtension || type == .commandLineTool
|
|
}
|
|
}
|
|
|
|
extension XCScheme.CommandLineArguments {
|
|
// Dictionary is a mapping from argument name and if it is enabled by default
|
|
public convenience init(_ dict: [String: Bool]) {
|
|
let args = dict.map { tuple in
|
|
XCScheme.CommandLineArguments.CommandLineArgument(name: tuple.key, enabled: tuple.value)
|
|
}.sorted { $0.name < $1.name }
|
|
self.init(arguments: args)
|
|
}
|
|
}
|