Apple’s library technology has a long and glorious history, dating all the way back to the origins of Unix. This does, however, mean that it can be a bit confusing to newcomers. This is my attempt to clarify some terminology.
If you have any questions or comments about this, start a new thread and tag it with Linker so that I see it.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
An Apple Library Primer
Apple’s tools support two related concepts:
Platform — This is the platform itself; macOS, iOS, iOS Simulator, and Mac Catalyst are all platforms.
Architecture — This is a specific CPU architecture used by a platform. arm64 and x86_64 are both architectures.
A given architecture might be used by multiple platforms. The most obvious example of this arm64, which is used by all of the platforms listed above.
Code built for one platform will not work on another platform, even if both platforms use the same architecture.
Code is usually packaged in either a Mach-O file or a static library. Mach-O is used for executables (MH_EXECUTE), dynamic libraries (MH_DYLIB), bundles (MH_BUNDLE), and object files (MH_OBJECT). These can have a variety of different extensions; the only constant is that .o is always used for a Mach-O containing an object file. Use otool and nm to examine a Mach-O file. Use vtool to quickly determine the platform for which it was built. Use size to get a summary of its size. Use dyld_info to get more details about a dynamic library.
IMPORTANT All the tools mentioned here are documented in man pages. For information on how to access that documentation, see Reading UNIX Manual Pages. There’s also a Mach-O man page, with basic information about the file format.
Many of these tools have old and new variants, using the -classic suffix or llvm- prefix, respectively. For example, there’s nm-classic and llvm-nm. If you run the original name for the tool, you’ll get either the old or new variant depending on the version of the currently selected tools. To explicitly request the old or new variants, use xcrun.
The term Mach-O image refers to a Mach-O that can be loaded and executed without further processing. That includes executables, dynamic libraries, and bundles, but not object files.
A dynamic library has the extension .dylib. You may also see this called a shared library.
A framework is a bundle structure with the .framework extension that has both compile-time and run-time roles:
At compile time, the framework combines the library’s headers and its stub library (stub libraries are explained below).
At run time, the framework combines the library’s code, as a Mach-O dynamic library, and its associated resources.
The exact structure of a framework varies by platform. For the details, see Placing Content in a Bundle.
macOS supports both frameworks and standalone dynamic libraries. Other Apple platforms support frameworks but not standalone dynamic libraries.
Historically these two roles were combined, that is, the framework included the headers, the dynamic library, and its resources. These days Apple ships different frameworks for each role. That is, the macOS SDK includes the compile-time framework and macOS itself includes the run-time one. Most third-party frameworks continue to combine these roles.
A static library is an archive of one or more object files. It has the extension .a. Use ar, libtool, and ranlib to inspect and manipulate these archives.
The static linker, or just the linker, runs at build time. It combines various inputs into a single output. Typically these inputs are object files, static libraries, dynamic libraries, and various configuration items. The output is most commonly a Mach-O image, although it’s also possible to output an object file. The linker may also output metadata, such as a link map (see Using a Link Map to Track Down a Symbol’s Origin).
The linker has seen three major implementations:
ld — This dates from the dawn of Mac OS X.
ld64 — This was a rewrite started in the 2005 timeframe. Eventually it replaced ld completely. If you type ld, you get ld64.
ld_prime — This was introduced with Xcode 15. This isn’t a separate tool. Rather, ld now supports the -ld_classic and -ld_new options to select a specific implementation.
Note During the Xcode 15 beta cycle these options were -ld64 and -ld_prime. I continue to use those names because the definition of new changes over time (some of us still think of ld64 as the new linker ;–).
The dynamic linker loads Mach-O images at runtime. Its path is /usr/lib/dyld, so it’s often referred to as dyld, dyld, or DYLD. Personally I pronounced that dee-lid, but some folks say di-lid and others say dee-why-el-dee.
IMPORTANT Third-party executables must use the standard dynamic linker.
Other Unix-y platforms support the notion of a statically linked executable, one that makes system calls directly. This is not supported on Apple platforms. Apple platforms provide binary compatibility via system dynamic libraries and frameworks, not at the system call level.
Note Apple platforms have vestigial support for custom dynamic linkers (your executable tells the system which dynamic linker to use via the LC_LOAD_DYLINKER load command). This facility originated on macOS’s ancestor platform and has never been a supported option on any Apple platform.
The dynamic linker has seen 4 major revisions. See WWDC 2017 Session 413 (referenced below) for a discussion of versions 1 through 3. Version 4 is basically a merging of versions 2 and 3.
The dyld man page is chock-full of useful info, including a discussion of how it finds images at runtime.
Every dynamic library has an install name, which is how the dynamic linker identifies the library. Historically that was the path where you installed the library. That’s still true for most system libraries, but nowadays a third-party library should use an rpath-relative install name. For more about this, see Dynamic Library Identification.
Mach-O images are position independent, that is, they can be loaded at any location within the process’s address space. Historically, Mach-O supported the concept of position-dependent images, ones that could only be loaded at a specific address. While it may still be possible to create such an image, it’s no longer a good life choice.
Mach-O images have a default load address, also known as the base address. For modern position-independent images this is 0 for library images and 4 GiB for executables (leaving the bottom 32 bits of the process’s address space unmapped). When the dynamic linker loads an image, it chooses an address for the image and then rebases the image to that address. If you take that address and subtract the image’s load address, you get a value known as the slide.
Xcode 15 introduced the concept of a mergeable library. This a dynamic library with extra metadata that allows the linker to embed it into the output Mach-O image, much like a static library. Mergeable libraries have many benefits. For all the backstory, see WWDC 2023 Session 10268 Meet mergeable libraries. For instructions on how to set this up, see Configuring your project to use mergeable libraries.
If you put a mergeable library into a framework structure you get a mergeable framework.
Xcode 15 also introduced the concept of a static framework. This is a framework structure where the framework’s dynamic library is replaced by a static library.
Note It’s not clear to me whether this offers any benefit over creating a mergeable framework.
Earlier versions of Xcode did not have proper static framework support. That didn’t stop folks trying to use them, which caused all sorts of weird build problems.
A universal binary is a file that contains multiple architectures for the same platform. Universal binaries always use the universal binary format. Use the file command to learn what architectures are within a universal binary. Use the lipo command to manipulate universal binaries.
A universal binary’s architectures are either all in Mach-O format or all in the static library archive format. The latter is called a universal static library.
A universal binary has the same extension as its non-universal equivalent. That means a .a file might be a static library or a universal static library.
Most tools work on a single architecture within a universal binary. They default to the architecture of the current machine. To override this, pass the architecture in using a command-line option, typically -arch or --arch.
An XCFramework is a single document package that includes libraries for any combination of platforms and architectures. It has the extension .xcframework. An XCFramework holds either a framework, a dynamic library, or a static library. All the elements must be the same type. Use xcodebuild to create an XCFramework. For specific instructions, see Xcode Help > Distribute binary frameworks > Create an XCFramework.
Historically there was no need to code sign libraries in SDKs. If you shipped an SDK to another developer, they were responsible for re-signing all the code as part of their distribution process. Xcode 15 changes this. You should sign your SDK so that a developer using it can verify this dependency. For more details, see WWDC 2023 Session 10061 Verify app dependencies with digital signatures and Verifying the origin of your XCFrameworks.
A stub library is a compact description of the contents of a dynamic library. It has the extension .tbd, which stands for text-based description (TBD). Apple’s SDKs include stub libraries to minimise their size; for the backstory, read this post. Use the tapi tool to create and manipulate stub libraries. In this context TAPI stands for a text-based API, an alternative name for TBD. Oh, and on the subject of tapi, I’d be remiss if I didn’t mention tapi-analyze!
Stub libraries currently use YAML format, a fact that’s relevant when you try to interpret linker errors. If you’re curious about the format, read the tapi-tbdv4 man page. There’s also a JSON variant documented in the tapi-tbdv5 man page.
Note Back in the day stub libraries used to be Mach-O files with all the code removed (MH_DYLIB_STUB). This format has long been deprecated in favour of TBD.
Historically, the system maintained a dynamic linker shared cache, built at runtime from its working set of dynamic libraries. In macOS 11 and later this cache is included in the OS itself. Libraries in the cache are no longer present in their original locations on disk:
% ls -lh /usr/lib/libSystem.B.dylib
ls: /usr/lib/libSystem.B.dylib: No such file or directory
Apple APIs, most notably dlopen, understand this and do the right thing if you supply the path of a library that moved into the cache. That’s true for some, but not all, command-line tools, for example:
% dyld_info -exports /usr/lib/libSystem.B.dylib
/usr/lib/libSystem.B.dylib [arm64e]:
-exports:
offset symbol
…
0x5B827FE8 _mach_init_routine
% nm /usr/lib/libSystem.B.dylib
…/nm: error: /usr/lib/libSystem.B.dylib: No such file or directory
When the linker creates a Mach-O image, it adds a bunch of helpful information to that image, including:
The target platform
The deployment target, that is, the minimum supported version of that platform
Information about the tools used to build the image, most notably, the SDK version
A build UUID
For more information about the build UUID, see TN3178 Checking for and resolving build UUID problems. To dump the other information, run vtool.
In some cases the OS uses the SDK version of the main executable to determine whether to enable new behaviour or retain old behaviour for compatibility purposes. You might see this referred to as compiled against SDK X. I typically refer to this as a linked-on-or-later check.
Apple tools support the concept of autolinking. When your code uses a symbol from a module, the compiler inserts a reference (using the LC_LINKER_OPTION load command) to that module into the resulting object file (.o). When you link with that object file, the linker adds the referenced module to the list of modules that it searches when resolving symbols.
Autolinking is obviously helpful but it can also cause problems, especially with cross-platform code. For information on how to enable and disable it, see the Build settings reference.
Mach-O uses a two-level namespace. When a Mach-O image imports a symbol, it references the symbol name and the library where it expects to find that symbol. This improves both performance and reliability but it precludes certain techniques that might work on other platforms. For example, you can’t define a function called printf and expect it to ‘see’ calls from other dynamic libraries because those libraries import the version of printf from libSystem.
To help folks who rely on techniques like this, macOS supports a flat namespace compatibility mode. This has numerous sharp edges — for an example, see the posts on this thread — and it’s best to avoid it where you can. If you’re enabling the flat namespace as part of a developer tool, search the ’net for dyld interpose to learn about an alternative technique.
WARNING Dynamic linker interposing is not documented as API. While it’s a useful technique for developer tools, do not use it in products you ship to end users.
Apple platforms use DWARF. When you compile a file, the compiler puts the debug info into the resulting object file. When you link a set of object files into a executable, dynamic library, or bundle for distribution, the linker does not include this debug info. Rather, debug info is stored in a separate debug symbols document package. This has the extension .dSYM and is created using dsymutil. Use symbols to learn about the symbols in a file. Use dwarfdump to get detailed information about DWARF debug info. Use atos to map an address to its corresponding symbol name.
Different languages use different name mangling schemes:
C, and all later languages, add a leading underscore (_) to distinguish their symbols from assembly language symbols.
C++ uses a complex name mangling scheme. Use the c++filt tool to undo this mangling.
Likewise, for Swift. Use swift demangle to undo this mangling.
For a bunch more info about symbols in Mach-O, see Understanding Mach-O Symbols. This includes a discussion of weak references and weak definition. If your code is referencing a symbol unexpectedly, see Determining Why a Symbol is Referenced.
To remove symbols from a Mach-O file, run strip. To hide symbols, run nmedit.
It’s common for linkers to divide an object file into sections. You might find data in the data section and code in the text section (text is an old Unix term for code). Mach-O uses segments and sections. For example, there is a text segment (__TEXT) and within that various sections for code (__TEXT > __text), constant C strings (__TEXT > __cstring), and so on.
Over the years there have been some really good talks about linking and libraries at WWDC, including:
WWDC 2023 Session 10268 Meet mergeable libraries
WWDC 2022 Session 110362 Link fast: Improve build and launch times
WWDC 2022 Session 110370 Debug Swift debugging with LLDB
WWDC 2021 Session 10211 Symbolication: Beyond the basics
WWDC 2019 Session 416 Binary Frameworks in Swift — Despite the name, this covers XCFrameworks in depth.
WWDC 2018 Session 415 Behind the Scenes of the Xcode Build Process
WWDC 2017 Session 413 App Startup Time: Past, Present, and Future
WWDC 2016 Session 406 Optimizing App Startup Time
Note The older talks are no longer available from Apple, but you may be able to find transcripts out there on the ’net.
Historically Apple published a document, Mac OS X ABI Mach-O File Format Reference, or some variant thereof, that acted as the definitive reference to the Mach-O file format. This document is no longer available from Apple. If you’re doing serious work with Mach-O, I recommend that you find an old copy. It’s definitely out of date, but there’s no better place to get a high-level introduction to the concepts. The Mach-O Wikipedia page has a link to an archived version of the document.
For the most up-to-date information about Mach-O, see the declarations and doc comments in <mach-o/loader.h>.
Revision History
2025-08-04 Added a link to Determining Why a Symbol is Referenced.
2025-06-29 Added information about autolinking.
2025-05-21 Added a note about the legacy Mach-O stub library format (MH_DYLIB_STUB).
2025-04-30 Added a specific reference to the man pages for the TBD format.
2025-03-01 Added a link to Understanding Mach-O Symbols. Added a link to TN3178 Checking for and resolving build UUID problems. Added a summary of the information available via vtool. Discussed linked-on-or-later checks. Explained how Mach-O uses segments and sections. Explained the old (-classic) and new (llvm-) tool variants. Referenced the Mach-O man page. Added basic info about the strip and nmedit tools.
2025-02-17 Expanded the discussion of dynamic library identification.
2024-10-07 Added some basic information about the dynamic linker shared cache.
2024-07-26 Clarified the description of the expected load address for Mach-O images.
2024-07-23 Added a discussion of position-independent images and the image slide.
2024-05-08 Added links to the demangling tools.
2024-04-30 Clarified the requirement to use the standard dynamic linker.
2024-03-02 Updated the discussion of static frameworks to account for Xcode 15 changes. Removed the link to WWDC 2018 Session 415 because it no longer works )-:
2024-03-01 Added the WWDC 2023 session to the list of sessions to make it easier to find. Added a reference to Using a Link Map to Track Down a Symbol’s Origin. Made other minor editorial changes.
2023-09-20 Added a link to Dynamic Library Identification. Updated the names for the static linker implementations (-ld_prime is no more!). Removed the beta epithet from Xcode 15.
2023-06-13 Defined the term Mach-O image. Added sections for both the static and dynamic linkers. Described the two big new features in Xcode 15: mergeable libraries and dependency verification.
2023-06-01 Add a reference to tapi-analyze.
2023-05-29 Added a discussion of the two-level namespace.
2023-04-27 Added a mention of the size tool.
2023-01-23 Explained the compile-time and run-time roles of a framework. Made other minor editorial changes.
2022-11-17 Added an explanation of TAPI.
2022-10-12 Added links to Mach-O documentation.
2022-09-29 Added info about .dSYM files. Added a few more links to WWDC sessions.
2022-09-21 First posted.
Linker
RSS for tagUse dyld to link in frameworks at runtime. Use ld to make your programs and link archive libraries at build time.
Posts under Linker tag
96 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have an Xcode project setup as follows:
3 static libraries
1 framework target, whose Mach-O type is set to Dynamic Library
main app target (iOS app)
The target dependencies are as follows:
In framework's build phase [Link with libraries], I have the 3 libs statically linked.
In the main app's build phase [Link with libraries], I have only the framework, which is dynamically linked.
As per my understanding:
The libs are statically linked to the framework. So, the framework binary would contain code from all the libs.
The framework is dynamically linked to the main app (iOS app in this case). So, the main app's binary only has a reference to the framework's binary, which would be loaded in the memory at runtime.
Assuming my understanding is correct, I'm stuck with the following problem:
All 3 libs build successfully
The framework builds successfully
The main app target doesn't build. The compilation is successful, but the build fails with linker errors.
Please let me know if I am doing something incorrectly, or if a configuration is missing. Below are more details:
The linker gives the following error:
Undefined symbols for architecture arm64:
"StringUtils.GetStr() -> Swift.String", referenced from:
dynamic_fw.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: [__C.UIApplicationLaunchOptionsKey : Any]?) -> Swift.Bool in AppDelegate.o
"TWUtils.GetNum() -> Swift.Int", referenced from:
dynamic_fw.AppDelegate.application(_: __C.UIApplication, didFinishLaunchingWithOptions: [__C.UIApplicationLaunchOptionsKey : Any]?) -> Swift.Bool in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And the command shown in the logs for linking phase is:
Ld /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator/dynamic-fw.app/dynamic-fw normal (in target 'dynamic-fw' from project 'dynamic-fw')
cd /Users/raunit.shrivastava/Desktop/dynamic-fw
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios17.5-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk -O0 -L/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator -L. -L./StringUtils -L./TWFramework -L./TWUtils -L./dynamic-fw -F/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator -F. -F./StringUtils -F./TWFramework -F./TWUtils -F./dynamic-fw -filelist /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic-fw.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker ./\*\* -dead_strip -Xlinker -object_path_lto -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic-fw_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic_fw.swiftmodule -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/dynamic-fw.app-Simulated.xcent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/dynamic-fw.app-Simulated.xcent.der -framework TWFramework -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Intermediates.noindex/dynamic-fw.build/Debug-iphonesimulator/dynamic-fw.build/Objects-normal/arm64/dynamic-fw_dependency_info.dat -o /Users/raunit.shrivastava/Library/Developer/Xcode/DerivedData/dynamic-fw-foqtqhpopkmoapfufzxbfloamnpr/Build/Products/Debug-iphonesimulator/dynamic-fw.app/dynamic-fw
I am trying to debug the AAX version of my plugin (MIDI effect) on Pro Tools, but I am getting the following error (Mac console) when attempting to load it:
dlsym cannot find symbol g_dwILResult in CFBundle etc..
I used Xcode 16.4 to build the plugin.
Has anybody come across the same or a similar message?
Best,
Achillefs
Axart Labs
My Xcode project fails to run with the following crash log any time I use a new SwiftUI symbol such as ConcentricRectangle or .glassEffect. I've tried using the legacy linker to no avail. It compiles perfectly fine, and I've tried targeting just macOS 26 also to no avail. This is a macOS project that's compiled just fine for years and compiles and runs on macOS going back to 13.0.
Failed to look up symbolic reference at 0x118e743cd - offset 1916987 - symbol symbolic _____y_____y_____y_____yAAyAAy_____y__________G_____G_____yAFGGSg_ACyAAy_____y_____SSG_____y_____SgGG______tGSgACyAAyAAy_____ATG_____G_AVtGSgtGGAQySbGG______Qo_ 7SwiftUI4ViewPAAE11glassEffect_2inQrAA5GlassV_qd__tAA5ShapeRd__lFQO AA15ModifiedContentV AA6VStackV AA05TupleC0V AA01_hC0V AA9RectangleV AA5ColorV AA12_FrameLayoutV AA24_BackgroundStyleModifierV AA6IDViewV 8[ ]012EditorTabBarC0V AA022_EnvironmentKeyWritingS0V A_0W0C AA7DividerV A_0w4JumpyC0V AA08_PaddingP0V AA07DefaultgeH0V in /Users/[ ]/Library/Developer/Xcode/DerivedData/[ ]-grfjhgtlsyiobueapymobkzvfytq/Build/Products/Debug/[ ]/Contents/MacOS/[ ].debug.dylib - pointer at 0x119048408 is likely a reference to a missing weak symbol
Example crashing code:
import SwiftUI
struct MyView: View {
var body: some View {
if #available(macOS 26.0, *) {
Text("what the heck man").glassEffect()
}
}
}
I created 2 iOS projects in Xcode:
Project 1:
4 targets (main app + 3 app extensions)
4 static libraries
the main app's target dependencies include - 3 app extensions and the 4 libs.
the main app's binary is linked to all 4 libs
similarly, each extension is linked to all 4 libs
Project 2:
5 targets (main app + 3 app extensions + 1 framework)
4 static libraries
the main app's target dependencies include - 3 app extensions and the framework
each extension is dependent only on the framework
the framework's target dependencies include all the 4 static libs
As per my understanding, the app bundle size for Project 2 should be less than that of Project 1, since we eliminate duplicating the static libs for each target by using a framework instead.
However, I have found that the bundle size is more for Project 2 as compared to the bundle size of project 1.
I do not understand, why?
I'm having a problem with Xcode 26 where a symbol bug is causing my app to crash at launch if they are running iOS 17.X
This has to do with a HealthKit API that was introduced in iOS 18.1 HKQuantityType(.appleSleepingBreathingDisturbances), I use availability clauses to ensure I only support it in that version. This all worked fine with Xcode 16.4 but breaks in Xcode 26.
This means ALL my users running iOS 17 will get at launch crashes if this isn't resolved in the Xcode GM seed.
I'll post the code here in case I'm doing anything wrong. This, the HealthKit capability, the "HealthKit Privacy - Health Share Usage Description" and "Privacy - Health Update Usage Description", and device/simulator on iOS 17.X are all you need to reproduce the issue.
I've made a feedback too as I'm 95% sure it's a bug: FB19727966
import SwiftUI
import HealthKit
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
.task {
print(await requestPermission())
}
}
}
#Preview {
ContentView()
}
func requestPermission() async -> Bool {
if #available(iOS 18.0, *) {
let healthTypes = [HKQuantityType(.appleSleepingBreathingDisturbances)]
var readTypes = healthTypes.map({$0})
let write: Set<HKSampleType> = []
let res: ()? = try? await HKHealthStore().requestAuthorization(toShare: write, read: Set(readTypes))
guard res != nil else {
print("requestPermission returned nil")
return false
}
return true
}
else { return false}
}
This is a lengthy one. I have basically compiled a Rust binary into a dylib and packaged into a .xcframework that contains per arch .frameworks. This loads correctly when run from Xcode into a real iOS device. However, when deployed to TestFlight the app crashes.
Here is what is a bit different, the dylib is not fully self-contained. It tries to reach in an use C functions I have exposed in my library code. Calling functions that are just within the dylib and just return works fine, but the moment it tries to call one of the exposed functions it crashes.
A full in-depth step by step of how I packaged the binaries can be found in my website: https://ospfranco.com/complete-guide-to-dylibs-in-ios-and-android
When I look at the TestFlight crash report there are no symbols but the termination cause via WatchDog is:
Termination Reason: CODESIGNING 2 Invalid Page
I have declared my functions as such:
OBJC_EXTERN void ios_prepare_request(const char *url)
#define EXPORT __attribute__((visibility("default"), used, retain))
extern "C" {
EXPORT void ios_prepare_request(const char *url) {
NSString *urlString = [NSString stringWithUTF8String:url];
request =
[NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
}
}
// Function used to prevent optimization
void force_symbol_registration() {
// Force these symbols to be included in the binary by referencing them
volatile void *ptrs[] = {(void *)ios_prepare_request,};
// Prevent compiler from optimizing away the array
(void)ptrs;
}
And I load my framework as:
opacity::force_symbol_registration();
// NSBundle *dylib_bundle =
// [NSBundle bundleWithIdentifier:@"com.opacitylabs.sdk"];
// NSString *dylib_path = [dylib_bundle pathForResource:@"sdk" ofType:@""];
// // Load the dynamic library
// void *handle = dlopen([dylib_path UTF8String], RTLD_NOW | RTLD_GLOBAL);
// if (!handle) {
// NSString *errorMessage = [NSString stringWithUTF8String:dlerror()];
// *error =
// [NSError errorWithDomain:@"OpacitySDKDylibError"
// code:1002
// userInfo:@{NSLocalizedDescriptionKey :
// errorMessage}];
// return -1; // or appropriate error code
// }
// Make sure the main executable's symbols are available
dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
NSBundle *frameworkBundle =
[NSBundle bundleWithIdentifier:@"com.opacitylabs.sdk"];
if (![frameworkBundle isLoaded]) {
BOOL success = [frameworkBundle load];
if (!success) {
NSString *errorMessage = @"Failed to load framework";
*error =
[NSError errorWithDomain:@"OpacitySDKDylibError"
code:1002
userInfo:@{NSLocalizedDescriptionKey : errorMessage}];
return -1;
}
}
As you can see, I have also tried dlopen both work when run from Xcode but crash when deployed on testflight.
I have tried re-signing the xcframework/frameworks on a pre build step but it doesn't work
As stated, I can call the functions inside the dylib, but once they try to call my exposed code it crashes
Is this achievable at all or just a limitation of the iOS sandbox?
I have been learning from the Apple Developer tutorials and I got stuck on the ScoreKeeper chapter with Testing. Since my Macbook Pro 2017 can only use Xcode 15.2 as the highest level, I am having issues with it. I saw a forum post that a certain level of Swift and the tool chain would fix this. I attempted to install Swift 5.10.1 to then realize I only had Xcode 15.2 not 15.3, so I had to attempt to install Swift 5.9. Since neither option worked, I uninstalled Xcode and removed any extra files along with swift packages, minus my projects, to redownload and reinstall Xcode 15.2. Now I am having issues with building the scheme, and I get link error,s and they pertain to Swift 5.10.1, which I had not installed any Swift packages after the Xcode reinstallation. I have tried another previous project even a new one same error. This was 7/30/25, as of today 7/31 I tried to install Swift 5.9 thinking it would overwrite or "downgrade" the package, no such luck. The file path in the error stops at the /.../...RELEASE.pkg file and does not continue, which seems to be the issue of the error. How to I fix this issue, I had a working product 3 dyas ago
I'm unable to API such as NSFileProviderManager on MacOS catalyst although the developer site says this extension is supported. https://developer.apple.com/documentation/fileprovider
I've attempted to build a iOS framework to import into the catalyst target with no luck (I thought Catalyst was against the iOS API — maybe not?). Also attempted building a MacOS framework to import (maybe it's the other way around) but no luck.
Has anyone found a workaround? Building for "MacOS for iPad" does work but isn't ideal for the UI.
I'm building an open-source framework called OgreNextMain on macOS, and it statically links to an open-source library called FreeImage. When I run the nm -gU command on the binary within the resulting framework, I see lots of the symbols from FreeImage, but a couple that I wanted to use are missing. I thought, maybe they get stripped if they are not called by OgreNextMain, so I looked into stripping options. The "strip style" in the Xcode build settings for OgreNextMain is set to "debugging symbols". I tried setting the "additional strip flags" build setting to have the "-s" option and the path to a file containing the names of the symbols I want, but that didn't have any effect.
H there!
I'm new to mergeable libraries, so sorry if I missed anything obvious. We have some really huge projects with mergeable libraries that started failing to build with Xcode 26 beta 3. After doing some research I managed to create a very small project where I was able to reproduce the issues. The project just contains a SwiftUI app and a framework. The framework includes just a class that is used from a SwiftUI view included in the app.
Problems
I found the following:
Default configuration (no mergeable libraries)
Everything works as expected
Automatic mergeable libraries
In this case I just set Create Merged Binary to Automatic. In this case:
the application can be properly built and run in the simulator
the SwiftUI preview stops working with the following report:
== PREVIEW UPDATE ERROR:
FailedToAnalyzeBuiltTargetDescription: Could not analyze the built target description for MLibTestCase to create the preview.
buildableName: MLibTestCase
==================================
| UnrecognizedLinkerArguments: Unrecognized linker arguments
|
| arguments: -no_merge_framework
|
Manual mergeable libraries
In this case I set:
Create Merged Binary to Automatic in the app target
Build Mergeable Library to Yes in the library target
and I get exactly the same result as above. But if in addition I set:
MAKE_MERGEABLE to YES as a User-Defined setting in the library target
now things gets really worse, as:
linking no longer works, failing with the following error:
duplicate symbol '_relinkableLibraryClassesCount' in:
[...]/Build/Products/Debug-iphonesimulator/MLib.framework/MLib
bundle-file
duplicate symbol '_relinkableLibraryClasses' in:
[...]/Build/Products/Debug-iphonesimulator/MLib.framework/MLib
bundle-file
ld: 2 duplicate symbols
the SwiftUI preview fails, but now due to the error mentioned above:
== PREVIEW UPDATE ERROR:
SchemeBuildError: Failed to build the scheme “MLibTestCase”
linker command failed with exit code 1 (use -v to see invocation)
Conclusions, thoughts and doubts
After watching the WWDC session on mergeable libraries and reading the corresponding Apple documentation I got the feeling that Xcode would automatically manage mergeable libraries in both Debug and Release configurations, doing different things, but after performing this experiment with Xcode 26 beta 3 I'm no longer convinced that this is the case.
Anyway, our projects seemed to be working properly until Xcode 26 beta 2, using the last mentioned settings, this is, manual merged binary, with frameworks including the build mergeable library and MAKE_MERGEABLE settings.
In addition, the symbols causing the duplication error seem to be synthesized by the linker in the case of mergeable libraries, so it's weird to get this error related with something that the linker is supposed to manage automatically. And don't forget that Unrecognized linker argument...
So:
Has Xcode 26 beta 3 changed the way mergeable libraries are treated and configured, or is this a bug?
In case this is not a bug, are we now supposed to provide different settings for Debug and Release builds? (I could create a merged binary only in the Release configuration, but again, we didn't have to do this before this Xcode version)
I'm encountering a crash on app launch. The crash is observed in iOS version 17.6 but not in iOS version 18.5. The only new notable thing I added to this app version was migrate to store kit 2.
Below is the error message from Xcode:
Referenced from: <DCC68597-D1F6-32AA-8635-FB975BD853FE> /private/var/containers/Bundle/Application/6FB3DDE4-6AD5-4778-AD8A-896F99E744E8/callbreak.app/callbreak
Expected in: <A0C8B407-0ABF-3C28-A54C-FE8B1D3FA7AC> /usr/lib/swift/libswift_Concurrency.dylib
Symbol not found: _$sScIsE4next9isolation7ElementQzSgScA_pSgYi_tYa7FailureQzYKFTu
Referenced from: <DCC68597-D1F6-32AA-8635-FB975BD853FE> /private/var/containers/Bundle/Application/6FB3DDE4-6AD5-4778-AD8A-896F99E744E8/callbreak.app/callbreak
Expected in: <A0C8B407-0ABF-3C28-A54C-FE8B1D3FA7AC> /usr/lib/swift/libswift_Concurrency.dylib
dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libLogRedirect.dylib:/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/System/Library/PrivateFrameworks/GPUToolsCapture.framework/GPUToolsCapture:/usr/lib/libViewDebuggerSupport.dylib```
and Stack Trace:
```* thread #1, stop reason = signal SIGABRT
* frame #0: 0x00000001c73716f8 dyld`__abort_with_payload + 8
frame #1: 0x00000001c737ce34 dyld`abort_with_payload_wrapper_internal + 104
frame #2: 0x00000001c737ce68 dyld`abort_with_payload + 16
frame #3: 0x00000001c7309dd4 dyld`dyld4::halt(char const*, dyld4::StructuredError const*) + 304
frame #4: 0x00000001c73176a8 dyld`dyld4::prepare(...) + 4088
frame #5: 0x00000001c733bef4 dyld`start + 1748```
Note: My app is a Godot App and uses objc static libraries. I am using swift with bridging headers for interoperability. This issue wasn't observed until my last version in which the migration to storekit2 was the only notable change.
What are my options if I want to iterate over loaded images (dynamic libraries) within a signal handler? I have a few solutions that might work, but without going too much into them, i'm curious if anyone has experience here, or ideas what to look into.
Cheers,
AC
Dear Apple Developer Support,
We are experiencing a critical issue after upgrading our development environment from Xcode 15 to Xcode 16 (beta). Our iOS application integrates Flutter via CocoaPods (install_all_flutter_pods and flutter_post_install) and uses plugins like webview_flutter.
After the upgrade, our project started failing at the linking stage with the following errors:
Undefined symbol: _XPluginsGetDataFuncOrAbort
Undefined symbol: _XPluginsGetFunctionPtrFromID
Undefined symbol: Plugins::SocketThreadLocalScope::SocketThreadLocalScope(int)
Undefined symbol: Plugins::SocketThreadLocalScope::~SocketThreadLocalScope()
Linker command failed with exit code 1
These symbols seem to originate from Flutter’s new native C++ plugin architecture (possibly via webview_flutter_wkwebview), and were previously resolving fine with Xcode 15.
We have ensured the following:
Added -lc++ and -ObjC to OTHER_LDFLAGS
Cleaned and rebuilt Flutter module via flutter build ios --release
Re-installed CocoaPods with pod install
Verified Flutter.xcframework and plugin xcframeworks are present
Despite this, the linker fails to resolve the mentioned symbols under Xcode 16. This suggests a stricter linker behavior or a compatibility issue with the new C++ plugin system Flutter uses.
Can you confirm:
If Xcode 16 introduces stricter C++/Objective-C++ linker constraints?
Is there an official workaround or updated documentation for dealing with Plugins::SocketThreadLocalScope and related symbol resolution?
Should these symbols be declared explicitly or provided in .xcframework format from plugin developers?
We would appreciate guidance or clarification on how to proceed with Flutter plugin compatibility under Xcode 16.
Thank you.
For some reason, after invoking an unrelated dlclose() call to unload any .dylib that had previously been loaded via dlopen(..., RTLD_NOW), the subsequent call to task_info(mach_task_self(), TASK_DYLD_INFO, ...) syscall returns unexpected structure in dyld_uuid_info image_infos->uuidArray, that, while it seems to represent an array of struct dyld_uuid_info elements, there is only 1 such element (dyld_all_image_infos *infos->uuidArrayCount == 1) and the app crashes when trying to access dyld_uuid_info image->imageLoadAddress->magic, as image->imageLoadAddress doesn't seem to represent a valid struct mach_header structure address (although it looks like a normal pointer within the process address space. What does it point to?).
This reproduces on macOS 15.4.1 (24E263)
Could you please confirm that this is a bug in the specified OS build, or point to incorrect usage of the task_info() API?
Attaching the C++ file that reproduces the issue to this email message
It needs to be built on macOS 15.4.1 (24E263) via Xcode or just a command line clang++ compiler. It may crash or return garbage, depending on memory layout, but on this macOS build it doesn’t return a correct feedfacf magic number for the struct mach_header structure.
Thank you
Feedback Assistant reference: FB18431345
//On `macOS 15.4.1 (24E263)` create a C++ application (for example, in Xcode), with the following contents. Note, that this application should crash on this macOS build. It will not crash, however, if you either:
//1. Comment out `dlclose()` call
//2. Change the order of the `performDlOpenDlClose()` and `performTaskInfoSyscall()` functions calls (first performTaskInfoSyscall() then performDlOpenDlClose()).
#include <iostream>
#include <dlfcn.h>
#include <mach/mach.h>
#include <mach-o/dyld_images.h>
#include <mach-o/loader.h>
void performDlOpenDlClose() {
printf("dlopen/dlclose function\n");
printf("Note: please adjust the path below to any real dylib on your system, if the path below doesn't exist!\n");
std::string path = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libswiftDemangle.dylib";
printf("Dylib to open: %s\n", path.c_str());
void* handle = ::dlopen(path.c_str(), RTLD_NOW);
if(handle) {
::dlclose(handle);
} else {
printf("Error: %s\n", dlerror());
}
}
void performTaskInfoSyscall() {
printf("Making a task_info() syscall\n");
printf("\033[34mSource File: %s\033[0m\n", __FILE__);
task_t task = mach_task_self();
struct task_dyld_info dyld_info;
mach_msg_type_number_t size = TASK_DYLD_INFO_COUNT;
kern_return_t kr = task_info(task, TASK_DYLD_INFO, (task_info_t)&dyld_info, &size);
if (kr != KERN_SUCCESS) {
fprintf(stderr, "task_info failed: %s\n", mach_error_string(kr));
}
const struct dyld_all_image_infos* infos =
(const struct dyld_all_image_infos*)dyld_info.all_image_info_addr;
printf("version: %d, infos->infoArrayCount: %d\n", infos->version, infos->infoArrayCount);
for(uint32_t i=0; i<infos->infoArrayCount; i++) {
dyld_image_info image = infos->infoArray[i];
const struct mach_header* header = image.imageLoadAddress;
printf("%d ", i);
printf("%p ", (void*)image.imageLoadAddress);
printf("(%x) ", header->magic);
printf("%s\n", image.imageFilePath);
fflush(stdout);
}
printf("\n\n");
printf("infos->uuidArrayCount: %lu\n", infos->uuidArrayCount);
for(uint32_t i=0; i<infos->uuidArrayCount; i++) {
dyld_uuid_info image = infos->uuidArray[i];
const struct mach_header* header = image.imageLoadAddress;
printf("%d ", i);
printf("%p ", (void*)image.imageLoadAddress);
printf("(%x)\n", header->magic);
fflush(stdout);
}
printf("task_info() syscall result processing is completed\n\n");
}
int main(int argc, const char * argv[]) {
performDlOpenDlClose();
performTaskInfoSyscall();
return 0;
}
Hello
I have a qt, CMAKE app, non-xcode one till xcode start supporting cmake.
I have 3 apps, 2 basic ones and 1 very complex ones.
My complex one build/links/notarises/validates/deploys beautifly. I have tear in my eye when I see it build.
The other 2 apps explode and torment me for past 5 days. The build proves is 99% the same, the only thing that a little changes are info.plist and app name+ some minor changes.
Its absolutely bananas and I can't fix it, I'm running out of ideas so if any1 could sugged anything, I'll buy & ship you a beer.
Anyway, errors:
Log: Using otool:
Log: inspecting "/Users/dariusz/Qt/6.9.1/macos/lib/QtCore.framework/Versions/A/QtCore"
Log: Could not parse otool output line: "/Users/dariusz/Qt/6.9.1/macos/lib/QtCore.framework/Versions/A/QtCore (architecture arm64):"
Log: Adding framework:
Log: Framework name "QtCore.framework"
Framework directory "/Users/dariusz/Qt/6.9.1/macos/lib/"
Framework path "/Users/dariusz/Qt/6.9.1/macos/lib/QtCore.framework"
Binary directory "Versions/A"
Binary name "QtCore"
Binary path "/Versions/A/QtCore"
Version "A"
Install name "@rpath/QtCore.framework/Versions/A/QtCore"
Deployed install name "@rpath/QtCore.framework/Versions/A/QtCore"
Source file Path "/Users/dariusz/Qt/6.9.1/macos/lib/QtCore.framework/Versions/A/QtCore"
Framework Destination Directory (relative to bundle) "Contents/Frameworks/QtCore.framework"
Binary Destination Directory (relative to bundle) "Contents/Frameworks/QtCore.framework/Versions/A"
Log: copied: "/Users/dariusz/Qt/6.9.1/macos/lib/QtWebSockets.framework/Versions/A/QtWebSockets"
Log: to "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/Versions/A/QtWebSockets"
Log: copy: "/Users/dariusz/Qt/6.9.1/macos/lib/QtWebSockets.framework/Resources" "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/Versions/A/Resources"
Log: copied: "/Users/dariusz/Qt/6.9.1/macos/lib/QtWebSockets.framework/Resources/Info.plist"
Log: to "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/Versions/A/Resources/Info.plist"
Log: copied: "/Users/dariusz/Qt/6.9.1/macos/lib/QtWebSockets.framework/Resources/PrivacyInfo.xcprivacy"
Log: to "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/Versions/A/Resources/PrivacyInfo.xcprivacy"
Log: symlink "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/QtWebSockets"
Log: points to "Versions/Current/QtWebSockets"
Log: symlink "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/Resources"
Log: points to "Versions/Current/Resources"
Log: symlink "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/Frameworks/QtWebSockets.framework/Versions/Current"
Log: points to "A"
Log: Using install_name_tool:
Log: in "/AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/MacOS/Agameri_Toolbox"
Log: change reference "@rpath/QtWebSockets.framework/Versions/A/QtWebSockets"
Log: to "@rpath/QtWebSockets.framework/Versions/A/QtWebSockets"
ERROR: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: fatal error: file not in an order that can be processed (link edit information does not fill the __LINKEDIT segment): /AppBuild/Agameri_Toolbox/Agameri_Toolbox.app/Contents/MacOS/Agameri_Toolbox\n"
ERROR: ""
Even tho I get that error, it will "Notarize" and "greenlight by gatekeeper.
So my automatic build app if he sees error with the __LINKEDIT it will stop deployment.
But even tho he "stops" release of app to public I can still go check binary and when I try to run that I get:
Library not loaded: @rpath/QtConcurrent.framework/Versions/A/QtConcurrent
Referenced from: <69A296DB-8C7D-3BC9-A8AE-947B8D6ED224> /Volumes/VOLUME/*/Agameri_Toolbox.app/Contents/MacOS/Agameri_Toolbox
Reason: tried: '/Users/dariusz/Qt/6.9.1/macos/lib/QtConcurrent.framework/Versions/A/QtConcurrent' (code signature in <192D5FAC-FE8C-31AB-86A7-6C2CE5D3E864> '/Users/dariusz/Qt/6.9.1/macos/lib/QtConcurrent.framework/Versions/A/QtConcurrent' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/System/Volumes/Preboot/Cryptexes/OS/Users/dariusz/Qt/6.9.1/macos/lib/QtConcurrent.framework/Versions/A/QtConcurrent' (no such file), '/Volumes/DEV_MAC/02_CODE/Dev/Icarus.nosync/Icarus_Singleton/codeSingleton/libOutput/Release/QtConcurrent.framework/Versions/A/QtConcurrent' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Volumes/DEV_MAC/02_CODE/Dev/Icarus.nosync/Icarus_Singleton/codeSingleton/libOu
(terminated at launch; ignore backtrace)
And here is my build script, its QT based application, I'm using macdeployqt + my own custom signing as the one from macdeployqt breaks on the complex app. (I will post it in next post as apparently there is 7k limit O.O)
I've tried to replace the @rpath/ to @executable_path but that has made a million new issues and I'm just lost.
I have an app (currently in development stage) which needs to use ffmpeg, so I tried searching how to embed ffmpeg in apple apps and found this article https://doc.qt.io/qt-6/qtmultimedia-building-ffmpeg-ios.html
It is working correctly for iOS but not for macOS ( I have made changes macOS specific using chatgpt and traditional web searching)
Drive link for the file and instructions which I'm following: https://drive.google.com/drive/folders/11wqlvb8SU2thMSfII4_Xm3Kc2fPSCZed?usp=share_link
Please can someone from apple or in general help me to figure out what I'm doing wrong?
Hi,
I encountered an issue in my code where I directly used #import <CoreHaptics/CoreHaptics.h> without adding it to the "Link Binary With Libraries" section under Build Phases. My deployment target is iOS 12, and the code was running fine before; however, after upgrading Xcode, the app crashes immediately on an iOS 12 device with the following error message: DYLD, Library not loaded: /System/Library/Frameworks/CoreHaptics.framework/CoreHaptics | xx | Reason: image not found.
Did Xcode modify the default auto-linking configuration? When did this behavior change in which version of Xcode? Do I need to specify CoreHaptics.framework as Optional in "Link Binary With Libraries"?
Thanks for reply soon!
Using xcode 26 with linker flag -ld_classic,get an error :
0 0x1042b9778 __assert_rtn + 160
1 0x1042bc560 ld::tool::SymbolTableAtom<x86_64>::classicOrdinalForProxy(ld::Atom const*) (.cold.3) + 0
2 0x1041f3da8 ld::tool::SymbolTableAtom<x86_64>::classicOrdinalForProxy(ld::Atom const*) + 172
3 0x1041f4c1c ld::tool::SymbolTableAtom::addImport(ld::Atom const*, ld::tool::StringPoolAtom*) + 140
4 0x1041f6500 ld::tool::SymbolTableAtom::encode() + 396
5 0x1041e83a8 ___ZN2ld4tool10OutputFile20buildLINKEDITContentERNS_8InternalE_block_invoke.413 + 36
6 0x182a95b2c _dispatch_call_block_and_release + 32
7 0x182aaf85c _dispatch_client_callout + 16
8 0x182acc478 _dispatch_channel_invoke.cold.5 + 92
9 0x182aa7fa4 _dispatch_root_queue_drain + 736
10 0x182aa85d4 _dispatch_worker_thread2 + 156
11 0x182c49e28 _pthread_wqthread + 232
A linker snapshot was created at:
/tmp/app-2025-06-13-215652.ld-snapshot
ld: Assertion failed: (it != _dylibToOrdinal.end()), function dylibToOrdinal, file OutputFile.cpp, line 5196.
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Environment:
Xcode Version: 16.0 (latest stable release)
iOS Version: 18.3.1
Devices: physical devices
Configuration: Main Thread Checker enabled (Edit Scheme &gt; Run &gt; Diagnostics)
Issue Description
When the Main Thread Checker is enabled, methods defined in a UIViewController category (e.g., supportedInterfaceOrientations) fail to execute, whereas the subclass implementation of the same method works as expected. This conflicts with the normal behavior where both implementations should be called.
Steps to Reproduce
1、Declare a category method in UIViewController+Extend.m:
// UIViewController+Extend.m
@implementation UIViewController (Extend)
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
NSLog(@"category supportedInterfaceOrientations hit");
return UIInterfaceOrientationMaskAll;
}
@end
2、Override the same method in a subclass ,call super methed(ViewController.m):
// ViewController.m
@implementation ViewController
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
NSLog(@"subclass called supportedInterfaceOrientations called");
return [super supportedInterfaceOrientations]; // Expected to call the category implementation
}
@end
3、Expected Behavior (Main Thread Checker disabled):
subclass called supportedInterfaceOrientations called
category supportedInterfaceOrientations hit
4、Actual Behavior (Main Thread Checker enabled):
subclass called supportedInterfaceOrientations called
// category supportedInterfaceOrientations hit
Requested Resolution
Please investigate:
1、Why Main Thread Checker disrupts category method invocation.
2、Whether this is a broader issue affecting other UIKit categories.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
Linker
Xcode Sanitizers and Runtime Issues
UIKit
Hi !
I'm currently stuck with an issue on Xcode, I'll try explain to the best I can :-)
I have a workspace (that I need to keep that way, I can't split projects) that contains multiple projects.
I have 2 frameworks : Core and Draw. Draw depends on Core. So far so good.
I needed to create a test application that can be modular and link my framewok, but also other drawing frameworks.
To that extend, I created a CardLIbrary framewok, and a CardAdapter framewok, and I linked them into the test application.
Test App
└── DrawCardAdapter
│ └── CardAdapter
│ └── CardLibrary
│ └── Core
│ └── TCA (SPM)
│ └── Draw
│ └── Core
Here, all dependencies are local ones if not stated otherwise (for the SPM).
CardLibrary is a framework that generates only UI (linked to Core for logging purposes, nothing fancy). I also added TCA which is a SPM dependency, it may generate some issues after.
CardAdapter is an abstraction for CardLibrary. Basically, it acts as an interface between CardLibrary and Test Application.
DrawCardAdapter is the actual implementation of CardAdapter using local Draw framework.
Why so complex ? Because I need to be able to do this:
Test App
└── ExternalDrawCardAdapter
│ └── CardAdapter
│ └── CardLibrary
│ └── Core
│ └── TCA (SPM)
│ └── ExternalDrawFramework
With this architecture, I can create a new ExternalDrawCardAdapter that implents the CardAdapter logic. This new framework does not relies on my Draw framework, and yet, I can still generate a test application that visually looks and feel like all others, but use a completely different drawing engine underneath.
To do that, the Test App code only uses inputs and outputs from CardAdapter (the protocol), not concrete implementations like DrawCardAdapter or ExternalDrawCardAdapter.
But to be able to make it work, I have 2 test ap targets : a DrawTestApp and a ExternalDrawTestApp. All code files are shared, except a SdkLauncher that is target specific and acutally loads the proper implementation. So the SdkLauncher for DrawTestApp is linked to the DrawCardAdapter (embed and sign) and loads DrawCardAdapter framework, whereas the ExternalDrawTestApp is linked to the ExternalDrawCardAdapter (embed and sign) and loads ExternalDrawCardAdapter framework.
Now it looks like this (I only show local stuff othewise it would be too complicated :D)
So far so good, this works well.
Now, for the part that fails.
My Draw and Core frameworks are frameworks that I release for my customers (Cocoapod), and I wanted to be able to test my productions frameworks with the test app (it's that actual purpose of the test app : being able to test development and released SDKs)
To do so, I duplicated every target and removed local dependency for a cocoapod dependency. All targets were named -pod, but the actual module and product name are still the same (I tried differently, it did not work either, I'll explain it later).
Test App
└── DrawCardAdapter
│ └── CardAdapter
│ └── CardLibrary
│ └── Core
│ └── TCA (SPM)
│ └── Draw
│ └── Core
│
Test App Pod
└── DrawCardAdapter-pod
│ └── CardAdapter-pod
│ └── CardLibrary-pod
│ └── Core-pod
│ └── TCA (SPM)
│ └── Draw-pod
│ └── Core-pod
Once again, it's only targets, every project would look like
CardAdapter
└── CardAdapter
└── CardAdapter-pod
It continues to use local targets, except for the DrawCardAdapter-pod that actually loads Draw and Core from a Podfile instead of using the lkocal frameworks.
But now for the part that fails : even though TestApp-pod does not link any local frameworks, I get a warning
Multiple targets match implicit dependency for product reference 'Draw.framework'. Consider adding an explicit dependency on the intended target to resolve this ambiguity.
And actually, Xcode ends up packaging the wrong framework. I can check it but showing in the app the Draw framework version, and it's always the local one, not the one specified in the podfile.
For the record, I get this message for all 3 frameworks of course.
I tried sooooo many things, that did not work of course:
renaming the -pod frameworks so that the names are different (I had to rename all imports too). It works for all local frameworks (Lilbrary and Adapter basically), but not for Draw and Core (since I don't have -podversions of thoses framewoks of course).
Creating a new local workspace that only handles -pod versions. Does not work since as we work as a team, I have to keep the shared schemes, and all workspaces see all targets and schemes. I also tried with a separate derived data folder, but I end up with some compilation issues. It seems that mixing local, cocoapod and spm dependencies inside the same workspace is not well handled)
using explicit Target Dependenciesfrom the build phase. I end up with some compilation issues
creating local podspecs for Library and Adapter. It fails because TCA is linked with SPM and apparently not copied when using podspecs.
To the few ones that stayed so far, thanks for your patience :D I hope that @eskimo will drop by as you always were my savior in the end :D :D