11// swift-tools-version: 5.9
2- // Package.swift for vkuttyp/SQLClient-Swift
3-
42import PackageDescription
53
64let package = Package (
75 name: " SQLClientSwift " ,
8-
9- // Explicit platform minimums — required for async/await and modern Swift Concurrency.
106 platforms: [
117 . iOS( . v16) ,
128 . macOS( . v13) ,
139 . tvOS( . v16) ,
1410 ] ,
15-
1611 products: [
1712 . library(
1813 name: " SQLClientSwift " ,
1914 targets: [ " SQLClientSwift " ]
20- )
15+ ) ,
2116 ] ,
22-
2317 targets: [
24- // ── System library target for FreeTDS ─────────────────────────────
25- // Enables `import CFreeTDS` in Swift without a bridging header,
26- // which is required for Linux / Swift Package Manager builds.
27- // On macOS/iOS you still need to link libsybdb.a manually.
18+ // systemLibrary uses pkg-config to find FreeTDS at build time.
19+ // No hardcoded paths, no unsafeFlags — works as an SPM dependency.
20+ // macOS : brew install freetds && brew install pkg-config
21+ // Linux : sudo apt install freetds-dev
2822 . systemLibrary(
2923 name: " CFreeTDS " ,
30- pkgConfig: " freetds " , // resolved via `pkg-config freetds`
24+ path: " Sources/CFreeTDS " ,
25+ pkgConfig: " freetds " ,
3126 providers: [
32- . brew( [ " freetds " ] ) , // macOS: brew install freetds
33- . apt( [ " freetds-dev " ] ) , // Linux: apt install freetds-dev
27+ . brew( [ " freetds " ] ) ,
28+ . apt( [ " freetds-dev " ] ) ,
3429 ]
3530 ) ,
36-
37- // ── Main library target ───────────────────────────────────────────
3831 . target(
3932 name: " SQLClientSwift " ,
4033 dependencies: [ " CFreeTDS " ] ,
4134 path: " Sources/SQLClientSwift " ,
42- cSettings: [
43- // Added compiler flags to direct CC to look for freetds in both
44- // MacOS intel and MacOS Arm directories.
45- . unsafeFlags( [
46- " -I/opt/homebrew/opt/freetds/include/ " , // Apple Silicon
47- " -I/usr/local/opt/freetds/include/ " , // Intel
48- ] )
49- ] ,
5035 swiftSettings: [
5136 . enableExperimentalFeature( " StrictConcurrency=complete " ) ,
52- // Pass both Homebrew prefix locations to the C compiler so
53- // angle bracket includes in CFreeTDS.h resolve on both
54- // Intel (/usr/local) and Apple Silicon (/opt/homebrew) Macs.
55- // The compiler silently ignores paths that don't exist,
56- // so providing both is safe.
57- . unsafeFlags(
58- [
59- " -Xcc " , " -I/opt/homebrew/opt/freetds/include/ " , // Apple Silicon
60- " -Xcc " , " -I/usr/local/opt/freetds/include/ " , // Intel
61- ] , . when( platforms: [ . macOS] ) ) ,
62- ] ,
63- linkerSettings: [
64- . unsafeFlags(
65- [
66- " -L/opt/homebrew/opt/freetds/lib " , // Apple Silicon
67- " -L/usr/local/opt/freetds/lib " , // Intel
68- ] , . when( platforms: [ . macOS] ) ) ,
69- . linkedLibrary( " sybdb " ) ,
70- . linkedLibrary( " iconv " , . when( platforms: [ . macOS] ) ) ,
7137 ]
7238 ) ,
73-
74- // ── Unit & integration test target ───────────────────────────────
75- // Integration tests require a live SQL Server; controlled via
76- // environment variables HOST, DATABASE, USERNAME, PASSWORD.
7739 . testTarget(
7840 name: " SQLClientSwiftTests " ,
7941 dependencies: [ " SQLClientSwift " ] ,
80- path: " Tests/SQLClientSwiftTests " ,
81- cSettings: [
82- . unsafeFlags( [
83- " -I/opt/homebrew/opt/freetds/include/ " , // Apple Silicon
84- " -I/usr/local/opt/freetds/include/ " , // Intel
85- ] )
86- ] ,
87- swiftSettings: [
88- . enableExperimentalFeature( " StrictConcurrency=complete " ) ,
89- . unsafeFlags(
90- [
91- " -Xcc " , " -I/opt/homebrew/opt/freetds/include/ " , // Apple Silicon
92- " -Xcc " , " -I/usr/local/opt/freetds/include/ " , // Intel
93- ] , . when( platforms: [ . macOS] ) ) ,
94- ] ,
95- linkerSettings: [
96- . unsafeFlags(
97- [
98- " -L/opt/homebrew/opt/freetds/lib " , // Apple Silicon
99- " -L/usr/local/opt/freetds/lib " , // Intel
100- ] , . when( platforms: [ . macOS] ) ) ,
101- . linkedLibrary( " sybdb " ) ,
102- . linkedLibrary( " iconv " , . when( platforms: [ . macOS] ) ) ,
103- ]
42+ path: " Tests/SQLClientSwiftTests "
10443 ) ,
10544 ]
106- )
45+ )
0 commit comments