Xcode 16.0 (16A242d): xcodebuild fails due "INTERNAL ERROR: Uncaught exception"

Hi!,

Did you experienced failure of xcodebuild tool in Xcode 16? I can't build from command line. It fails when I am trying to perform clean, build, test, etc. actions.

macOS version: 14.7 (23H124)
Xcode 16.0, Build version 16A242d

My steps:

  1. sudo xcode-select -s /Volumes/Apps/Developer/Xcode/Xcode_15_4_0.app
  2. xcodebuild -showBuildSettings -workspace mc.xcworkspace -scheme AllNormalTests_macOS

As result showBuildSettings is working as expected when using Xcode 15.4.

Command line invocation:
    /Volumes/Apps/Developer/Xcode/Xcode_15_4_0.app/Contents/Developer/usr/bin/xcodebuild -showBuildSettings -workspace mc.xcworkspace -scheme AllNormalTests_macOS

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Build settings for action build and target Testability_macOS:
    ACTION = build
    AD_HOC_CODE_SIGNING_ALLOWED = YES
    AGGREGATE_TRACKED_DOMAINS = YES
    ALLOW_TARGET_PLATFORM_SPECIALIZATION = NO
    ALTERNATE_GROUP = staff
    ...

Then:

  1. sudo xcode-select -s /Volumes/Apps/Developer/Xcode/Xcode_16_0_0.app
  2. xcodebuild -showBuildSettings -workspace mc.xcworkspace -scheme AllNormalTests_macOS

As result error:

Command line invocation:
    /Volumes/Apps/Developer/Xcode/Xcode_16_0_0.app/Contents/Developer/usr/bin/xcodebuild -showBuildSettings -workspace mc.xcworkspace -scheme AllNormalTests_macOS

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

** INTERNAL ERROR: Uncaught exception **
Uncaught Exception: -[NSTaggedPointerString unsignedIntegerValue]: unrecognized selector sent to instance 0xbe036b67f7528701
Stack:
  0   __exceptionPreprocess (in CoreFoundation)
  1   objc_exception_throw (in libobjc.A.dylib)
  2   -[NSObject(NSObject) __retain_OA] (in CoreFoundation)
  3   ___forwarding___ (in CoreFoundation)
  4   _CF_forwarding_prep_0 (in CoreFoundation)
  5   -[DVTDeviceManager _startObservingDevice:] (in DVTFoundation)
  6   -[DVTDeviceManager _adjustAvailableDevicesForChangeKind:addedObjects:removedObjects:] (in DVTFoundation)
  7   __42-[_DVTDeviceLocatorTracker startObserving]_block_invoke (in DVTFoundation)
  8   -[DVTObservingBlockToken observeValueForKeyPath:ofObject:change:context:] (in DVTFoundation)
  9   NSKeyValueNotifyObserver (in Foundation)
 10   NSKeyValueDidChange (in Foundation)
 11   NSKeyValueDidChangeWithPerThreadPendingNotifications (in Foundation)
 12   __62-[DVTiPhoneSimulatorLocator _startLocatingDevicesInDeviceSet:]_block_invoke_2 (in IDEiOSSupportCore)
 13   __DVT_CALLING_CLIENT_BLOCK__ (in DVTFoundation)
 14   ___DVTAsyncPerformBlockOnMainRunLoop_block_invoke (in DVTFoundation)
 15   __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation)
 16   __CFRunLoopDoBlocks (in CoreFoundation)
 17   __CFRunLoopRun (in CoreFoundation)
 18   CFRunLoopRunSpecific (in CoreFoundation)
 19   +[DVTKVOConditionValidator waitForCondition:sourceObject:keyPathAffectingConditionBlock:timeout:] (in DVTFoundation)
 20   -[Xcode3CommandLineBuildTool _resolveInputOptionsWithTimingSection:] (in Xcode3Core)
 21   -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
 22   XcodeBuildMain (in libxcodebuildLoader.dylib)
 23   -[XcodebuildPreIDEHandler loadXcode3ProjectSupportAndRunXcode3CommandLineBuildToolWithArguments:] (in xcodebuild)
 24   -[XcodebuildPreIDEHandler runWithArguments:] (in xcodebuild)
 25   main (in xcodebuild)
 26   start (in dyld)

Abort trap: 6

Simple commands as shown below are working, but not typical build actions.

xcodebuild -h
xcodebuild -version
xcodebuild -showsdks

Thank you in advance!

Answered by v_gorlov in 807928022

Removing user default key DVTDeviceVisibilityPreferences fixes issue.

defaults delete com.apple.dt.Xcode DVTDeviceVisibilityPreferences

I had a wrong value type under DVTDeviceVisibilityPreferences key. String instead of Integer.

Observed

<key>2DDE32D1-C291-4C3A-A76F-2878C9F57F61</key>
<string>1</string>

Should be

<key>2DDE32D1-C291-4C3A-A76F-2878C9F57F61</key>
<integer>1</integer>

All of the information you provided here is excellent detail for a bug report. Could you go ahead and formally file this as a bug so we can look into it? Including an Xcode sysdiagnose would be great too. Once you open the bug report, please post the FB number here for my reference.

— Ed Ford,  DTS Engineer

Thank you Ed,

Issue report is created: FB15300340

FYI: Issue also reproducible when using Xcode 16.1 Beta 2 (16B5014f).

Accepted Answer

Removing user default key DVTDeviceVisibilityPreferences fixes issue.

defaults delete com.apple.dt.Xcode DVTDeviceVisibilityPreferences

I had a wrong value type under DVTDeviceVisibilityPreferences key. String instead of Integer.

Observed

<key>2DDE32D1-C291-4C3A-A76F-2878C9F57F61</key>
<string>1</string>

Should be

<key>2DDE32D1-C291-4C3A-A76F-2878C9F57F61</key>
<integer>1</integer>
Xcode 16.0 (16A242d): xcodebuild fails due "INTERNAL ERROR: Uncaught exception"
 
 
Q