Skip to content

Commit 509970a

Browse files
committed
Use info plist file and code sign entitlements from environment
1 parent c726c82 commit 509970a

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Sources/RswiftCore/CallInformation.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public struct CallInformation {
2323
let targetName: String
2424
let bundleIdentifier: String
2525
let productModuleName: String
26+
let infoPlistFile: URL
27+
let codeSignEntitlements: URL?
2628

2729
let scriptInputFiles: [String]
2830
let scriptOutputFiles: [String]
@@ -47,6 +49,8 @@ public struct CallInformation {
4749
targetName: String,
4850
bundleIdentifier: String,
4951
productModuleName: String,
52+
infoPlistFile: URL,
53+
codeSignEntitlements: URL?,
5054

5155
scriptInputFiles: [String],
5256
scriptOutputFiles: [String],
@@ -70,6 +74,8 @@ public struct CallInformation {
7074
self.targetName = targetName
7175
self.bundleIdentifier = bundleIdentifier
7276
self.productModuleName = productModuleName
77+
self.infoPlistFile = infoPlistFile
78+
self.codeSignEntitlements = codeSignEntitlements
7379

7480
self.scriptInputFiles = scriptInputFiles
7581
self.scriptOutputFiles = scriptOutputFiles

Sources/RswiftCore/RswiftCore.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,18 @@ public struct RswiftCore {
8080
structGenerators.append(AccessibilityIdentifierStructGenerator(nibs: resources.nibs, storyboards: resources.storyboards))
8181
}
8282
if callInformation.generators.contains(.info) {
83-
84-
let infoPlists = buildConfigurations.compactMap {
85-
return loadPropertyList(name: $0.name, path: $0.infoPlistPath, callInformation: callInformation)
83+
84+
let infoPlists = buildConfigurations.compactMap { config in
85+
return loadPropertyList(name: config.name, url: callInformation.infoPlistFile, callInformation: callInformation)
8686
}
8787

8888
structGenerators.append(PropertyListGenerator(name: "info", plists: infoPlists, toplevelKeysWhitelist: infoPlistWhitelist))
8989
}
9090
if callInformation.generators.contains(.entitlements) {
9191

92-
let entitlements = buildConfigurations.compactMap {
93-
return loadPropertyList(name: $0.name, path: $0.entitlementsPath, callInformation: callInformation)
92+
let entitlements = buildConfigurations.compactMap { config -> PropertyList? in
93+
guard let codeSignEntitlement = callInformation.codeSignEntitlements else { return nil }
94+
return loadPropertyList(name: config.name, url: codeSignEntitlement, callInformation: callInformation)
9495
}
9596

9697
structGenerators.append(PropertyListGenerator(name: "entitlements", plists: entitlements, toplevelKeysWhitelist: nil))
@@ -164,10 +165,8 @@ public struct RswiftCore {
164165
}
165166
}
166167

167-
private func loadPropertyList(name: String, path: Path?, callInformation: CallInformation) -> PropertyList? {
168-
guard let path = path else { return nil }
168+
private func loadPropertyList(name: String, url: URL, callInformation: CallInformation) -> PropertyList? {
169169
do {
170-
let url = path.url(with: callInformation.urlForSourceTreeFolder)
171170
return try PropertyList(buildConfigurationName: name, url: url)
172171
} catch let ResourceParsingError.parsingFailed(humanReadableError) {
173172
warn(humanReadableError)

Sources/rswift/main.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ struct EnvironmentKeys {
4747
static let target = "TARGET_NAME"
4848
static let tempDir = "TEMP_DIR"
4949
static let xcodeproj = "PROJECT_FILE_PATH"
50+
static let infoPlistFile = "INFOPLIST_FILE"
51+
static let codeSignEntitlements = "CODE_SIGN_ENTITLEMENTS"
5052

5153
static let buildProductsDir = SourceTreeFolder.buildProductsDir.rawValue
5254
static let developerDir = SourceTreeFolder.developerDir.rawValue
@@ -123,6 +125,8 @@ let generate = command(
123125
let targetName = try processInfo.environmentVariable(name: EnvironmentKeys.target)
124126
let bundleIdentifier = try processInfo.environmentVariable(name: EnvironmentKeys.bundleIdentifier)
125127
let productModuleName = try processInfo.environmentVariable(name: EnvironmentKeys.productModuleName)
128+
let infoPlistFile = try processInfo.environmentVariable(name: EnvironmentKeys.infoPlistFile)
129+
let codeSignEntitlements = processInfo.environment[EnvironmentKeys.codeSignEntitlements]
126130

127131
let buildProductsDirPath = try processInfo.environmentVariable(name: EnvironmentKeys.buildProductsDir)
128132
let developerDirPath = try processInfo.environmentVariable(name: EnvironmentKeys.developerDir)
@@ -203,6 +207,8 @@ let generate = command(
203207
targetName: targetName,
204208
bundleIdentifier: bundleIdentifier,
205209
productModuleName: productModuleName,
210+
infoPlistFile: URL(fileURLWithPath: infoPlistFile),
211+
codeSignEntitlements: codeSignEntitlements.map { URL(fileURLWithPath: $0) },
206212

207213
scriptInputFiles: scriptInputFiles,
208214
scriptOutputFiles: scriptOutputFiles,

0 commit comments

Comments
 (0)