@@ -3,11 +3,22 @@ import Foundation
33public class PackageFileGenerator {
44 let packageName : String
55 let targetName : String
6+ let hasTests : Bool
67 let capRepoName = " capacitor-swift-pm "
78 let capLocation = " https://github.com/ionic-team/capacitor-swift-pm.git "
89 let capVersion = " 8.0.0 "
910
1011 var packageText : String {
12+ var testTargetText = " "
13+ if hasTests {
14+ testTargetText = """
15+ ,
16+ .testTarget(
17+ name: " \( targetName) Tests " ,
18+ dependencies: [ " \( targetName) " ],
19+ path: " ios/Tests/ \( targetName) Tests " )
20+ """
21+ }
1122 return """
1223 // swift-tools-version: 5.9
1324 import PackageDescription
@@ -30,19 +41,16 @@ public class PackageFileGenerator {
3041 .product(name: " Capacitor " , package: " \( capRepoName) " ),
3142 .product(name: " Cordova " , package: " \( capRepoName) " )
3243 ],
33- path: " ios/Sources/ \( targetName) " ),
34- .testTarget(
35- name: " \( targetName) Tests " ,
36- dependencies: [ " \( targetName) " ],
37- path: " ios/Tests/ \( targetName) Tests " )
44+ path: " ios/Sources/ \( targetName) " ) \( testTargetText)
3845 ]
3946 )
4047 """
4148 }
4249
43- public init ( packageName: String , targetName: String ) {
50+ public init ( packageName: String , targetName: String , hasTests : Bool ) {
4451 self . packageName = packageName
4552 self . targetName = targetName
53+ self . hasTests = hasTests
4654 }
4755
4856 public func generateFile( at fileURL: URL ) throws {
0 commit comments