Skip to content

Commit 4455919

Browse files
authored
Added support for "driver-extension" and "system-extension" product types (#1094)
* 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.
1 parent b8af21d commit 4455919

25 files changed

Lines changed: 1160 additions & 9 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

77
- Added support for DocC Catalogs [#1091](https://github.com/yonaskolb/XcodeGen/pull/1091) @brevansio
8+
- Added support for "driver-extension" and "system-extension" product types [#1092](https://github.com/yonaskolb/XcodeGen/issues/1092) @vgorloff
89

910
## 2.23.1
1011

Docs/ProjectSpec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ This will provide default build settings for a certain product type. It can be a
292292
- `watchkit-extension`
293293
- `watchkit2-extension`
294294
- `xcode-extension`
295+
- `driver-extension`
296+
- `system-extension`
295297
- `xpc-service`
296298
- ``""`` (used for legacy targets)
297299

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let package = Package(
1616
.package(url: "https://github.com/yonaskolb/JSONUtilities.git", from: "4.2.0"),
1717
.package(url: "https://github.com/kylef/Spectre.git", from: "0.9.2"),
1818
.package(url: "https://github.com/onevcat/Rainbow.git", from: "3.0.0"),
19-
.package(url: "https://github.com/tuist/XcodeProj.git", from: "7.23.0"),
19+
.package(url: "https://github.com/tuist/XcodeProj.git", from: "8.0.0"),
2020
.package(url: "https://github.com/jakeheis/SwiftCLI.git", from: "6.0.0"),
2121
.package(url: "https://github.com/mxcl/Version", from: "2.0.0"),
2222
.package(url: "https://github.com/SwiftDocOrg/GraphViz.git", .exact("0.2.0")),

Sources/ProjectSpec/FileType.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ extension FileType {
8787
"metal": FileType(buildPhase: .sources),
8888
"mlmodel": FileType(buildPhase: .sources),
8989
"rcproject": FileType(buildPhase: .sources),
90+
"iig": FileType(buildPhase: .sources),
9091

9192
// headers
9293
"h": FileType(buildPhase: .headers),

Sources/ProjectSpec/Linkage.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ extension Target {
3333
.watch2AppContainer,
3434
.watch2Extension,
3535
.xcodeExtension,
36-
.xpcService:
36+
.xpcService,
37+
.systemExtension,
38+
.driverExtension:
3739
return .none
3840
case .framework, .xcFramework:
3941
// Check the MACH_O_TYPE for "Static Framework"

Sources/ProjectSpec/XCProjExtensions.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ extension PBXProductType {
2626
fileExtension == "appex"
2727
}
2828

29+
public var isSystemExtension: Bool {
30+
fileExtension == "dext" || fileExtension == "systemextension"
31+
}
32+
2933
public var isApp: Bool {
3034
fileExtension == "app"
3135
}
@@ -35,7 +39,7 @@ extension PBXProductType {
3539
}
3640

3741
public var isExecutable: Bool {
38-
isApp || isExtension || isTest || self == .commandLineTool
42+
isApp || isExtension || isSystemExtension || isTest || self == .commandLineTool
3943
}
4044

4145
public var name: String {
@@ -89,7 +93,7 @@ extension Platform {
8993
extension Target {
9094
public var shouldExecuteOnLaunch: Bool {
9195
// This is different from `type.isExecutable`, because we don't want to "run" a test
92-
type.isApp || type.isExtension || type == .commandLineTool
96+
type.isApp || type.isExtension || type.isSystemExtension || type == .commandLineTool
9397
}
9498
}
9599

Sources/XcodeGenKit/PBXProjGenerator.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ public class PBXProjGenerator {
669669
var copyWatchReferences: [PBXBuildFile] = []
670670
var packageDependencies: [XCSwiftPackageProductDependency] = []
671671
var extensions: [PBXBuildFile] = []
672+
var systemExtensions: [PBXBuildFile] = []
672673
var appClips: [PBXBuildFile] = []
673674
var carthageFrameworksToEmbed: [String] = []
674675
let localPackageReferences: [String] = project.packages.compactMap { $0.value.isLocal ? $0.key : nil }
@@ -729,6 +730,9 @@ public class PBXProjGenerator {
729730
if dependencyTarget.type.isExtension {
730731
// embed app extension
731732
extensions.append(embedFile)
733+
} else if dependencyTarget.type.isSystemExtension {
734+
// embed system extension
735+
systemExtensions.append(embedFile)
732736
} else if dependencyTarget.type == .onDemandInstallCapableApplication {
733737
// embed app clip
734738
appClips.append(embedFile)
@@ -1001,9 +1005,9 @@ public class PBXProjGenerator {
10011005
return sourceFilesByCopyFiles.mapValues { getBuildFilesForSourceFiles($0) }
10021006
}
10031007

1004-
func getPBXCopyFilesBuildPhase(dstSubfolderSpec: PBXCopyFilesBuildPhase.SubFolder, name: String, files: [PBXBuildFile]) -> PBXCopyFilesBuildPhase {
1008+
func getPBXCopyFilesBuildPhase(dstSubfolderSpec: PBXCopyFilesBuildPhase.SubFolder, dstPath: String = "", name: String, files: [PBXBuildFile]) -> PBXCopyFilesBuildPhase {
10051009
return PBXCopyFilesBuildPhase(
1006-
dstPath: "",
1010+
dstPath: dstPath,
10071011
dstSubfolderSpec: dstSubfolderSpec,
10081012
name: name,
10091013
buildActionMask: target.onlyCopyFilesOnInstall ? PBXProjGenerator.copyFilesActionMask : PBXBuildPhase.defaultBuildActionMask,
@@ -1116,6 +1120,16 @@ public class PBXProjGenerator {
11161120
buildPhases.append(copyFilesPhase)
11171121
}
11181122

1123+
if !systemExtensions.isEmpty {
1124+
1125+
let copyFilesPhase = addObject(
1126+
// With parameters below the Xcode will show "Destination: System Extensions".
1127+
getPBXCopyFilesBuildPhase(dstSubfolderSpec: .productsDirectory, dstPath: "$(SYSTEM_EXTENSIONS_FOLDER_PATH)", name: "Embed System Extensions", files: systemExtensions)
1128+
)
1129+
1130+
buildPhases.append(copyFilesPhase)
1131+
}
1132+
11191133
if !appClips.isEmpty {
11201134

11211135
let copyFilesPhase = addObject(
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// Driver.cpp
3+
// Driver
4+
//
5+
// Created by Vlad Gorlov on 18.06.21.
6+
//
7+
8+
#include <os/log.h>
9+
10+
#include <DriverKit/IOUserServer.h>
11+
#include <DriverKit/IOLib.h>
12+
13+
#include "Driver.h"
14+
15+
kern_return_t
16+
IMPL(Driver, Start)
17+
{
18+
kern_return_t ret;
19+
ret = Start(provider, SUPERDISPATCH);
20+
os_log(OS_LOG_DEFAULT, "Hello World");
21+
return ret;
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)