Use dyld to link in frameworks at runtime. Use ld to make your programs and link archive libraries at build time.

Linker Documentation

Pinned Posts

Posts under Linker tag

162 Posts
Sort by:
Post not yet marked as solved
0 Replies
1.1k Views
Hello everyone, I am having an issue in Xcode after updating to version 14.3.1 and I'm hoping someone might be able to help me. I am working on macOS 13.4.1. I'm trying to integrate the Firebase SDK (version 8.15.0) into my project through Cocoapods. The specific Firebase frameworks I am using are FirebaseAnalytics, FirebaseAuth, FirebaseCore, FirebaseDynamicLinks, FirebaseFirestore, FirebaseInstallations, FirebaseMessaging, and FirebaseStorage. Despite installing these successfully, I am facing an error that states "Framework not found Firebase". It does not specify any particular Firebase framework that's missing. I have attempted several potential solutions such as reinstalling pods, cleaning the project, deleting derived data, and even switching the package manager from Cocoapods to Swift Package Manager. I've also tried adjusting the header paths. Unfortunately, none of these methods have resolved the issue. Below is the error message from my log: ld: warning: directory not found for option '-F/Users/oscarnilsson/Library/Developer/Xcode/DerivedData/Aircutt_Business-cibnpzcszsymgwgztnynnwvihkub/Build/Products/Debug-iphoneos/FirebaseAppCheckInterop' ld: warning: directory not found for option '-F/Users/oscarnilsson/Library/Developer/Xcode/DerivedData/Aircutt_Business-cibnpzcszsymgwgztnynnwvihkub/Build/Products/Debug-iphoneos/FirebaseAuthInterop' ld: warning: directory not found for option '-F/Users/oscarnilsson/Library/Developer/Xcode/DerivedData/Aircutt_Business-cibnpzcszsymgwgztnynnwvihkub/Build/Products/Debug-iphoneos/FirebaseCoreExtension' ld: warning: directory not found for option '-F/Users/oscarnilsson/Library/Developer/Xcode/DerivedData/Aircutt_Business-cibnpzcszsymgwgztnynnwvihkub/Build/Products/Debug-iphoneos/FirebaseCoreInternal' ld: framework not found Firebase clang: error: linker command failed with exit code 1 (use -v to see invocation) Has anyone experienced a similar issue or does anyone have any insights into what could be causing this? Any help would be greatly appreciated. Best, Oscar
Posted
by
Post not yet marked as solved
1 Replies
266 Views
while I'm running a code on vs i'm getting an error on my terminal it saying -clang: error: linker command failed with exit code 1 (use -v to see invocation). and i cant run my vs as i'm a student and I need to write my code and checking it but when i downloade the vs on my mac it was not working properly. its my first time using apple product and it giving me very bad expression i checked the problem on internet but still i couldn't get any solution
Posted
by
Post not yet marked as solved
0 Replies
582 Views
I regularly see questions from folks who’ve run into problems with their third-party IDE on macOS. Specifically, the issue is that their IDE is invoking Apple’s command-line tools — things like clang and ld — and that’s failing in some way. This post collects my ideas on how to investigate, and potentially resolve, issues like this. If you have any questions or comments, please put them in a new thread here on DevForums. Tag it appropriately so that I see it. Good tags include Compiler, Linker, LLVM, and Command Line Tools. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Investigating Third-Party IDE Integration Problems Many third-party IDEs rely on Apple tools. For example, the IDE might run clang to compile C code or run ld to link object files. These IDEs typically don’t include the tools themselves. Rather, they rely on you to install Xcode or Apple’s Command Line Tools package. These are available at Apple > Developer > Downloads Occasionally I see folks having problems with this. They most typically report that basic stuff, like compiling a simple C program, fails with some mysterious error. If you’re having such a problem, follow the steps below to investigate it. IMPORTANT Some IDEs come with their own tools for compiling and linking. Such IDEs are not the focus of this post. If you have problems with an IDE like that, contact its vendor. Select Your Tools macOS has a concept of the current command-line tools. This can either point to the tools within Xcode or to an installed Command Line Tools package. To see which tools are currently selected, run xcode-select with the --print-path argument. This is what you’ll see if you have Xcode installed in the Applications folder: % xcode-select --print-path /Applications/Xcode.app/Contents/Developer Note All of the tools I discuss here are documented in man pages. If you’re not familiar with those, see Reading UNIX Manual Pages. And this is what you’ll see with a Command Line Tools package selected. % xcode-select --print-path /Library/Developer/CommandLineTools There are two common problems with this: It points to something you’ve deleted. It points to something unexpected. Run the command above to see the current state. If necessary, change the state using the --switch option. For example: % xcode-select --print-path /Applications/Xcode.app/Contents/Developer % clang -v Apple clang version 14.0.3 (clang-1403.0.22.14.1) … % sudo xcode-select --switch ~/XcodeZone/Xcode-beta.app % clang -v Apple clang version 15.0.0 (clang-1500.0.38.1) … I have Xcode 14.3 in the Applications foledr and thus clang runs Clang 14.0.3. I have Xcode 15.0b5 in ~/XcodeZone, so switching to that yields Clang 15.0.0. It’s possible to run one specific command with different tools. See Select Your Tools Temporarily, below. Run a Simple Test A good diagnostic test is to use the selected command-line tools to compile a trivial test program. Consider this C [1] example: % cat hello.c #include <stdio.h> int main(int argc, char ** argv) { printf("Hello Cruel World!\n"); return 0; } % clang -o hello hello.c % ./hello Hello Cruel World! IMPORTANT If possible, run this from Terminal rather than, say, over SSH. You may need to expand this test program to exercise your specific case. For example, if your program is hitting an error when it tries to import the Core Foundation framework, add that import to your test program: % cat hello.c #include <stdio.h> #include <CoreFoundation/CoreFoundation.h> int main(int argc, char ** argv) { printf("Hello Cruel World!\n"); return 0; } When you compile your test program, you might see one of these results: Your test program compiles. Your test program fails with a similar error. Your test program fails with a different error. I’ll explore each case in turn. [1] For a C++ example, see C++ Issues, below. If your test program compiles… If your test program compiles from the shell, that proves that your basic command-line tools setup is fine. If the same program fails to compile in your IDE, there’s something IDE-specific going on here. I can’t help you with that. I recommend that you escalate the issue via the support channel for your IDE. If your test program fails with a similar error… If your test program fails with an error similar to the one you’re seeing in your IDE, there are two possibilities: There’s a bug in your test program’s code. There’s an environmental issue that’s affecting your command-line tools setup. Don’t rule out the first possibility. I regularly see folks bump into problems like this, where it turns out to be a bug in their code. For a specific example, see C++ Issues, below. Assuming, however, that your test program’s code is OK, it’s time to investigate environmental issues. See Vary Your Environment, below. If your test program fails with a different error… If your test program fails with a different error, look at the test program’s code to confirm that it’s correct, and that it accurately reflects the code you’re trying to run in your IDE. Vary Your Environment If your test program fails with the same error as you’re seeing in your IDE, and you are sure that the code is correct, it’s time to look for environmental factors. I typically do this with the steps described in the next sections, which are listed from most to least complex. These steps only tell you where things are going wrong, not what is going wrong. However, that’s often enough to continue the investigation of your issue. Vary Your Shell Try running your commands in a different shell. macOS’s default shell is zsh. Try running your commands in bash instead: % bash … bash-3.2$ clang -o hello hello.c bash-3.2$ ./hello Hello Cruel World! Or if you’ve switched your shell to bash, try it in zsh. Vary Your User Account Some problems are caused by settings tied to your user account. To investigate whether that’s an issue here: Use System Settings > Users & Groups to create a new user. Log in as that user. Run your test again. Vary Your Mac Some problems are system wide, so you need to test on a different Mac. The easiest way to do that is to set up a virtual machine (VM) and run your test there. Or, if you have a separate physical Mac, run your test on that. Vary Your Site If you’re working for an organisation, they may have installed software on your Mac that causes problems. If you have a Mac at home, try running your test there. It’s also possible that your network is causing problems [1]. If you have a laptop, try taking it to a different location to see if that changes things. [1] I rarely see this when building a simple test program, but it do see it with other stuff, like code signing. C++ Issues If you’re using C++, here’s a simple test you can try: % cat hello.cpp #include <iostream> int main() { std::cout << "Hello Cruel World!\n"; } % clang++ -o hello hello.cpp % ./hello Hello Cruel World! A classic problem with C++ relates to name mangling. Consider this example: % cat hello.c #include <stdio.h> #include "hello-core.h" int main(int argc, char ** argv) { HCSayHello(); return 0; } % cat hello-core.cpp #include "hello-core.h" #include <iostream> extern void HCSayHello() { std::cout << "Hello Cruel World!\n"; } % cat hello-core.h extern void HCSayHello(); % clang -c hello.c % clang++ -c hello-core.cpp % clang++ -o hello hello.o hello-core.o Undefined symbols for architecture x86_64: "_HCSayHello", referenced from: _main in hello.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The issue here is that C++ generates a mangled name for HCSayHello: % nm hello-core.o | grep HCSayHello 0000000000000000 T __Z10HCSayHellov whereas C uses the non-mangled name: % nm hello.o | grep HCSayHello U _HCSayHello The fix is an appropriate application of extern "C": % cat hello-core.h extern "C" { extern void HCSayHello(); }; Select Your Tools Temporarily Sometimes you want to temporarily run a command from a particular tools package. To continue my earlier example, I currently have Xcode 14.3 installed in the Applications folder and Xcode 15.0b5 in ~/XcodeZone. Xcode 14.3 is the default but I can override that with the DEVELOPER_DIR environment variable: % clang -v Apple clang version 14.0.3 (clang-1403.0.22.14.1) … % DEVELOPER_DIR=~/XcodeZone/Xcode-beta.app/Contents/Developer clang -v Apple clang version 15.0.0 (clang-1500.0.38.1) …
Posted
by
Post not yet marked as solved
1 Replies
510 Views
Hi! I've been dealing with mergeable libraries quite some time. However I can't achieve the following scenario: I have 2 xcframeworks A and B that are merged as part of a third xcframework called C. And my app needs to import something from A and B. As per the documentation we have to remove the references from A and B from the final app and replace it with C. If I work on the same xcodepoj it works like a charm (maybe because of caches), but if I try to compile C as a separate XCFramework and distribute it as a packed library, the app is not able to resolve the symbols to A and B classes. This C xcframework is compiled with BUILD_LIBRARY_FOR_DISTRIBUTION se to true and if I check its swiftinterface files it is not declaring the symbols from A and B. However the size of the binary seems to have A and B. Is there any way to export A and B symbols as part of C's swiftinterface? If I add @_exported, it is forcing me to declare the import of A and B wherever I use them and therefore I'm going to have duplicated symbols Thanks!
Posted
by
Post marked as solved
2 Replies
464 Views
I have a static library staticLib.a which is witten mostly in C++ with one additional obj-C class MyClass. There are two dynamic libs, dynamicLib_A. dylib and dynamicLib_B.dylib are linked with the static lib. When starting the application which loads the dynamic libs at runtime it comes out the following warning: objc[15078]: Class MyClass is implemented in both /path/to/libdynamicLib_A.dylib (0x104f03f90) and /path/to/libdynamicLib_B.dylib (0x10dbf3f48). One of the two will be used. Which one is undefined. It can be found that the C++ names are mangled. For instance, both libdynamicLib_A.dylib and libdynamicLib_B contains string: __ZN18MyClassBC2Ev It looks like the obj-c class name is not mangled. Both libdynamicLib_A.dylib and libdynamicLib_B contains string: 00000000012b7f48 S OBJC_CLASS$_MyClass Question: How to avoid this warning? Why it complains only about the obj-c class but not the C++ class? Is this issue related to name mangling?
Posted
by
Post marked as solved
5 Replies
709 Views
I have got a crash related with RoomPlan framework on iOs 13.5.1 Hardware Model: iPad6,11 Process: xxxxxxx [4677] Path: /private/var/containers/Bundle/Application/15CC2737-2FFD-4A17-A111-A2DB7A6838E0/xxxxxxx.app/xxxxxxx Identifier: xxxxxxx Version: 1489 (4.7.3) AppStoreTools: 14E221 AppVariant: 1:iPad6,11:13 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: xxxxxxx [1071] Date/Time: 2023-08-05 04:34:53.0188 +0700 Launch Time: 2023-08-05 04:34:52.7050 +0700 OS Version: iPhone OS 13.5.1 (17F80) Release Type: User Baseband Version: n/a Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Description: DYLD, can't resolve symbol _$s8RoomPlan0A14CaptureSessionC13ConfigurationVMa in /private/var/containers/Bundle/Application/15CC2737-2FFD-4A17-A111-A2DB7A6838E0/xxxxxxx.app/xxxxxxx because dependent dylib #40 could not be loaded Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 dyld 0x0000000105ea8f68 __abort_with_payload + 8 1 dyld 0x0000000105eafee8 abort_with_payload_wrapper_internal + 100 (terminate_with_reason.c:102) 2 dyld 0x0000000105eaff18 abort_with_payload + 12 (terminate_with_reason.c:124) 3 dyld 0x0000000105ead13c dyld::halt(char const*) + 384 (dyld2.cpp:4240) 4 dyld 0x0000000105e607fc dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 168 (dyld2.cpp:4328) 5 libdyld.dylib 0x00000001b1482398 dyld_stub_binder + 60 6 xxxxxxx 0x000000010475cc38 type metadata completion function for RoomPlanCaptureViewController + 60 (<compiler-generated>:0) 7 libswiftCore.dylib 0x00000001bedcf76c swift_getSingletonMetadata + 956 (MetadataCache.h:920) 8 xxxxxxx 0x000000010475a540 type metadata accessor for RoomPlanCaptureViewController + 48 (<compiler-generated>:0) 9 libobjc.A.dylib 0x00000001b13ab958 realizeAllClasses() + 112 (objc-runtime-new.mm:2840) 10 libobjc.A.dylib 0x00000001b13ae6dc objc_getClassList + 92 (objc-runtime-new.mm:5013) . . 14 dyld 0x0000000105e732c4 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 428 (ImageLoaderMachO.cpp:2427) 15 dyld 0x0000000105e736b0 ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 52 (ImageLoaderMachO.cpp:2524) 16 dyld 0x0000000105e6e0f0 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 536 (ImageLoader.cpp:1621) 17 dyld 0x0000000105e6c520 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 184 (ImageLoader.cpp:605) 18 dyld 0x0000000105e6c5e8 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 92 (ImageLoader.cpp:620) 19 dyld 0x0000000105e61a64 dyld::runInitializers(ImageLoader*) + 88 (dyld2.cpp:4923) 20 dyld 0x0000000105e687b8 dlopen_internal + 832 (dyldAPIs.cpp:1761) 21 libdyld.dylib 0x00000001b1483a08 dlopen + 172 (dyldAPIsInLibSystem.cpp:1545) . . . 30 dyld 0x0000000105e732c4 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 428 (ImageLoaderMachO.cpp:2427) 31 dyld 0x0000000105e736b0 ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 52 (ImageLoaderMachO.cpp:2524) 32 dyld 0x0000000105e6e0f0 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 536 (ImageLoader.cpp:1621) . . 36 dyld 0x0000000105e687b8 dlopen_internal + 832 (dyldAPIs.cpp:1761) 37 libdyld.dylib 0x00000001b1483a08 dlopen + 172 (dyldAPIsInLibSystem.cpp:1545) 38 substitute-inserter.dylib 0x0000000106019284 0x105f3c000 + 905860 39 substitute-inserter.dylib 0x0000000106326ac0 0x105f3c000 + 4106944 40 substitute-inserter.dylib 0x00000001062e7980 0x105f3c000 + 3848576 41 dyld 0x0000000105e732c4 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 428 (ImageLoaderMachO.cpp:2427) 42 dyld 0x0000000105e736b0 ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 52 (ImageLoaderMachO.cpp:2524) 43 dyld 0x0000000105e6e0f0 ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 536 (ImageLoader.cpp:1621) 44 dyld 0x0000000105e6c520 ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) + 184 (ImageLoader.cpp:605) 45 dyld 0x0000000105e6c5e8 ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) + 92 (ImageLoader.cpp:620) 46 dyld 0x0000000105e5e608 dyld::initializeMainExecutable() + 136 (dyld2.cpp:1569) 47 dyld 0x0000000105e62eb0 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 4400 (dyld2.cpp:6989) 48 dyld 0x0000000105e5d208 dyldbootstrap::start(dyld3::MachOLoaded const*, int, char const**, dyld3::MachOLoaded const*, unsigned long*) + 396 (dyldInitialization.cpp:145) 49 dyld 0x0000000105e5d038 _dyld_start + 56 by framework is weakly linked Load command 53 cmd LC_LOAD_WEAK_DYLIB cmdsize 80 name /System/Library/Frameworks/RoomPlan.framework/RoomPlan (offset 24) time stamp 2 Thu Jan 1 03:00:02 1970 current version 1.0.0 compatibility version 1.0.0
Posted
by
Post not yet marked as solved
22 Replies
4.1k Views
In Xcode 15 beta 6, building any Mac Catalyst project will encounter the following Linker warning. ld: warning: building for 'macCatalyst', but linking in dylib (/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa.tbd) built for 'macOS'
Posted
by
Post not yet marked as solved
2 Replies
731 Views
I'm encountering a linker error while trying to build an iOS application developed using Ionic, Capacitor, and Angular. The build process fails for both debug (testing on the device) and release builds. Ld /Users/Library/Developer/Xcode/DerivedData/App/Build/Products/Debug-iphoneos/WxWxnetwork/WxWxnetwork.framework/WxWxnetwork normal (in target 'WxWxnetwork' from project 'Pods') cd /AppName/ios/App/Pods/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios13.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk - L/Users/Library/Developer/Xcode/DerivedData/App/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphoneos - L/Users/Library/Developer/Xcode/DerivedData/App/Build/Products/Debug-iphoneos/WxWxnetwork -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk/usr/lib/swift - F/Users/Library/Developer/Xcode/DerivedData/App/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphoneos - F/Users/Library/Developer/Xcode/DerivedData/App/Build/Products/Debug-iphoneos/WxWxnetwork - F/Users/Library/Developer/Xcode/DerivedData/App/Build/Products/Debug-iphoneos/Capacitor - F/Users/Library/Developer/Xcode/DerivedData/App/Build/Products/Debug-iphoneos/CapacitorCordova - F/Users/Documents/Test/ios/App/Pods/../../../node_modules/wx-wxnetwork -filelist /Users/Library/Developer/Xcode/DerivedData/App/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/WxWxnetwork.build/Objects-normal/arm64/WxWxnetwork.LinkFileList -install_name @rpath/WxWxnetwork.framework/WxWxnetwork -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/Library/Developer/Xcode/DerivedData/App/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/WxWxnetwork.build/Objects-normal/arm64/WxWxnetwork_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime - L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/Library/Developer/Xcode/DerivedData/App/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/WxWxnetwork.build/Objects-normal/arm64/WxWxnetwork.swiftmodule -framework Capacitor -framework ICDeviceManager -framework Foundation -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/Library/Developer/Xcode/DerivedData/App/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/WxWxnetwork.build/Objects-normal/arm64/WxWxnetwork_dependency_info.dat -o /Users/Library/Developer/Xcode/DerivedData/App/Build/Products/Debug-iphoneos/WxWxnetwork/WxWxnetwork.framework/WxWxnetwork Project Info: Xcode: 14.3.1 IOS SDK: 16.4 Capacitor: 5.2.2 Ionic: 7 Angular: 16 I've tried multiple solutions to address the linker error including targeting ios 11. However, none of them have worked so far. Since I can't decrease the target iOS version due to the Capacitor requirement. Any insights or suggestions would be greatly appreciated. Thank you in advance!
Posted
by
Post not yet marked as solved
0 Replies
396 Views
We are developing an application for iOS in Xamarin in Visual Studio (XCode CLT 14.3.1 on a MacBook Pro with M2 Chip and Ventura). We have a Woosim Printer, where the sdk is written in c++ but uses Swift modules. When i try to add the .dll in the project i get the following errors. I added these flags to the project: --gcc_flags -L/usr/lib/swift --gcc_flags -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos --gcc_flags "-Wl,-rpath -Wl,@executable_path/Frameworks“ Does anybody know, what am i doing wrong? Or is this a linkerproblem?
Posted
by
Post not yet marked as solved
0 Replies
795 Views
While i am trying to Archive a react native project, I am getting an error that is "Undefined symbols for architecture arm64". Configuration is :- React Native :- "0.71.6" React :- "18.2.0" Xcode Version :- 14.2 The error is in the bellow :- Undefined symbols for architecture arm64: "OBJC_CLASS$_FKUserDefaultsPlugin", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) "OBJC_CLASS$_FlipperClient", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) "OBJC_CLASS$_FlipperKitLayoutPlugin", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) "OBJC_CLASS$_FlipperKitNetworkPlugin", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) "OBJC_CLASS$_FlipperKitReactPlugin", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) "OBJC_CLASS$_SKDescriptorMapper", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) "OBJC_CLASS$_SKIOSNetworkAdapter", referenced from: objc-class-ref in libReact-Core.a(RCTAppSetupUtils.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Please help me to solve this problem.
Posted
by
Post marked as solved
3 Replies
722 Views
Hi everyone, I'm studying Mergeable libraries. (in an iOS platform) In general, with the knowledge I knew (may not be accurate), Static Library cannot use resources except to add a separate resource bundle to the Main App Target, so I understand that the main app uses dynamic library. But In "Meet mergeable libraries Session", it was said that below "Up until iOS 12, the runtime needed the framework's binary to discover bundles, but mergeable frameworks won't have binaries in them by the time the process is running. Good news! In iOS 12, a hook was added to enable lookup for this scenario. That does mean if you rely on bundle lookup support, you should update your minimum deployment version to iOS 12 or later to use mergeable libraries." I don't know what 'hook' is mentioned below. I have a dynamic library that only handles the resources(images, colors - xcassets) and those assets compiled and become Assets.car file I set Build Mergeable Library to Yes in the build setting of this dynamic library, and I set Create Mergeable Binary to Automatic in the Main App (which relies on this library). When the app bundle includes the framework, of course the resource is loaded, but if I set the library to do not embedded in the project setting, I cannot read the resource. I wonder if the Merged Binary (Main App) has a library merged, and if I need to add a separate framework to the App Bundle simply because of resources. Thank you.
Posted
by
Post marked as solved
3 Replies
1.4k Views
Hi everyone! Using my Mac with macOS Ventura 13.5.1 and Xcode 15 beta 7, when I launch my application using a simulator with ios 17, the app crashes with 'DYLD 1 Library missing' error - Library not loaded: /System/Library/Frameworks/NewsstandKit.framework/NewsstandKit. I tried the same using a simulator with iOS 16, and it works ok, but I need to make tests with iOS 17. Anyone has experienced something like that or any suggestions in order to fix this? Thanks in advance for your time and help.
Posted
by
Post not yet marked as solved
1 Replies
498 Views
Hi, I have a mac with M1 pro. I installed libfido2 with homebrew. I took the static libarary - libfido2.a and added to a xcode project (simple app). In this project I am just trying to test the libfido2, to see if its working. When building I get : Undefined symbols for architecture arm64: "_BN_CTX_end", referenced from: _es256_pk_to_EVP_PKEY in libfido2.a(es256.c.o) _es256_pk_from_EC_KEY in libfido2.a(es256.c.o) any ideas why, and how to fix this? cheers
Posted
by
Post not yet marked as solved
1 Replies
862 Views
Recently we encountered an error after building our project. App crashed while opening. Any help? No online solution helped. Here is the log: Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: DYLD 1 Library missing Library not loaded: @rpath/libswiftCore.dylib Referenced from: &lt;8A390533-5381-32BC-8D7F-86ACA722025A&gt; /Volumes/VOLUME/*/VisionAi.app/VisionAi Reason: tried: '/private/var/containers/Bundle/Application/D9A0E845-0185-4FF4-953B-59F2EA6E4D44/VisionAi.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/D9A0E845-0185-4FF4-953B-59F2EA6E4D44/VisionAi.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/D9A0E845-0185-4FF4-953B-59F2EA6E4D44/VisionAi.app/Frameworks/libswiftCore.dylib' (no such file), '/private/var/containers/Bundle/Application/D9A0E845-0185-4FF4-953B-59F2EA6E4D44/VisionAi.app/Frameworks/libswiftCore.dylib' (no such file), '/usr/local/lib/libswiftCore.dylib' (no such file), '/usr/lib/libswiftCore.dylib' (no such file, not in dyld cache) (terminated at launch; ignore backtrace) ** Current Xcode version 14.3.1**
Posted
by
Post marked as Apple Recommended
5.4k Views
My app was working fine on XCode 14.6 and I was able to install it on my iPad. For testing the app on my iPad on iOS 17 Beta, I updated both my iPad and XCode 14.6 to XCode 15 Beta 8. Now when I am trying to install it, I get this error: duplicate symbol '_CRLF' in: /Users/mac-0077/Desktop/HBook/eBook/Nov_2023/ebookapp copy/eBook/Third Party/PrinterLibrary/libPrinter_170b.a[arm64][4](ZPLPrinter.o) /Users/mac-0077/Desktop/HBook/eBook/Nov_2023/ebookapp copy/eBook/Third Party/PrinterLibrary/libPrinter_170b.a[arm64][3](CPCLPrinter.o) ld: 1 duplicate symbols clang: error: linker command failed with exit code 1 (use -v to see invocation) If I am installing the app using XCode 14.6 on the simulator(iOS 16), it's working. If I am installing the app using XCode 15.0 beta 8 on the iPad(iOS 17 Beta), it's not working giving the above error. I have tried many things but nothing worked. Any help or guidance provided would be greatly appreciated. Thank you in advance for taking the time to assist me!
Posted
by
rv3
Post not yet marked as solved
0 Replies
1.5k Views
I often find myself helping folks with dynamic library problems. These problems manifest in many different ways, but they all have one common factor: The dynamic library has an atypical install name. Sometimes this was inherited from macOS’s deep past, but most often it’s because folks aren’t aware of the two well-trodden paths through this particular minefield. This post is my attempt to rectify that. If you have questions or comments about this, start a new thread here on DevForums. 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" Dynamic Library Identification Apple’s dynamic linker has a lot of flexibility. Much of this flexibility exists for historical reasons, and it’s better for modern programs to follow one of two well-trodden paths: Most dynamic libraries should use an rpath-relative install name, as explained in Dynamic Library Standard Setup for Apps. In some cases it might make sense to use a full path for your install name, per Dynamic Library Full Path Alternative. To understand these options, you need to know a little bit about how the dynamic linker works, which is the subject of this post. Note This post covers some of the same ground as Embedding nonstandard code structures in a bundle, but in a less official way (-: Install Name Every dynamic library has an install name. This name identifies the library to the dynamic linker. When you link to a dynamic library, the static linker records the library’s install name in your Mach-O image. When the dynamic linker loads your Mach-O image, it uses those recorded install names to find and load the libraries you depend on. Note There are many different aliases for the term install name, including id, identification name, or install path. To see a library’s install name, run otool and examine the LC_ID_DYLIB load command: % otool -l libWaffle.dylib | grep -A 2 LC_ID_DYLIB cmd LC_ID_DYLIB cmdsize 48 name @rpath/libWaffle.dylib … Note The Mach-O load commands and their associated structures are defined in <mach-o/loader.h>. For example LC_ID_DYLIB is associated with the dylib_command structure. To see the install names of the libraries imported by a Mach-O image, run otool and examine the LC_LOAD_DYLIB load commands: % otool -l libVarnish.dylib | grep -A 2 LC_LOAD_DYLIB cmd LC_LOAD_DYLIB cmdsize 48 name @rpath/libWaffle.dylib … -- cmd LC_LOAD_DYLIB cmdsize 56 name /usr/lib/libSystem.B.dylib … Alternatively, use the -L option: % otool -L libVarnish.dylib … @rpath/libVarnish.dylib … @rpath/libWaffle.dylib … /usr/lib/libSystem.B.dylib … This displays the library’s own install name first, followed by the install names of all the libraries it imports. If you’re building a dynamic library with Xcode, use the Dynamic Library Install Name build setting to set the install name. If you’re building from the command line, pass the -install_name option to ld. For more about this, see the ld man page. It’s best to set the install name at build time and not change it. However, if you’re working with an existing dynamic library that has the wrong install name, you can usually change it using install_name_tool. See the install_name_tool man page for details. Runtime Path List Way back in the day, a dynamic library’s install name was the full path of the installed library. That’s why it’s called the install name. However, full paths don’t work in some situations. For example, if you have a library embedded within an app, you can’t use an full path because the app might not be installed in the Applications folder. To address this problem Apple updated the dynamic linker to support a number of special install name prefixes. At runtime it replaces the prefix with an appropriate path. For example, @executable_path is replaced with the path to the directory containing the processes main executable. For a full list of these prefixes see the dyld man page. However, if you’re creating a dynamic library you’ll want to focus on the runtime path, @rpath, or just rpath for short. The exact details of how this works are complex, see the man page for the full story, but the basic gist is that: The dynamic linker maintains a list of rpath directories. When it loads a Mach-O image, the dynamic linker looks for LC_RPATH load commands in the image. For each one it finds, it adds a new directory to the rpath list. When a Mach-O image imports a library with an rpath-relative install name, the dynamic linker searches for that library in each directory in the list. This may sound a bit abstract, so you might want to hop on over to Dynamic Library Standard Setup for Apps for some examples of how this works in practice. If you’re building a Mach-O image with Xcode, use the Runpath Search Paths build setting to add rpath directories. If you’re building from the command line, pass the -rpath option to ld. For more about this, see the ld man page. It’s best to configure your rpath directories at build time. However, if you’re working with an existing Mach-O that has the wrong rpath directories, you can add, delete, and change them using install_name_tool. See the install_name_tool man page for details.
Posted
by
Post not yet marked as solved
0 Replies
925 Views
If you haven’t already read Dynamic Library Identification, read that before reading this. If you have questions or comments about this, start a new thread here on DevForums. 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" Dynamic Library Standard Setup for Apps When building a dynamic library, you must choose an install name. I recommend that you use an rpath-relative path for this, because that allows for a clean separation of concerns: You, as the library developer, don’t have to worry about where the library is going to be installed. Your library can use the same install name no matter where it ends up on disk. Someone using your library has the freedom to place it wherever they want, adding an LC_RPATH load command so that the dynamic linker can find the library at runtime. Newly created Xcode projects use this technique. This post walks you through an example of how such a project is set up, and how it works at runtime. App with Framework Example Imagine you’re building an iOS app with an embedded framework. In this case the app is called WaffleOMatic, and has the WaffleVarnish framework embedded within it. On creating this project with Xcode, using the standard iOS > App project template and the iOS > Framework target template, you’ll see the following: The framework’s Dynamic Library Install Name build setting is set to $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH). This resolves to @rpath/WaffleVarnish.framework/WaffleVarnish. The framework’s Runpath Search Paths build setting is set to $(inherited) @executable_path/Frameworks @loader_path/Frameworks. The $(inherited) value is empty, so this resolves to @executable_path/Frameworks @loader_path/Frameworks. The app’s Runpath Search Paths build setting is set to $(inherited) @executable_path/Frameworks. The $(inherited) value is empty, so this resolves to @executable_path/Frameworks. When you build this app these settings get reflected in its Mach-O images: % otool -l WaffleOMatic.app/Frameworks/WaffleVarnish.framework/WaffleVarnish | grep -A 2 LC_ID_DYLIB cmd LC_ID_DYLIB cmdsize 72 name @rpath/WaffleVarnish.framework/WaffleVarnish … % otool -l WaffleOMatic.app/Frameworks/WaffleVarnish.framework/WaffleVarnish | grep -A 2 LC_RPATH cmd LC_RPATH cmdsize 40 path @executable_path/Frameworks … -- cmd LC_RPATH cmdsize 40 path @loader_path/Frameworks … % otool -l WaffleOMatic.app/WaffleOMatic | grep -A 2 LC_RPATH cmd LC_RPATH cmdsize 40 path @executable_path/Frameworks … % otool -l WaffleOMatic.app/WaffleOMatic | grep -A 2 LC_LOAD_DYLIB cmd LC_LOAD_DYLIB cmdsize 72 name @rpath/WaffleVarnish.framework/WaffleVarnish … … Now let’s look at how the dynamic linker loads the app: It starts by loading the app’s main executable, WaffleOMatic.app/WaffleOMatic. This has an LC_RPATH load command for @executable_path/Frameworks, so it adds that directory to the rpath list. It then finds that the app has a LC_LOAD_DYLIB load command that imports @rpath/WaffleVarnish.framework/WaffleVarnish, so it attempts to find that library. This is an rpath-relative install name, so it looks in each directory in the rpath list. The first and only entry is @executable_path/Frameworks, so it looks for @executable_path/Frameworks/WaffleVarnish.framework/WaffleVarnish. It finds a dynamic library there. It looks at that library’s LC_ID_DYLIB value. That matches the library it’s looking for, and so it starts loading that library. Neat-o! Note The above bundle structure applies to iOS and its child platforms. macOS uses a different structure, and you have to adjust the paths accordingly. See Placing Content in a Bundle for details on the macOS layout. Swift System Libraries Modern systems have the Swift system libraries built-in. If your app supports older systems, Xcode embeds a copy of these libraries within your app. It uses rpath magic to ensure that your app uses the built-in system libraries if they’re available, falling back to the embedded ones if they’re not. To demonstrates how this works, change the deployment target for the WaffleOMatic app and the WaffleVarnish framework to iOS 12. Also add some trivial Swift code to the framework. The app now includes a copy of the Swift system libraries: % ls -l WaffleOMatic.app/Frameworks total 79032 drwxr-xr-x … WaffleVarnish.framework -rwxr-xr-x … libswiftCore.dylib … Each library has an rpath-relative install name: % otool -l WaffleOMatic.app/Frameworks/libswiftCore.dylib | grep -A 2 LC_ID_DYLIB cmd LC_ID_DYLIB cmdsize 52 name @rpath/libswiftCore.dylib … The app also has a new LC_RPATH load command for /usr/lib/swift: % otool -l WaffleOMatic.app/WaffleOMatic | grep -A 2 LC_RPATH cmd LC_RPATH cmdsize 32 path /usr/lib/swift … -- cmd LC_RPATH cmdsize 40 path @executable_path/Frameworks … The placement of this load command is critical. By placing it first in the list, the dynamic linker will use the built-in Swift system libraries in preference to the embedded ones. IMPORTANT Some developers encounter a crash whose backtrace like this: Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib … __pthread_kill … 1 libsystem_pthread.dylib … pthread_kill … 2 libsystem_c.dylib … abort … 3 libswiftCore.dylib … swift::fatalError… 4 libswiftCore.dylib … checkVersion() … 5 dyld … invocation function for block in dyld4::Loader::findAndRunAllInitializers… … This suggests that your app has a problem with its LC_RPATH load commands. Frames 4 and 3 shows that the Swift runtime has noticed a version disparity and trapped. Check the Runpath Search Paths build setting for each of your targets, making sure it matches the default value you get when you create a new target from the appropriate built-in template.
Posted
by
Post not yet marked as solved
0 Replies
349 Views
If you haven’t already read Dynamic Library Identification, read that before reading this. If you have questions or comments about this, start a new thread here on DevForums. 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" Dynamic Library Full Path Alternative In most cases it’s better to use an rpath-relative install name for your dynamic library. See Dynamic Library Standard Setup for Apps for an explanation as to why. There is, however, one well-supported alternative: a full path. IMPORTANT This technique is only viable on macOS. On iOS and its child platforms you must use an rpath-relative install name. Back in the early days of macOS, using a full path as the install name was super common. A third-party developer might install a framework in /Library/Frameworks with the express understanding that it would be used by other third-party apps. In recent years this technique has waned in popularity because of the hardened runtime. The hardened runtime enables library validation, meaning that your process can only load code signed by Apple or signed by your own team. That makes it hard for multiple developers to shared code in this way. While it’s possible to disable library validation, that reduces the security of your product [1] and can cause Gatekeeper problems [2]. Using a full path as the install name is still useful for developers who ship multiple apps with a lot of common code. However, there are factors that work against that as well, notably user expecting to be able to install an app by dragging it the Applications folder and, more importantly, uninstall it by dragging it to the Trash. [1] Starting with macOS 14 beta you can selective relax this restriction. See WWDC 2023 Session 10266 Protect your Mac app with environment constraints for the details. [2] See Resolving Gatekeeper Problems Caused by Dangling Load Command Paths. Adopting the Full Path Alternative Adopting this technique is super simple: Choose a full path for your dynamic library. Typically this will be within /Library/Frameworks but other directories, like a subdirectory within /Library/Application Support, also work just fine. Set the install name of your dynamic library to that path. When deploying, install your dynamic library at that path. When building, either link your app to your dynamic library or to a stub library that references that path. For more information about stub libraries, see An Apple Library Primer. This technique does have one notable drawback: It complicates your development process. It’s not very practical to install the library every time you rebuild it [1]. You can get around that using dynamic library environment variables, like DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH. For the details, see the dyld man page. However, be aware that these are disabled by default by the hardened runtime. [1] If you do go down that path, avoid the pitfall described in Updating Mac Software.
Posted
by
Post not yet marked as solved
0 Replies
640 Views
I am trying to install Python from source according to the readme using: ./configure make &lt;-- Error happens here make test sudo make altinstall However, I cannot complete the make command since it fails with: Undefined symbols for architecture arm64: "_libintl_bindtextdomain", referenced from: __locale_bindtextdomain in _localemodule.o "_libintl_dcgettext", referenced from: __locale_dcgettext in _localemodule.o "_libintl_dgettext", referenced from: __locale_dgettext in _localemodule.o "_libintl_gettext", referenced from: __locale_gettext in _localemodule.o "_libintl_setlocale", referenced from: __locale_setlocale in _localemodule.o __locale_localeconv in _localemodule.o "_libintl_textdomain", referenced from: __locale_textdomain in _localemodule.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Programs/_freeze_module] Error 1 Looks like make is somehow using the wrong architecture. I just don't know why. Does anyone have an idea?
Posted
by