The better way to manage the Xcode project file (project.pbxproj) in swift. This swift module lets you automate the modification process.
- macOS 10.12+
- Xcode 8+
.package(url: "https://github.com/0x973/XcodeManager.git", from: "0.2.0")
You can use Carthage to install XcodeManager
by adding it to your Cartfile:
github "0x973/XcodeManager" ~> 0.2.0
- import module.
import XcodeManager
- Initialize the Xcode project file.
var project = try? XcodeManager(projectFile: "../.../xxx.xcodeproj", printLog: true)
- How to add static library in Xcode project?
project.linkStaticLibrary("../.../test.a")
- How to add framework in Xcode project?
project.linkFramework("../.../test.framework")
- How to add resources folder in Xcode project?
project.addFolder("../.../test/")
- How to add a single resources file in Xcode project?
project.addFile("../.../test.txt")
- How to modify the product name (display name)?
project.setProductName("TestProduct")
- How to modify the Bundle Identifier?
project.setBundleId("cn.x0x01.TestProduct")
- How to add new value?
project.setLibrarySearchPathValue("$(PROJECT_DIR)/TestProduct/Folder")
- How to add new value?
project.setFrameworkSearchPathValue("$(PROJECT_DIR)/TestProduct/Folder")
- How to control the CodeSignStyle(manual OR automatic)?
project.setCodeSignStyle(type: .automatic)
project.setCodeSignStyle(type: .manual)
- Complete modification? Write to a .pbxproj file!
let isSaveSuccess = try? project.save()
if (isSaveSuccess) {
print("Done!")
}