Skip to content

Commit ac582cd

Browse files
committed
Incorporate documentation and PKG-Config improvements from PR #9
1 parent 782f35a commit ac582cd

File tree

2 files changed

+41
-24
lines changed

2 files changed

+41
-24
lines changed

README.md

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,47 +33,59 @@ This is a Swift rewrite and modernisation of [martinrybak/SQLClient](https://git
3333
| tvOS | 16.0 |
3434
| Xcode | 15.0 |
3535
| Swift | 5.9 |
36+
| PKG-Config | 0.29+ (macOS) |
3637
| FreeTDS | 1.0 (1.5 recommended) |
3738

3839
---
3940

4041
## Installation
4142

42-
### Swift Package Manager
43+
> **Note for macOS:** If you encounter compilation errors like `'sybdb.h' file not found`, you need to configure `pkg-config` to correctly link your FreeTDS installation. See [PKG-Config Configuration](#pkg-config-configuration) below.
4344
44-
Add the dependency to your `Package.swift`:
45+
### Swift Package Manager
46+
...
47+
**macOS (Homebrew):**
48+
```bash
49+
brew install freetds
50+
```
4551

46-
```swift
47-
dependencies: [
48-
.package(url: "https://github.com/vkuttyp/SQLClient-Swift.git", from: "1.0.0")
49-
],
50-
targets: [
51-
.target(
52-
name: "MyApp",
53-
dependencies: [
54-
.product(name: "SQLClientSwift", package: "SQLClient-Swift")
55-
]
56-
)
57-
]
52+
**Linux (apt):**
53+
```bash
54+
sudo apt install freetds-dev
5855
```
5956

60-
Or in Xcode: **File → Add Package Dependencies…** and enter the repository URL.
57+
**iOS / custom build:** Use a pre-compiled `libsybdb.a` (e.g. from [FreeTDS-iOS](https://github.com/patchhf/FreeTDS-iOS)) and link it manually in your Xcode target under **Build Phases → Link Binary With Libraries**, along with `libiconv.tbd`.
58+
59+
### PKG-Config Configuration (macOS)
6160

62-
### Install FreeTDS
61+
For systems that do not natively include `pkg-config` or where Homebrew does not provide a `.pc` file for FreeTDS (common on macOS), extra steps are required.
6362

64-
SQLClient-Swift wraps FreeTDS — you need the native library present at build time.
63+
**1. Install pkg-config**
6564

66-
**macOS (Homebrew):**
6765
```bash
68-
brew install freetds
66+
brew install pkg-config
6967
```
7068

71-
**Linux (apt):**
69+
**2. Configure freetds.pc**
70+
71+
A `freetds.pc` file is provided in the `ci/` folder of this repository. You need to make this file available to `pkg-config`.
72+
73+
**Option A: Export PKG_CONFIG_PATH (Recommended)**
74+
Point `pkg-config` to the `ci/` folder in your local copy of this repo:
7275
```bash
73-
sudo apt install freetds-dev
76+
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/path/to/SQLClient-Swift/ci"
7477
```
7578

76-
**iOS / custom build:** Use a pre-compiled `libsybdb.a` (e.g. from [FreeTDS-iOS](https://github.com/patchhf/FreeTDS-iOS)) and link it manually in your Xcode target under **Build Phases → Link Binary With Libraries**, along with `libiconv.tbd`.
79+
**Option B: Copy to system path**
80+
Copy the file to your system's pkg-config directory:
81+
```bash
82+
cp ci/freetds.pc /usr/local/lib/pkgconfig/
83+
```
84+
85+
**Note on Intel vs Apple Silicon:**
86+
The provided `ci/freetds.pc` is configured for Apple Silicon (`/opt/homebrew`). If you are on an **Intel Mac**, edit the `prefix` line in the file:
87+
- **Apple Silicon:** `prefix=/opt/homebrew/opt/freetds`
88+
- **Intel:** `prefix=/usr/local/opt/freetds`
7789

7890
---
7991

ci/freetds.pc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# FreeTDS pkg-config file for macOS (Apple Silicon)
2-
# Committed to repo because Homebrew's freetds does not ship a .pc file on macOS.
1+
# FreeTDS pkg-config file for macOS
2+
# Homebrew's freetds does not ship a .pc file on macOS.
33
# Linux users: this file is ignored; FreeTDS is found via system pkg-config.
4+
5+
# --- PREFIX CONFIGURATION ---
6+
# Apple Silicon (M1/M2/M3): /opt/homebrew/opt/freetds
7+
# Intel Mac: /usr/local/opt/freetds
48
prefix=/opt/homebrew/opt/freetds
9+
510
exec_prefix=${prefix}
611
libdir=${exec_prefix}/lib
712
includedir=${prefix}/include

0 commit comments

Comments
 (0)