@@ -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,25 +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: [
4351 . enableExperimentalFeature( " StrictConcurrency=complete " ) ,
4452 // Pass both Homebrew prefix locations to the C compiler so
4553 // angle bracket includes in CFreeTDS.h resolve on both
4654 // Intel (/usr/local) and Apple Silicon (/opt/homebrew) Macs.
4755 // The compiler silently ignores paths that don't exist,
4856 // so providing both is safe.
49- . unsafeFlags( [
50- " -Xcc " , " -I/opt/homebrew/opt/freetds/include " , // Apple Silicon
51- " -Xcc " , " -I/usr/local/opt/freetds/include " , // Intel
52- ] , . when( platforms: [ . macOS] ) ) ,
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] ) ) ,
5362 ] ,
5463 linkerSettings: [
55- . unsafeFlags( [
56- " -L/opt/homebrew/opt/freetds/lib " , // Apple Silicon
57- " -L/usr/local/opt/freetds/lib " , // Intel
58- ] , . 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] ) ) ,
5969 . linkedLibrary( " sybdb " ) ,
60- . linkedLibrary( " iconv " , . when( platforms: [ . macOS] ) )
70+ . linkedLibrary( " iconv " , . when( platforms: [ . macOS] ) ) ,
6171 ]
6272 ) ,
6373
@@ -67,7 +77,30 @@ let package = Package(
6777 . testTarget(
6878 name: " SQLClientSwiftTests " ,
6979 dependencies: [ " SQLClientSwift " ] ,
70- 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+ ]
71104 ) ,
72105 ]
73106)
0 commit comments