Skip to content

Commit 693e60f

Browse files
authored
Support entitlements with XcodePacker (#88)
1 parent 6df7e40 commit 693e60f

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

Sources/PackLib/Planner.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public struct Planner: Sendable {
153153
bundleID: bundleID,
154154
infoPlist: infoPlist,
155155
resources: resources,
156-
iconPath: self.schema.base.iconPath
156+
iconPath: self.schema.base.iconPath,
157+
entitlementsPath: self.schema.base.entitlementsPath
157158
)
158159
}
159160

@@ -217,6 +218,7 @@ public struct Plan: Sendable {
217218
public var infoPlist: [String: any Sendable]
218219
public var resources: [Resource]
219220
public var iconPath: String?
221+
public var entitlementsPath: String?
220222
}
221223

222224
public enum Resource: Codable, Sendable {

Sources/PackLib/XcodePacker.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public struct XcodePacker {
4242
throw StringError("Could not parse deployment target '\(plan.deploymentTarget)'")
4343
}
4444

45+
var buildSettings: [String: Any] = [
46+
"PRODUCT_BUNDLE_IDENTIFIER": plan.bundleID,
47+
"TARGETED_DEVICE_FAMILY": families.map { "\($0)" }.joined(separator: ","),
48+
]
49+
50+
if let entitlementsPath = plan.entitlementsPath {
51+
buildSettings["CODE_SIGN_ENTITLEMENTS"] = fromProjectToRoot + Path(entitlementsPath)
52+
}
53+
4554
let project = Project(
4655
name: plan.product,
4756
targets: [
@@ -50,10 +59,7 @@ public struct XcodePacker {
5059
type: .application,
5160
platform: .iOS,
5261
deploymentTarget: deploymentTarget,
53-
settings: Settings(buildSettings: [
54-
"PRODUCT_BUNDLE_IDENTIFIER": plan.bundleID,
55-
"TARGETED_DEVICE_FAMILY": families.map { "\($0)" }.joined(separator: ","),
56-
]),
62+
settings: Settings(buildSettings: buildSettings),
5763
sources: [
5864
TargetSource(path: (fromProjectToRoot + emptyFile).string),
5965
],

Sources/XToolSupport/DevCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct PackOperation {
6464
)
6565
let bundle = try await packer.pack()
6666

67-
if let entitlementsPath = schema.base.entitlementsPath {
67+
if let entitlementsPath = plan.entitlementsPath {
6868
let data = try await Data(reading: URL(fileURLWithPath: entitlementsPath))
6969
let decoder = PropertyListDecoder()
7070
let entitlements = try decoder.decode(Entitlements.self, from: data)

0 commit comments

Comments
 (0)