-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPbxprojParser.swift
More file actions
33 lines (29 loc) · 1.06 KB
/
PbxprojParser.swift
File metadata and controls
33 lines (29 loc) · 1.06 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
//
// PbxprojParser.swift
// XcodeHelper
//
// Created by dhcdht on 2016/11/1.
// Copyright © 2016年 XH. All rights reserved.
//
import Cocoa
class PbxprojParser: NSObject {
class func xcpluginNameFromPbxproj(path: String?) -> String? {
guard let path = path else {
return nil
}
do {
let pbxproj = try String(contentsOfFile: path, encoding: .utf8)
let regex = try NSRegularExpression(pattern: "(\\w[\\w\\s\\.-]*\\w\\.(xc|ide)plugin\\s)", options: [.anchorsMatchLines])
let result = regex.firstMatch(in: pbxproj, options: [], range: NSRange(location: 0, length: pbxproj.lengthOfBytes(using: pbxproj.smallestEncoding)))
if let resultRange = result?.rangeAt(0) {
var subString = (pbxproj as NSString).substring(with: resultRange)
subString = subString.trimmingCharacters(in: .whitespacesAndNewlines)
return subString
} else {
return nil
}
} catch {
return nil
}
}
}