@@ -28,6 +28,32 @@ extension Punic {
2828 func run( options: Punic . Options ) {
2929 let rootPath = options. rootPath ( extension: . xcworkspace)
3030 let carthagePath : Path = rootPath + sourceDir
31+
32+ var created = false
33+ if options. filePath ( extension: . xcworkspace) == nil ,
34+ let projectPath: Path = options. filePath ( extension: . xcodeproj) {
35+ // if no workspace but a project we could create it
36+ let xmlString = """
37+ <?xml version= " 1.0 " encoding= " UTF-8 " ?>
38+ <Workspace
39+ version = " 1.0 " >
40+ <FileRef
41+ location = " container: \( projectPath. fileName) " >
42+ </FileRef>
43+ </Workspace>
44+ """
45+ let workspacePath : Path = projectPath. of ( extension: . xcworkspace)
46+ if let data = xmlString. data ( using: . utf8) {
47+ do {
48+ try workspacePath. createDirectory ( )
49+ try DataFile ( path: workspacePath + " contents.xcworkspacedata " ) . write ( data)
50+ created = true
51+ } catch let ioError {
52+ options. error ( " Cannot save new create workspace \( ioError) " )
53+ }
54+ }
55+ }
56+
3157 guard let workspacePath: Path = options. filePath ( extension: . xcworkspace) else {
3258 options. error ( " Cannot find workspace in \( rootPath) " ) // XXX maybe create an empty one
3359 return
@@ -72,7 +98,7 @@ extension Punic {
7298 if hasChange, let newData = workspaceDocument. xml. data ( using: . utf8) {
7399 do {
74100 try workspaceDataFile. write ( newData)
75- options. log ( " 💾 Workspace saved " )
101+ options. log ( " 💾 Workspace \( created ? " created " : " saved " ) " )
76102 } catch let ioError {
77103 options. error ( " Cannot save workspace \( ioError) " )
78104 }
0 commit comments