Swiftpack.co - Package - bannzai/XcodeProject

XcodeProject

XcodeProject is a library for Xcode utility for read structure and it can be overwrite for`project.pbxproj.
And XcodeProject package has executable library about append and remove files and directory to your xcode project on CLI named by xcp.

About XcodeProject Library

Usage XcodeProject Core Function.

Instanciate XcodeProject class. XcodeProject is necessary edit for project.pbxproj.

// Prepare for your project `project.pbxproj` file path.
let yourProjectPath = "/Users/bannzai/development/iOSProject/iOSProject.xcodeproj"
let pbxPath = yourProjectPath + "/project.pbxproj"
let xcodeprojectFileURL = URL(fileURLWithPath: pbxPath)

// Instanciate `XcodeProject`.
let xcodeproject = try XcodeProject(xcodeprojectURL: xcodeprojectFileURL)

Append file with relative wfile path from iOSProject.xcodeproject directory and build target name.

xcodeproject.appendFile(path: "iOSProject/Repository/UserRepository.swift", targetName: "iOSProject")

Remove file with relative wfile path from iOSProject.xcodeproject directory and build target name.

// append file with file path and build target name. 
xcodeproject.removeFile(path: "Config.swift", targetName: "iOSProject")

If you want overwrite project.pbxproj, You can call xcodeproject.write() method.

// Overwrite in pbxproj.
try xcodeproject.write()

Command Line Tool

Install

Using mint.

$ mint install bannzai/XcodeProject

Usage

Add file

xcp --add-file <FILE_PATH> <BUILD_TARGET_NAME>

$ xcp --add-file iOSProject/Group/A.swift iOSProject.xcodeproj/project.pbxproj iOSProject 

Add group

xcp --add-group <FILE_PATH> <BUILD_TARGET_NAME>

$ xcp --add-group iOSProject/Group/ iOSProject.xcodeproj/project.pbxproj iOSProject

Remove file

xcp --remove-file <FILE_PATH> <BUILD_TARGET_NAME>

$ xcp --remove-file iOSProject/Group/A.swift iOSProject.xcodeproj/project.pbxproj iOSProject 

Remove group

xcp --remove-group <FILE_PATH> <BUILD_TARGET_NAME>

$ xcp --remove-group iOSProject/Group/ iOSProject.xcodeproj/project.pbxproj iOSProject

Used in

Kuri

Kuri is code generate for iOS CleanArchitecture.

License

XcodeProject is available under the MIT license. See the LICENSE file for more info.

Github

link
Stars: 45

Used By

Total: 0

Releases

Support Swift Package Manager Dependency - 2020-05-10 15:06:31

Separate dependencies between `XcodeProject` and example project. - 2020-01-21 08:49:01

- 2019-12-01 17:27:56

Append Resources Build Phase - 2018-01-03 06:08:25

Fix generate directories - 2018-01-03 04:18:50

Fix file extension - 2018-01-03 01:45:03

0.1.2 - 2017-11-01 15:04:38

publish access control for using kuri.

Bugfix for remake filerefs and subgroups - 2017-10-14 03:29:06

First Release. - 2017-10-08 23:38:51

Read and write pbxproj file. Append new file to pbxproj

let pbxPath = projectFilePath + "project.pbxproj"
let xcodeprojectFileUrl = URL(fileURLWithPath: pbxPath)

// Read pbxproj when create XCProject instance
let project = try XCProject(for: xcodeprojectFileUrl)

// Append for PBX Object with
// project root direcotry path,
// will append file path relative for project root directory path,
// will append project target name.
...
project.appendFilePath(
    with: projectRootPath,
    filePath: filePath,
    targetName: targetName
)
...

// Write in pbxproj.
// If you added the PBX Object it will be reflected
try project.write()