When test support code relies on production code, a diamond can occur. If this occurs across packages, it can lead to duplicated symbols and incorrect behavior at runtime despite no warnings at build time. This only occurs in Xcode and top-level application testing. This doesn't occur when the code being tested is in a separate package.
I'm trying to understand how to correctly manage shared test support code which needs to access production code, or if this is the correct way and it is an Xcode bug.
For a minimized example project, see https://github.com/rnapier/SupportCode.
The setup includes three packages: Dependencies, which manages all the dependencies for the app and tests; Core which contains core logic and test support; and Feature, which relies on Core an contains feature-related logic and test support.
Building this system causes Core.framework to show up three times in DerivedData:
./App.app/PlugIns/AppTests.xctest/Frameworks/Core_59974D35D_PackageProduct.framework
./App.app/Frameworks/Core_59974D35D_PackageProduct.framework
./PackageFrameworks/Core_59974D35D_PackageProduct.framework
When unit tests are run, there is a collision on the symbol for Keychain:
objc[48914]: Class _TtC8Keychain8Keychain is implemented in both /Users/ornapier/Library/Developer/Xcode/DerivedData/App-grdjljgevqofhqgflgtrqvhvbtej/Build/Products/Debug-iphonesimulator/PackageFrameworks/Core_59974D35D_PackageProduct.framework/Core_59974D35D_PackageProduct (0x100a98118) and /Users/ornapier/Library/Developer/CoreSimulator/Devices/216C441E-4AE5-45EC-8E52-FA42D8562365/data/Containers/Bundle/Application/7197F2F2-EB26-42FF-B7DB-67116159897D/App.app/PlugIns/AppTests.xctest/AppTests (0x1011002c0). One of the two will be used. Which one is undefined.
This is not a benign warning. There are two distinct copies of _TtC8Keychain8Keychain and test cases will access one and the app will access a different one. This leads to mismatches when accessing static instances such as .shared.
I believe this dependency graph should work, and it does work as long as the top-level testing system is a Swift module. But if it is the application, it builds successfully, but behaves incorrectly in subtle ways.
Xcode
RSS for tagBuild, test, and submit your app using Xcode, Apple's integrated development environment.
Post
Replies
Boosts
Views
Activity
Since dragImage: is deprecated I am trying to update drag and drop with beginDraggingSessionWithItems:.
Drag work fine but I cannot get drop to work correctly.
In the code below change #ifndef to #ifdef (using dragImage:) make drop work as expected.
draggingEntered, draggingUpdated, draggingExited, draggingEnded are all called but NOT performDragOperation (which do the drop).
Uncommenting the line
[pb_item pasteboard:paste_board provideDataForType:@"LN_PboardType"];
cause an exceptionPreprocess: -[NSPasteboardItem pasteboard:provideDataForType:]: unrecognized selector sent to instance 0x600001e64240.
I also try add NSDraggingDestination, NSItemProviderWriting, NSPasteboardTypeOwner to @interface line without success.
What I am doing wrong ?
Any other method to do Drag and Drop (other than dragImage: and beginDraggingSessionWithItems:) ?
Where can I found an Obj-C project using beginDraggingSessionWithItems: for drag an drop ?
``@interface Enclosure : NSView <NSDraggingSource, NSPasteboardItemDataProvider>
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[super setAutoresizesSubviews:YES];
[self registerForDraggedTypes:[NSArray arrayWithObjects:@"LN_PboardType", NSPasteboardTypeString, nil]];
}
return self;
}
- (BOOL)acceptsFirstMouse:(NSEvent *)event
{
return YES;
}
- (void)mouseDown:(NSEvent *)drag_event
{
NSImage *drag_image;
NSPoint drag_position;
NSRect dragging_rect;
NSPasteboard *paste_board;
NSDraggingItem *drag_item;
NSArray *items_array;
NSPasteboardItem *pb_item;
paste_board = [NSPasteboard pasteboardWithName:@"LN_PboardType"];
[paste_board declareTypes:[NSArray arrayWithObjects:@"LN_PboardType", NSPasteboardTypeString, nil] owner:self];
pb_item = [[NSPasteboardItem alloc] init];
[pb_item setDataProvider:self forTypes:[NSArray arrayWithObjects:@"LN_PboardType", NSPasteboardTypeString, nil]];
// [pb_item pasteboard:paste_board provideDataForType:@"LN_PboardType"];
drag_image = [ [NSImage imageNamed:@"drag.jpg"];
drag_position = [self convertPoint:[drag_event locationInWindow] fromView:nil];
drag_position.x -= drag_image.size.width/2;
drag_position.y -= drag_image.size.height/2;
#ifndef DEPRECATED
[self dragImage:drag_image at:drag_position offset:NSZeroSize event:drag_event pasteboard:paste_board source:self slideBack:YES];
#else
drag_item = [[NSDraggingItem alloc] initWithPasteboardWriter:pb_item];
dragging_rect = NSMakeRect(drag_position.x, drag_position.y, drag_image.size.width, drag_image.size.height);
[drag_item setDraggingFrame:dragging_rect contents:drag_image];
items_array = [NSArray arrayWithObject:drag_item];
[self beginDraggingSessionWithItems:items_array event:drag_event source:(id)self];
#endif
}
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
{
if (disable_drag_and_drop)
return NSDragOperationNone;
switch (context)
{
case NSDraggingContextWithinApplication:
return NSDragOperationCopy;
case NSDraggingContextOutsideApplication:
return NSDragOperationMove;
}
return NSDragOperationNone;
}
…``
Got an issue during a (hopefully) vanilla install of Game Porting Toolkit,
brew -v install apple/apple/game-porting-toolkit
configure:5057: checking for C compiler version
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang --version >&5
clang version 8.0.0
Target: x86_64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /usr/local/opt/game-porting-toolkit-compiler/bin
configure:5077: $? = 0
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -v >&5
clang version 8.0.0
Target: x86_64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /usr/local/opt/game-porting-toolkit-compiler/bin
configure:5077: $? = 0
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -V >&5
clang-8: error: argument to '-V' is missing (expected 1 value)
clang-8: error: no input files
configure:5077: $? = 1
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -qversion >&5
clang-8: error: unknown argument '-qversion', did you mean '--version'?
clang-8: error: no input files
configure:5077: $? = 1
configure:5066: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -version >&5
clang-8: error: unknown argument '-version', did you mean '--version'?
clang-8: error: no input files
configure:5077: $? = 1
configure:5097: checking whether the C compiler works
configure:5119: /usr/local/opt/game-porting-toolkit-compiler/bin/clang -I/usr/local/opt/zlib/include -I/usr/local/opt/freetype/include -I/usr/local/opt/sdl2/include -I/usr/local/opt/libgphoto2/include -I/usr/local/opt/faudio/include -I/usr/local/opt/jpeg/include -I/usr/local/opt/libpng/include -I/usr/local/opt/mpg123/include -I/usr/local/opt/libtiff/include -I/usr/local/opt/libgsm/include -I/usr/local/opt/glib/include -I/usr/local/opt/gnutls/include -I/usr/local/opt/libusb/include -I/usr/local/opt/gettext/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sane-backends/include -O3 -Wno-implicit-function-declaration -Wno-format -Wno-deprecated-declarations -Wno-incompatible-pointer-types -L/usr/local/opt/zlib/lib -L/usr/local/opt/freetype/lib -L/usr/local/opt/sdl2/lib -L/usr/local/opt/libgphoto2/lib -L/usr/local/opt/faudio/lib -L/usr/local/opt/jpeg/lib -L/usr/local/opt/libpng/lib -L/usr/local/opt/mpg123/lib -L/usr/local/opt/libtiff/lib -L/usr/local/opt/libgsm/lib -L/usr/local/opt/glib/lib -L/usr/local/opt/gnutls/lib -L/usr/local/opt/libusb/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/sane-backends/lib -lSystem -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,-rpath,@executable_path/../lib/external conftest.c >&5
-macosx_version_min has been renamed to -macos_version_min
dyld[64621]: Symbol not found: _lto_codegen_debug_options_array
Referenced from: <DCCE8DC8-8CC1-3A5E-9CB4-5C97EAE2230B> /Library/Developer/CommandLineTools/usr/bin/ld
Expected in: <64802029-27D0-3E0A-B92F-1DB69924EA28> /usr/local/Cellar/game-porting-toolkit-compiler/0.1/lib/libLTO.dylib
clang-8: error: unable to execute command: Abort trap: 6
clang-8: error: linker command failed due to signal (use -v to see invocation)
configure:5123: $? = 254
configure:5163: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "Wine"
| #define PACKAGE_TARNAME "wine"
| #define PACKAGE_VERSION "7.7"
| #define PACKAGE_STRING "Wine 7.7"
| #define PACKAGE_BUGREPORT "wine-devel@winehq.org"
| #define PACKAGE_URL "https://www.winehq.org"
| /* end confdefs.h. */
|
| int
| main (void)
| {
|
| ;
| return 0;
| }
configure:5168: error: in `/private/tmp/game-porting-toolkit-20250205-64149-m0jk9i/wine64-build':
configure:5170: error: C compiler cannot create executables
See `config.log' for more details
When i run clang manually, similar failure
teddys-MacBook-Pro:~ teddyvandenberg$ /usr/local/opt/game-porting-toolkit-compiler/bin/clang -I/usr/local/opt/zlib/include -I/usr/local/opt/freetype/include -I/usr/local/opt/sdl2/include -I/usr/local/opt/libgphoto2/include -I/usr/local/opt/faudio/include -I/usr/local/opt/jpeg/include -I/usr/local/opt/libpng/include -I/usr/local/opt/mpg123/include -I/usr/local/opt/libtiff/include -I/usr/local/opt/libgsm/include -I/usr/local/opt/glib/include -I/usr/local/opt/gnutls/include -I/usr/local/opt/libusb/include -I/usr/local/opt/gettext/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sane-backends/include -O3 -Wno-implicit-function-declaration -Wno-format -Wno-deprecated-declarations -Wno-incompatible-pointer-types -L/usr/local/opt/zlib/lib -L/usr/local/opt/freetype/lib -L/usr/local/opt/sdl2/lib -L/usr/local/opt/libgphoto2/lib -L/usr/local/opt/faudio/lib -L/usr/local/opt/jpeg/lib -L/usr/local/opt/libpng/lib -L/usr/local/opt/mpg123/lib -L/usr/local/opt/libtiff/lib -L/usr/local/opt/libgsm/lib -L/usr/local/opt/glib/lib -L/usr/local/opt/gnutls/lib -L/usr/local/opt/libusb/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/sane-backends/lib -lSystem -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,-rpath,@executable_path/../lib/external
-macosx_version_min has been renamed to -macos_version_min
dyld[65327]: Symbol not found: _lto_codegen_debug_options_array
Referenced from: <DCCE8DC8-8CC1-3A5E-9CB4-5C97EAE2230B> /Library/Developer/CommandLineTools/usr/bin/ld
Expected in: <64802029-27D0-3E0A-B92F-1DB69924EA28> /usr/local/Cellar/game-porting-toolkit-compiler/0.1/lib/libLTO.dylib
clang-8: error: unable to execute command: Abort trap: 6
clang-8: error: linker command failed due to signal (use -v to see invocation)
This is where my bisection skills cease, curious if anyone else has seen this
[config.log]
(https://developer.apple.com/forums/content/attachment/ed9a5c1a-98bb-46c4-a993-0884bab041fc)
I'm trying to use Xcode UI tests for the first time. I added a UI Tests target and set up the signing, then opened the default AppnameUITests.swift file. I added a new function named testAboutPage(), clicked inside the block and clicked the Record UI Test button (red circle) at the bottom of the editor window. If the app is already running when I do this, Xcode crashes immediately. If the app is not running, Xcode builds and runs the app, then crashes.
I've seen reports of this going back years, but none of the posts have a solution. I do have a crash log to share. Does anyone know how to get past this?
This forum won't let me upload the complete crash log because it exceeds the size limit, but here's the first part through the stack trace of the crashed thread:
Process: Xcode [46652]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 16.2 (23507)
Build Info: IDEApplication-23507000000000000~2 (16C5032a)
App Item ID: 497799835
App External ID: 870964517
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 503
Date/Time: 2025-02-04 12:58:05.5200 -0800
OS Version: macOS 15.3 (24D60)
Report Version: 12
Anonymous UUID: 144B0B99-8D44-736B-0D9A-1F6FA6DF85F7
Time Awake Since Boot: 48000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6
Terminating Process: Xcode [46652]
Application Specific Information:
abort() called
Application Specific Signatures:
((result)) != nil
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x18a3b3720 __pthread_kill + 8
1 libsystem_pthread.dylib 0x18a3ebf70 pthread_kill + 288
2 libsystem_c.dylib 0x18a2f8908 abort + 128
3 IDEKit 0x109e81554 +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 964
4 IDEKit 0x109e819e4 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] + 876
5 DVTFoundation 0x10600d358 _DVTAssertionHandler + 424
6 DVTFoundation 0x10600d4d8 _DVTAssertionFailureHandler + 196
7 IDEKit 0x10a1f99e4 -[IDEUIRecordingManager _workspaceTabController] + 176
8 IDEKit 0x10a1fa528 __94-[IDEUIRecordingManager _startRecordingWithLaunchSession:alwaysAskForAPIAccess:reservedNames:]_block_invoke_3 + 252
9 DVTFoundation 0x10611fc9c __DVT_CALLING_CLIENT_BLOCK__ + 16
10 DVTFoundation 0x1061206c4 __DVTDispatchAsync_block_invoke + 152
11 libdispatch.dylib 0x18a237854 _dispatch_call_block_and_release + 32
12 libdispatch.dylib 0x18a2395b4 _dispatch_client_callout + 20
13 libdispatch.dylib 0x18a248040 _dispatch_main_queue_drain + 984
14 libdispatch.dylib 0x18a247c58 _dispatch_main_queue_callback_4CF + 44
15 CoreFoundation 0x18a5139d0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
16 CoreFoundation 0x18a4d35bc __CFRunLoopRun + 1996
17 CoreFoundation 0x18a4d2734 CFRunLoopRunSpecific + 588
18 HIToolbox 0x195a41530 RunCurrentEventLoopInMode + 292
19 HIToolbox 0x195a47348 ReceiveNextEventCommon + 676
20 HIToolbox 0x195a47508 _BlockUntilNextEventMatchingListInModeWithFilter + 76
21 AppKit 0x18e04a848 _DPSNextEvent + 660
22 AppKit 0x18e9b0c24 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688
23 AppKit 0x18e03d874 -[NSApplication run] + 480
24 IDEKit 0x109e50f14 -[IDEApplication run] + 192
25 AppKit 0x18e014068 NSApplicationMain + 888
26 dyld 0x18a06c274 start + 2840
I've gone over the memory graph debugger documentation and WWDC videos.
The available documentation is sparse and does not go into any detail of what things mean.
Through usage I have a fair understanding of what most symbols and reference lines mean except for the line from an object that loops back on itself in the top right corner of an object symbol. I have noticed it always appears on dictionaries, I have this on one of my own classes and want to know what it means?
Please see detail here.
In Xcode Version 16.2 (16C5032a) - and previous versions too, the download container in the Devices & Simulators functionality no longer works.
It will start downloading the container, however it will also:
show NO download progress
fail to download the whole container (the downloaded container is missing whole directories, eg. AppData/Library is missing - where my application stores the CoreData db)
show no errors
This was tested with the XCode version stated above (and previous versions) and with iPhone XR (18.1.1 - MR42CN/A) and with iPad (17.7.2 - MR7F2FD/A).
How can I debug this issue / make the Xcode download the whole container?
Running on Mac mini 15.1.1 (24B91).
I am experiencing an issue with Xcode 16.2 (15E204a) where global workspace search does not return results from .xib files.
Hi,
I've noticed a warning during export archive phase (xcrun xcodebuild -exportArchive) in our iOS CI/CD pipelines.
Updating the export options info plist file to use
<key>method</key>
<string>app-store-connect</string>
helps, but I am not sure if we should update it or not since I cannot find any references about this change in the docs.
It'd be very helpful to get some guidelines.
Thank you
When I try to open Xcode, it tries to open the previous windows and load up the project I was last working on, but I can’t create a new project without opening Xcode, and I can’t do that; it just quits and gives me an Xcode quit unexpectedly, and it still happens when I download earlier versions of Xcode from the Apple developer website and the latest from the App Store, and I even when in Finder and tried to open my project that way, and it just does the same thing. I have tried everything, and I mean everything. I even reinstalled macOS, and it worked for a minute until it tried to open my project and then quit again and is doing the same thing.
when opening Main.storyboard, all screens turn black, XCode freezes, and then closes. I am adding the font according to this guide. I'm trying to add Inter-VariableFont_opsz,wght.ttf of the https://fonts.google.com/specimen/Inter
Hi,
I am working on an agent app.
The app has a menubarextra.
var body: some Scene {
MenuBarExtra(
"menubarextra", systemImage: "star")
{
Button("Item 1") {
}
Button("Item 2") {
}
Button("Item 3") {
}
}
}
I am going to write xctest to click on the icon i created and want to click on the menu next.
func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()
let menuBarsQuery = XCUIApplication().menuBars
let favouriteStatusItem = menuBarsQuery.statusItems["Favourite"]
favouriteStatusItem.click()
menuBarsQuery.menuItems["Item 1"].click()
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
There is a small problem. When the app is not a agent app, the app will start with with its own menu bar. If i am currently on fullscreen, it will swap to the desktop and the menubar will be showing the app's menu bar. In this case, I can see the menubarextra. The test will pass then.
When it is in agent app, the above behaviour will not happen. Once I run the test with fullscreen mode of xcode, my screen will still stay on xcode and the statusbar will not be showing. Then the test will response
error: -[swiftuitestUITests.MenubarExtraTests testExample] : Element StatusItem, {{1080.0, 6.5}, {34.5, 24.0}}, title: 'Favourite' is not hittable
The only solution I can found at the moment is to leave fullscreen first, then run the test.
In xctest, is there any way to force the statusbar to show first?
Thank you!
We are encountering a persistent code signing error with in-app purchase capabilities in our iOS app. Despite having the com.apple.developer.in-app-purchase entitlement properly configured in the app's entitlements file and the In-App Purchase capability enabled in both Xcode and the App ID configuration in the Apple Developer Portal, we continue to receive the error: "The provisioning profile 'iOS Team Provisioning Profile: does not include the com.apple.developer.in-app-purchase entitlement." We have attempted multiple solutions including:
Regenerating provisioning profiles
Cleaning and rebuilding the project
Switching between automatic and manual signing
Removing and re-adding the in-app purchase capability
Verifying all entitlements and capabilities configurations
The error persists despite the entitlement being correctly set in the entitlements file and the capability being enabled in the App ID. This appears to be an issue with how the provisioning profile is being generated or how the entitlement is being recognized by Xcode's code signing system.
I've got an existing app which is using some 3rd party xcframeworks within its app extensions (for example within a Notification Service Extension).
Within the target for the app extensions there is a Frameworks and Libraries section where the xcframework was dragged and dropped into.
However now I want to create a new project and do a similar thing, within the app's target there is a Frameworks and Libraries section, but when an app extension target is created, Xcode is not adding a Frameworks and Libraries section.
There is a Link Library with Binary section, however this doesn't have an embed section (where you can select to embed, don't embed, embed without signing etc.) and I get build error trying to drag and drop the xcframework in here.
Where id the Framewoks and Libraries section go for app extensions for projects created with Xcode 16? How can this section be added?
All the threads only contain system calls. The crashed thread only contains a single call to my app's code which is main.swift:12.
What could cause such a crash?
crash.txt
Hello all!
My application written with C++/CMake and when building have some troubles with adding test environment for StoreKit every time - it need to be done manually.
Is there any way to add StoreKit environment settings with CMake and when executed command like this $ cmake -g Xcode ... StoreKit test environment were automatically added?
Hi,
Regarding the bundle identifiers of App that I remove from App Store Connect will they be locked forever andI can't reuse them ?
Kind Regards
I have created two different apps using ADEP, and they were working on iPad with iOS 14.6 and 14.7.1. The environments are as follows:
Environment:
1.Mac mini (Mac OS X 10.7.5)
Xcode 8.3.2
2.iMac (OS X El Capitan 10.11.6)
Xcode 7.3
The certificates were exported from the environment in 1 and imported into 2.
When I tried to switch from ADEP to AdHoc for app creation, I encountered an error. Specifically, the app worked fine on an iPad running iOS 12.5.7 in environment 1, but on devices with iOS 14.6, 14.7.1, and 17.7, the installation was successful, but when I tried to open the app, the following error message appeared:
“XXXXX” needs to be updated
To run this app on this version of iOS, the developer needs to update the app.
Additionally, in environment 2, I’m unable to archive the app.
Is it possible to create a working app by simply switching from ADEP to AdHoc without making any other changes to the environment?
So I started a project in Xcode but without GitHub.
Now I have prepared Xcode for GitHub and kind of made it work.
I have also made a folder where I have cloned my project from GitHub.
So is there any way to connect Xcode and the new folder. If I save my project it doesn't know about my new folder I presume:
I could continue to use GitHub via Xcode but I'm afraid I will forget about commands in Git if I only use Xcode. If I should work on another project without Git.
I'm getting hundreds of the message below in Xcode. I've narrowed it down to when I instantiate the following
AVAudioUnitComponentManager.shared()
Message send exceeds rate-limit threshold and will be dropped. { reporterID=231700600717315, rateLimit=32hz }