@@ -17,7 +17,7 @@ let package = Package(
1717 . library(
1818 name: " SQLClientSwift " ,
1919 targets: [ " SQLClientSwift " ]
20- ) ,
20+ )
2121 ] ,
2222
2323 targets: [
@@ -27,10 +27,10 @@ let package = Package(
2727 // On macOS/iOS you still need to link libsybdb.a manually.
2828 . systemLibrary(
2929 name: " CFreeTDS " ,
30- pkgConfig: " freetds " , // resolved via `pkg-config freetds`
30+ pkgConfig: " freetds " , // resolved via `pkg-config freetds`
3131 providers: [
32- . brew( [ " freetds " ] ) , // macOS: brew install freetds
33- . apt( [ " freetds-dev " ] ) , // Linux: apt install freetds-dev
32+ . brew( [ " freetds " ] ) , // macOS: brew install freetds
33+ . apt( [ " freetds-dev " ] ) , // Linux: apt install freetds-dev
3434 ]
3535 ) ,
3636
@@ -39,14 +39,35 @@ let package = Package(
3939 name: " SQLClientSwift " ,
4040 dependencies: [ " CFreeTDS " ] ,
4141 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+ ] ,
4250 swiftSettings: [
43- // Enable strict concurrency checking (Swift 5.9+)
4451 . 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] ) ) ,
4562 ] ,
4663 linkerSettings: [
47- . unsafeFlags( [ " -L/opt/homebrew/opt/freetds/lib " ] , . when( platforms: [ . macOS] ) ) ,
64+ . unsafeFlags(
65+ [
66+ " -L/opt/homebrew/opt/freetds/lib " , // Apple Silicon
67+ " -L/usr/local/opt/freetds/lib " , // Intel
68+ ] , . when( platforms: [ . macOS] ) ) ,
4869 . linkedLibrary( " sybdb " ) ,
49- . linkedLibrary( " iconv " , . when( platforms: [ . macOS] ) )
70+ . linkedLibrary( " iconv " , . when( platforms: [ . macOS] ) ) ,
5071 ]
5172 ) ,
5273
@@ -56,7 +77,30 @@ let package = Package(
5677 . testTarget(
5778 name: " SQLClientSwiftTests " ,
5879 dependencies: [ " SQLClientSwift " ] ,
59- path: " Tests/SQLClientSwiftTests "
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+ ]
60104 ) ,
61105 ]
62106)
0 commit comments