# NTPAnalyzer-XCF — XCFramework distribution example

This NTPv4 plugin is built **without any access to the CocoaPacketAnalyzer source tree** — only the binary `CPAPluginSDK-X.Y.Z/` distribution.

This is the version a third-party developer would build outside the CPA repo. The Xcode project references nothing from `Packages/`; every compile-time and link-time dependency comes from the 10 `.xcframework` bundles symlinked in `Frameworks/`.

## Layout

```
NTPAnalyzer-XCF/
├── NTPAnalyzer.xcodeproj/         (uses XCFrameworks, no SPM)
├── NTPAnalyzer/                   (identical sources to ../NTPAnalyzer/NTPAnalyzer/)
│   ├── NTPPlugInController.swift
│   ├── NTPProtocolAnalyzer.swift
│   ├── NTPDissector.swift
│   ├── Info.plist
│   └── en.lproj/LocalizableNTPAnalyzer.strings
├── Frameworks/                    (symlinks to Releases/SDK/CPAPluginSDK-1.0.0/*.xcframework)
│   ├── CPAPluginSDK.xcframework -> ../../../Releases/SDK/CPAPluginSDK-1.0.0/CPAPluginSDK.xcframework
│   ├── CPADependencies.xcframework -> …
│   └── …  (10 total)
└── README.md  (this file)
```

For a real third-party project the `Frameworks/` folder would contain **copies** of the XCFrameworks shipped in the `CPAPluginSDK-X.Y.Z/` zip, not symlinks back into the repo.

## Build

```bash
xcodebuild -project NTPAnalyzer.xcodeproj \
           -scheme NTPAnalyzer \
           -configuration Debug \
           -destination 'platform=macOS' \
           CODE_SIGNING_ALLOWED=NO \
           build
```

Output: `~/Library/Developer/Xcode/DerivedData/NTPAnalyzer-*/Build/Products/Debug/NTPAnalyzer.cpaplugin`.

## What this proves

The resulting `.cpaplugin` has byte-identical Mach-O linkage to the SPM-built version (`../NTPAnalyzer/`):

```bash
otool -L NTPAnalyzer.cpaplugin/Contents/MacOS/NTPAnalyzer | grep @rpath
# Same 9 frameworks reference, no embedded Frameworks dir.
```

Both versions resolve their dynamic libraries from the host app's `Contents/SharedFrameworks/` at runtime. The XCFramework distribution is a drop-in replacement for the SPM path-reference approach, **with full library-evolution stability** — plugins can be built with a newer Xcode major version than the SDK without rebuilding the bundle.

## Building the SDK distribution

If you've changed any package source and want to refresh the XCFrameworks under `Frameworks/`, run from the repo root:

```bash
./_resources/Scripts/build-sdk-xcframework.sh
```

The symlinks in `NTPAnalyzer-XCF/Frameworks/` automatically point at the new build.
