ProjectKit is a Swift framework for parsing Xcode project files.
Here's an example that loads an Xcode project file and prints the name of all targets in the project.
import ProjectKit
let url = URL(fileURLWithPath: "<YourProject>.pbxproj")
do {
let project = try XcodeProject(url: url)
print(project)
for (targetID, target) in project.nativeTargets {
print(target.name)
}
} catch XcodeProjectError.failedToOpenProjectFile {
print("Failed to open project file.")
} catch XcodeProjectError.failedToParseProjectFile {
print("Failed to parse project file.")
}
ProjectKit is Carthage compatible.
-
Add
Carthage/Build
andCarthage/Checkouts
to your .gitignore, if you're using git. -
Create a Carthage folder in your repo. You could name it
Carthage
, for example. -
Create a text file in that folder and name it
Cartfile
. -
Add the following line to the
Cartfile
:git "git@github.com:apparata/ProjectKit.git" "master"
-
Then update using Carthage from the command line for whichever platform you want to build for:
carthage update
-
Build result (
ProjectKit.framework
) is found inCarthage/Build/Mac/
. -
Make sure you check in
Cartfile.resolved
. -
Add ProjectKit.framework to your project.