mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
add format code script
This commit is contained in:
@@ -31,12 +31,12 @@ public class PBXProjGenerator {
|
||||
var carthageFrameworksByPlatform: [String: [String]] = [:]
|
||||
var frameworkFiles: [String] = []
|
||||
|
||||
var uuids:Set<String> = []
|
||||
var uuids: Set<String> = []
|
||||
var projectReference: String
|
||||
|
||||
public init(spec: ProjectSpec, path: Path) {
|
||||
self.spec = spec
|
||||
self.basePath = path
|
||||
basePath = path
|
||||
|
||||
projectReference = ""
|
||||
projectReference = generateUUID(PBXProject.self, spec.name)
|
||||
@@ -51,7 +51,7 @@ public class PBXProjGenerator {
|
||||
repeat {
|
||||
counter += 1
|
||||
uuid = "\(classAcronym)\(stringID)\(String(format: "%02d", counter))"
|
||||
} while(uuids.contains(uuid))
|
||||
} while (uuids.contains(uuid))
|
||||
return uuid
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public class PBXProjGenerator {
|
||||
return SourceFile(path: path, fileReference: fileReference, buildFile: buildFile)
|
||||
}
|
||||
|
||||
func generateTarget(_ target: Target) throws -> PBXNativeTarget {
|
||||
func generateTarget(_ target: Target) throws -> PBXNativeTarget {
|
||||
|
||||
let sourcePaths = target.sources.map { basePath + $0 }
|
||||
var sourceFilePaths: [Path] = []
|
||||
@@ -161,17 +161,17 @@ public class PBXProjGenerator {
|
||||
switch dependancy {
|
||||
case let .target(dependencyTarget):
|
||||
let targetProxy = PBXContainerItemProxy(reference: generateUUID(PBXContainerItemProxy.self, target.name), containerPortal: projectReference, remoteGlobalIDString: targetNativeReferences[dependencyTarget]!, proxyType: .nativeTarget, remoteInfo: dependencyTarget)
|
||||
let targetDependancy = PBXTargetDependency(reference: generateUUID(PBXTargetDependency.self, dependencyTarget), target: targetNativeReferences[dependencyTarget]!, targetProxy: targetProxy.reference )
|
||||
let targetDependancy = PBXTargetDependency(reference: generateUUID(PBXTargetDependency.self, dependencyTarget), target: targetNativeReferences[dependencyTarget]!, targetProxy: targetProxy.reference)
|
||||
|
||||
objects.append(.pbxContainerItemProxy(targetProxy))
|
||||
objects.append(.pbxTargetDependency(targetDependancy))
|
||||
dependancies.append(targetDependancy.reference)
|
||||
|
||||
let dependencyBuildFile = targetBuildFileReferences[dependencyTarget]!
|
||||
//link
|
||||
// link
|
||||
targetFrameworkBuildFiles.append(dependencyBuildFile)
|
||||
|
||||
//embed
|
||||
// embed
|
||||
let embedSettings: [String: Any] = ["ATTRIBUTES": ["CodeSignOnCopy", "RemoveHeadersOnCopy"]]
|
||||
let embedFile = PBXBuildFile(reference: generateUUID(PBXBuildFile.self, targetFileReferences[dependencyTarget]!), fileRef: targetFileReferences[dependencyTarget]!, settings: embedSettings)
|
||||
objects.append(.pbxBuildFile(embedFile))
|
||||
@@ -216,7 +216,7 @@ public class PBXProjGenerator {
|
||||
objects.append(.pbxBuildFile(buildFile))
|
||||
}
|
||||
|
||||
//TODO: don't generate build files for files that won't be built
|
||||
// TODO: don't generate build files for files that won't be built
|
||||
|
||||
func getBuildFilesForPhase(_ buildPhase: BuildPhase) -> Set<String> {
|
||||
let files = sourceFilePaths.filter { getBuildPhaseForPath($0) == buildPhase }.map(generateSourceFile)
|
||||
@@ -243,15 +243,14 @@ public class PBXProjGenerator {
|
||||
objects.append(.pbxCopyFilesBuildPhase(copyFilesPhase))
|
||||
buildPhases.append(copyFilesPhase.reference)
|
||||
|
||||
|
||||
if target.type == .application {
|
||||
func getCarthageFrameworks(target: Target) -> [String] {
|
||||
var frameworks: [String] = []
|
||||
for dependency in target.dependencies {
|
||||
switch dependency {
|
||||
case .carthage(let framework): frameworks.append(framework)
|
||||
case .target(let targetName):
|
||||
if let target = spec.targets.first(where: {$0.name == targetName}) {
|
||||
case let .carthage(framework): frameworks.append(framework)
|
||||
case let .target(targetName):
|
||||
if let target = spec.targets.first(where: { $0.name == targetName }) {
|
||||
frameworks += getCarthageFrameworks(target: target)
|
||||
}
|
||||
default: break
|
||||
@@ -360,5 +359,4 @@ public class PBXProjGenerator {
|
||||
groups.insert(group, at: 0)
|
||||
return (allFilePaths, groups)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ProjectGenerator {
|
||||
|
||||
for target in spec.targets {
|
||||
for dependency in target.dependencies {
|
||||
if case .target(let targetName) = dependency, spec.getTarget(targetName) == nil {
|
||||
if case let .target(targetName) = dependency, spec.getTarget(targetName) == nil {
|
||||
errors.append(.invalidTargetDependency(target: target.name, dependency: targetName))
|
||||
}
|
||||
}
|
||||
@@ -95,19 +95,19 @@ public class ProjectGenerator {
|
||||
errors.append(.invalidSchemeTarget(scheme: scheme.name, target: buildTarget.target))
|
||||
}
|
||||
}
|
||||
if let buildAction = scheme.run, spec.getConfig(buildAction.config) == nil {
|
||||
if let buildAction = scheme.run, spec.getConfig(buildAction.config) == nil {
|
||||
errors.append(.invalidSchemeConfig(scheme: scheme.name, config: buildAction.config))
|
||||
}
|
||||
if let buildAction = scheme.test, spec.getConfig(buildAction.config) == nil {
|
||||
if let buildAction = scheme.test, spec.getConfig(buildAction.config) == nil {
|
||||
errors.append(.invalidSchemeConfig(scheme: scheme.name, config: buildAction.config))
|
||||
}
|
||||
if let buildAction = scheme.profile, spec.getConfig(buildAction.config) == nil {
|
||||
if let buildAction = scheme.profile, spec.getConfig(buildAction.config) == nil {
|
||||
errors.append(.invalidSchemeConfig(scheme: scheme.name, config: buildAction.config))
|
||||
}
|
||||
if let buildAction = scheme.analyze, spec.getConfig(buildAction.config) == nil {
|
||||
if let buildAction = scheme.analyze, spec.getConfig(buildAction.config) == nil {
|
||||
errors.append(.invalidSchemeConfig(scheme: scheme.name, config: buildAction.config))
|
||||
}
|
||||
if let buildAction = scheme.archive, spec.getConfig(buildAction.config) == nil {
|
||||
if let buildAction = scheme.archive, spec.getConfig(buildAction.config) == nil {
|
||||
errors.append(.invalidSchemeConfig(scheme: scheme.name, config: buildAction.config))
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class ProjectGenerator {
|
||||
|
||||
let buildAction = XCScheme.BuildAction(buildActionEntries: buildActionEntries, parallelizeBuild: true, buildImplicitDependencies: true)
|
||||
|
||||
let testAction = XCScheme.TestAction(buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, macroExpansion: buildableReference)
|
||||
let testAction = XCScheme.TestAction(buildConfiguration: scheme.test?.config ?? defaultDebugConfig.name, macroExpansion: buildableReference)
|
||||
|
||||
let launchAction = XCScheme.LaunchAction(buildableProductRunnable: productRunabke,
|
||||
buildConfiguration: scheme.run?.config ?? defaultDebugConfig.name)
|
||||
|
||||
@@ -55,7 +55,6 @@ extension ProjectSpec {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var buildSettingFiles: [String: BuildSettings] = [:]
|
||||
|
||||
extension SettingsPresetFile {
|
||||
|
||||
Reference in New Issue
Block a user