Skip to content

Fix dev-build.sh clobbering Datadog's SPM_BUILD flag - #11

Merged
alexkroman merged 1 commit into
mainfrom
fix/dev-build-datadog-spm-build
Jul 1, 2026
Merged

alexkroman merged 1 commit into
mainfrom
fix/dev-build-datadog-spm-build

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Problem

scripts/dev-build.sh failed to build locally with:

cannot find type 'UIApplicationNotificationCallback' in scope
cannot find type '__dd_private_AppLaunchHandler' in scope
cannot find '__dd_private_ObjcExceptionHandler' in scope

…even though CI (check.sh) was green on the same dd-sdk-ios revision, Xcode, and Swift toolchain.

Root cause

dev-build.sh passed SWIFT_ACTIVE_COMPILATION_CONDITIONS=DEBUG on the xcodebuild command line to strip UITEST_HOOKS from a clean local build. A command-line build-setting override applies to every target in the graph — including SwiftPM dependencies — and replaces (not appends to) their value.

dd-sdk-ios's Package.swift compiles DatadogCore/DatadogCrashReporting with .define("SPM_BUILD"). The global override wiped that out, so this guard went false:

#if SPM_BUILD
    internal import DatadogPrivate   // the ObjC module with the missing symbols
#endif

Why CI didn't catch it: check.sh's xcodebuild never passes that override, so the dependency kept SPM_BUILD. dev-build.sh is local-only, and Datadog (#8) was the first dependency to rely on a custom compilation condition — so a long-standing override in dev-build.sh only just started breaking builds.

Fix

  • Add a Debug-Local build configuration (debug type, UITEST_HOOKS off) in project.yml.
  • dev-build.sh selects it with -configuration Debug-Local instead of overriding the global setting — a per-config setting only touches the app target, so SwiftPM dependencies keep their own flags.
  • The "Install to /Applications" postBuildScript now installs for Debug-Local as well as Debug.
  • Regenerated project.pbxproj via xcodegen (keeps the drift gate green).

Verification

  • Full app build with -configuration Debug-Local → BUILD SUCCEEDED, with -DSPM_BUILD present on the DatadogCore compile.
  • Debug-Local → SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG (no UITEST_HOOKS); Debug → DEBUG UITEST_HOOKS.
  • Generated scheme unchanged (run/test Debug, archive Release).

🤖 Generated with Claude Code

scripts/dev-build.sh passed SWIFT_ACTIVE_COMPILATION_CONDITIONS=DEBUG on
the xcodebuild command line to strip UITEST_HOOKS from a local build. A
command-line build-setting override applies to EVERY target in the graph
— including SwiftPM dependencies — and replaces (not appends to) their
value. That silently dropped the SPM_BUILD flag dd-sdk-ios's package
targets set via .define("SPM_BUILD"), so DatadogCore/CrashReporting never
imported the DatadogPrivate ObjC module and failed with "cannot find type
'__dd_private_AppLaunchHandler'" (and UIApplicationNotificationCallback,
__dd_private_ObjcExceptionHandler).

CI never caught it: check.sh builds the app without that override, so the
dependency kept SPM_BUILD. dev-build.sh is local-only, and Datadog (#8)
was the first dependency to rely on a custom compilation condition, so a
pre-existing override in dev-build.sh only just started breaking builds.

Fix: add a Debug-Local build configuration (debug, UITEST_HOOKS off) and
have dev-build.sh select it with -configuration instead of overriding the
setting globally. A per-config setting only touches the app target, so
SwiftPM dependencies keep their own flags. The "Install to /Applications"
postBuildScript now installs for Debug-Local as well as Debug.

Verified: full app build with -configuration Debug-Local succeeds with
-DSPM_BUILD present on the DatadogCore compile; Debug-Local drops
UITEST_HOOKS while Debug keeps it; generated scheme unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexkroman
alexkroman enabled auto-merge July 1, 2026 19:24
@alexkroman
alexkroman added this pull request to the merge queue Jul 1, 2026
Merged via the queue into main with commit ed45c6d Jul 1, 2026
6 checks passed
@alexkroman
alexkroman deleted the fix/dev-build-datadog-spm-build branch July 1, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants