Skip to content

Commit

Permalink
Use info plist file and code sign entitlements from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlokhorst committed Apr 20, 2020
1 parent c726c82 commit 509970a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Sources/RswiftCore/CallInformation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public struct CallInformation {
let targetName: String
let bundleIdentifier: String
let productModuleName: String
let infoPlistFile: URL
let codeSignEntitlements: URL?

let scriptInputFiles: [String]
let scriptOutputFiles: [String]
Expand All @@ -47,6 +49,8 @@ public struct CallInformation {
targetName: String,
bundleIdentifier: String,
productModuleName: String,
infoPlistFile: URL,
codeSignEntitlements: URL?,

scriptInputFiles: [String],
scriptOutputFiles: [String],
Expand All @@ -70,6 +74,8 @@ public struct CallInformation {
self.targetName = targetName
self.bundleIdentifier = bundleIdentifier
self.productModuleName = productModuleName
self.infoPlistFile = infoPlistFile
self.codeSignEntitlements = codeSignEntitlements

self.scriptInputFiles = scriptInputFiles
self.scriptOutputFiles = scriptOutputFiles
Expand Down
15 changes: 7 additions & 8 deletions Sources/RswiftCore/RswiftCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,18 @@ public struct RswiftCore {
structGenerators.append(AccessibilityIdentifierStructGenerator(nibs: resources.nibs, storyboards: resources.storyboards))
}
if callInformation.generators.contains(.info) {
let infoPlists = buildConfigurations.compactMap {
return loadPropertyList(name: $0.name, path: $0.infoPlistPath, callInformation: callInformation)

let infoPlists = buildConfigurations.compactMap { config in
return loadPropertyList(name: config.name, url: callInformation.infoPlistFile, callInformation: callInformation)
}

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

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

structGenerators.append(PropertyListGenerator(name: "entitlements", plists: entitlements, toplevelKeysWhitelist: nil))
Expand Down Expand Up @@ -164,10 +165,8 @@ public struct RswiftCore {
}
}

private func loadPropertyList(name: String, path: Path?, callInformation: CallInformation) -> PropertyList? {
guard let path = path else { return nil }
private func loadPropertyList(name: String, url: URL, callInformation: CallInformation) -> PropertyList? {
do {
let url = path.url(with: callInformation.urlForSourceTreeFolder)
return try PropertyList(buildConfigurationName: name, url: url)
} catch let ResourceParsingError.parsingFailed(humanReadableError) {
warn(humanReadableError)
Expand Down
6 changes: 6 additions & 0 deletions Sources/rswift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct EnvironmentKeys {
static let target = "TARGET_NAME"
static let tempDir = "TEMP_DIR"
static let xcodeproj = "PROJECT_FILE_PATH"
static let infoPlistFile = "INFOPLIST_FILE"
static let codeSignEntitlements = "CODE_SIGN_ENTITLEMENTS"

static let buildProductsDir = SourceTreeFolder.buildProductsDir.rawValue
static let developerDir = SourceTreeFolder.developerDir.rawValue
Expand Down Expand Up @@ -123,6 +125,8 @@ let generate = command(
let targetName = try processInfo.environmentVariable(name: EnvironmentKeys.target)
let bundleIdentifier = try processInfo.environmentVariable(name: EnvironmentKeys.bundleIdentifier)
let productModuleName = try processInfo.environmentVariable(name: EnvironmentKeys.productModuleName)
let infoPlistFile = try processInfo.environmentVariable(name: EnvironmentKeys.infoPlistFile)
let codeSignEntitlements = processInfo.environment[EnvironmentKeys.codeSignEntitlements]

let buildProductsDirPath = try processInfo.environmentVariable(name: EnvironmentKeys.buildProductsDir)
let developerDirPath = try processInfo.environmentVariable(name: EnvironmentKeys.developerDir)
Expand Down Expand Up @@ -203,6 +207,8 @@ let generate = command(
targetName: targetName,
bundleIdentifier: bundleIdentifier,
productModuleName: productModuleName,
infoPlistFile: URL(fileURLWithPath: infoPlistFile),
codeSignEntitlements: codeSignEntitlements.map { URL(fileURLWithPath: $0) },

scriptInputFiles: scriptInputFiles,
scriptOutputFiles: scriptOutputFiles,
Expand Down

0 comments on commit 509970a

Please sign in to comment.