@@ -16,36 +16,33 @@ import POSIX
16
16
Generates an xcodeproj at the specified path.
17
17
- Returns: the path to the generated project
18
18
*/
19
- public func generate( path path : String , package : Package , modules: [ SwiftModule ] , products: [ Product ] ) throws -> String {
19
+ public func generate( dstdir dstdir : String , projectName : String , srcroot : String , modules: [ SwiftModule ] , products: [ Product ] ) throws -> String {
20
20
21
- /// If a specific *.xcodeproj path is already passed in, use that.
22
- /// Otherwise treat the path as the desired enclosing folder for
23
- /// the .xcodeproj folder.
24
- let rootdir = path. hasSuffix ( " .xcodeproj " ) ? path : Path . join ( path, " \( package . name) .xcodeproj " )
25
- try mkdir ( rootdir)
26
-
27
- let schemedir = try mkdir ( rootdir, " xcshareddata/xcschemes " )
21
+ let xcodeprojName = " \( projectName) .xcodeproj "
22
+ let xcodeprojPath = try mkdir ( dstdir, xcodeprojName)
23
+ let schemesDirectory = try mkdir ( xcodeprojPath, " xcshareddata/xcschemes " )
24
+ let schemeName = " \( projectName) .xcscheme "
28
25
29
26
////// the pbxproj file describes the project and its targets
30
- try open ( rootdir , " project.pbxproj " ) { fwrite in
31
- pbxproj ( projectPath : path , package : package , modules: modules, products: products, printer: fwrite)
27
+ try open ( xcodeprojPath , " project.pbxproj " ) { fwrite in
28
+ pbxproj ( srcroot : srcroot , projectRoot : dstdir , modules: modules, products: products, printer: fwrite)
32
29
}
33
30
34
31
////// the scheme acts like an aggregate target for all our targets
35
32
/// it has all tests associated so CMD+U works
36
- try open ( schemedir , " \( package . name ) .xcscheme " ) { fwrite in
37
- xcscheme ( packageName : package . name , modules: modules, printer: fwrite)
33
+ try open ( schemesDirectory , schemeName ) { fwrite in
34
+ xcscheme ( container : xcodeprojName , modules: modules, printer: fwrite)
38
35
}
39
36
40
37
////// we generate this file to ensure our main scheme is listed
41
38
/// before any inferred schemes Xcode may autocreate
42
- try open ( schemedir , " xcschememanagement.plist " ) { fwrite in
39
+ try open ( schemesDirectory , " xcschememanagement.plist " ) { fwrite in
43
40
fwrite ( " <?xml version= \" 1.0 \" encoding= \" UTF-8 \" ?> " )
44
41
fwrite ( " <plist version= \" 1.0 \" > " )
45
42
fwrite ( " <dict> " )
46
43
fwrite ( " <key>SchemeUserState</key> " )
47
44
fwrite ( " <dict> " )
48
- fwrite ( " <key> \( package . name ) .xcscheme </key>" )
45
+ fwrite ( " <key> \( schemeName ) </key> " )
49
46
fwrite ( " <dict></dict> " )
50
47
fwrite ( " </dict> " )
51
48
fwrite ( " <key>SuppressBuildableAutocreation</key> " )
@@ -54,7 +51,7 @@ public func generate(path path: String, package: Package, modules: [SwiftModule]
54
51
fwrite ( " </plist> " )
55
52
}
56
53
57
- return rootdir
54
+ return xcodeprojPath
58
55
}
59
56
60
57
0 commit comments