forked from tomlokhorst/XcodeEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.swift
More file actions
67 lines (54 loc) · 1.9 KB
/
main.swift
File metadata and controls
67 lines (54 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// main.swift
// Example
//
// Created by Tom Lokhorst on 2015-08-14.
// Copyright (c) 2015 nonstrict. All rights reserved.
//
import Foundation
let args = CommandLine.arguments
if args.count < 2 {
print("Call with a .xcodeproj, e.g.: \"$SRCROOT/../Test projects/HelloCpp.xcodeproj\"")
}
let start = Date()
// The xcodeproj file to load, test this with your own project!
let xcodeproj = URL(fileURLWithPath: args[1])
let proj = try! XCProjectFile(xcodeprojURL: xcodeproj)
// Write out a new pbxproj file
try! proj.write(to: xcodeproj, format: PropertyListSerialization.PropertyListFormat.openStep)
let time = Date().timeIntervalSince(start)
print("Timeinterval: \(time)")
//exit(0)
// Print paths for all files in Resources build phases
//for target in proj.project.targets.flatMap({ $0.value }) {
// for resourcesBuildPhase in target.buildPhases.flatMap({ $0.value }) {
// let files = resourcesBuildPhase.files.flatMap { $0.value }
// for file in files {
// if let fileReference = file.fileRef?.value as? PBXFileReference {
// print(fileReference.fullPath!)
// }
// // Variant groups are localizable
// else if let variantGroup = file.fileRef?.value as? PBXVariantGroup {
// let fileRefs = variantGroup.fileRefs.flatMap { $0.value }
// for variantFileReference in fileRefs {
// print(variantFileReference.fullPath!)
// }
// }
// }
// }
//}
// Print shells
for target in proj.project.targets.compactMap({ $0.value }) {
print("Target \(target.name) - \(target.isa): \(target.buildPhases.count)")
for bc in target.buildConfigurationList.value!.buildConfigurations.map({ $0.value! }) {
print(bc.fields)
}
print("--")
for buildPhase in target.buildPhases {
print(buildPhase.value!)
// if let shellScriptPhase = buildPhase.value as? PBXShellScriptBuildPhase {
// print(shellScriptPhase.shellScript)
// }
print()
}
}