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

Posts under Linker tag

160 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Xcode 15 vs. iOS: xcodebuild build-for-testing fails with linker error
The error is: ld: building for 'iOS', but linking in dylib (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework/Versions/A/XCTest) built for 'zippered(macOS/Catalyst)' clang: error: linker command failed with exit code 1 (use -v to see invocation) And the command is following: xcodebuild -project "my_project.xcodeproj" -scheme "UITests" -destination generic/platform=iOS build-for-testing It's caused by updating Xcode to 15, it was working well under Xcode 14. The same UITests scheme is built and executed successfully from Xcode. And xcodebuild still builds successfully the app bundle: xcodebuild -project "my_project.xcodeproj" -scheme "App" -destination generic/platform=iOS archive -archivePath "build/app.xcarchive" I haven't found this problem so far in forums, so looking for help/suggestions.
0
0
717
Oct ’23
Duplicate Symbol Error when Linking in Xcode: '_CRLF' | XCode 15.0 Beta 8
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!
8
3
6.3k
Oct ’23
Undefined Symbols in Linking iOS App
Hi! Xcode 14.3 on MacOS 13.3.1 I'm developing in iOS app targeting iOS 14.0 and higher. I've included 4 cocoa pods in my project and my code has compiled and run just fine. When I started to try to build an archive to submit to the app store, things started falling apart. Now nothing compiles for simulators and test devices and I end up with linking errors with undefined symbols. I've tried clean builds, pod updating, pod installing, explicitly importing the modules in my swift code. I'm ready to pull my hair out. Undefined symbols for architecture arm64: "OBJC_CLASS$_SFGeometryUtils", referenced from: objc-class-ref in MGRS.o ld: symbol(s) not found for architecture arm64 Any suggestions? Randomly I can get past this road block and then I run into: cannot find type 'TIFFImage' in scope var tiffImage: TIFFImage! Then randomly back to unresolved symbols by linker. Thanks, Bobby
6
0
12k
Oct ’23
Invalid bundle structure when submit to AppStore Connect as Frameworks contain .a file
XCode Version: 15.0 (15A240d) macOS version: 13.6 (22G120) I have an OpenSSL.xcframeworks (headers and .a included for different platforms e.g. iOS, iOS simulator on arm64/x86) included in my xcode project folder: Frameworks. It run without issues on iPhone device or iPhone simulator, however, when submit to AppStore Connect, it fail with Upload failed with errors: "Invalid bundle structure, ???.a file is in Frameworks directory, but the Swift runtime libraries are the only files permitted in that directory" How to solve the issue ?
4
0
1.1k
Oct ’23
Xcode 15 beta 3 linker issue: ld: warning: duplicate -rpath
Hello, In Xcode 15 beta 3, if a project embedded a Swift package (no matter static or dynamic), and the package has its own dependencies, the linker will always emit following warning: ld: warning: duplicate -rpath '/Users/.../Library/Developer/Xcode/DerivedData/MyApp.../Build/Products/Debug-iphonesimulator/PackageFrameworks' ignored The warning is not appeared on beta 2 and beta 1. Reproduce Steps [1] Create a new iOS project in Xcode 15 beta 3 [2] Create a new Swift package MyLibrary, and add any dependency in the Package.swift. Example: // swift-tools-version: 5.9 import PackageDescription let package = Package( name: "MyLibrary", platforms: [.iOS(.v16)], products: [ .library(name: "MyLibrary", targets: ["MyLibrary"]), ], dependencies: [ // 👀 Add any dependency to this package. // Here I use "Version" which is a simple pure swift package: .package(url: "https://github.com/mxcl/Version.git", .upToNextMajor(from: "2.0.0")), ], targets: [ .target(name: "MyLibrary", dependencies: ["Version",]), ] ) [3] In the project page, embed MyLibrary into the iOS app target. [4] Build the project. It will succeed but with link warnings. In addition, if you create a dynamic framework and embed MyLibrary, the warnings also reproduce. And this is only a simple case. In my real project, the linker will also emit a lot of warnings like this: ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$__TtP10SPConfetti18SPConfettiDelegate_ ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$__TtP10SPConfetti18SPConfettiDelegate_ ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDelegate ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionTaskDelegate ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDataDelegate ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDownloadDelegate ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSObject ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDelegate ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionTaskDelegate ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDataDelegate ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDownloadDelegate ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSObject
21
14
9.9k
Oct ’23
Symbol not found: _OBJC_CLASS_$_NSError
I launch the macOS app from Xcode after recently updating to Sonoma and now I get this. I would think that Foundation is automatically included. I took the extra step to add Foundation and Cocoa to the Frameworks and Libraries with the Do Not Embed option and it didn't fix it. I also tried Embed Wthout Signing, which didn't work either. Any suggestions?
1
0
454
Oct ’23
My libSystem.B.dylib is missing from my mac
When I try to run a simple executable from Cmake, I get this error. dyld[5005]: dyld cache '(null)' not loaded: syscall to map cache into shared region failed dyld[5005]: Library not loaded: /usr/lib/libSystem.B.dylib Referenced from: <7EB1C677-BB05-338C-8B29-CC2803CB8C21> /Users/pop/Desktop/Lang Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/libSystem.B.dylib' (no such file), '/usr/lib/libSystem.B.dylib' (no such file, no dyld cache), '/usr/local/lib/libSystem.B.dylib' (no such file) I have tried looking for my file sudo find / -name libSystem.B.dylib but not luck. I am using an M1 chip and Ventura 13.1. Please ask for more details if you need them, as I really have no idea what to do about my problem.
11
2
4.5k
Oct ’23
problem with dlopen() in swift xcode
so i am having a problem reading python library file using dlopen. when i use the method in terminal (running swift) it returns te library handle successfully . however when i use the same method without any changes in xcode it returns the handle as nil (i suppose this is some file access problem). now , i have seen some tutorials that recommend deleting app sandbox and editing something in herdened runtime (both should be found in the capabilities and signing section), but i cat find them in my capabilities section in the targets, idk if this is because i have the latest xcode version and that there has been made some changes or what but i cant find them. so all i want to do is run the dlopen command inside xcode if anyone can help i would be so thankful.
1
0
451
Oct ’23
Command Line Tools Linker does not work for linking assembly and C code
On Ventura 13.5.2 (22G91), Macbook pro 13 2019 (Intel): The following combination of the C code and Assembly code fails to link conftest_c.c: //conftest_c.c: #ifdef __cplusplus extern "C" { #endif void gsym_test_func(void); #ifdef __cplusplus } #endif int main() { gsym_test_func(); return 0; } Obj compiled using the command clang -O3 -DNDEBUG -finline-functions -fno-strict-aliasing -mcx16 -I. conftest_c.c -c produces conftest_c.o That exposes the following symbols: SYMBOL TABLE: 0000000000000000 g F __TEXT,__text _main 0000000000000000 *UND* _gsym_test_func Now we create assembly conftest.s that define _gsym_test_func: .text # _gsym_test_func .globl _gsym_test_func _gsym_test_func: # _gsym_test_func with the objdumb symbols: SYMBOL TABLE: 0000000000000000 g F __TEXT,__text _gsym_test_func Trying to link the two object files into a binary using the following command clang -O3 -DNDEBUG -v -finline-functions -fno-strict-aliasing -mcx16 conftest_c.o conftest.o -o conftest -lz results in the following error: Apple clang version 15.0.0 (clang-1500.0.40.1) Target: x86_64-apple-darwin22.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -platform_version macos 13.0.0 14.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -O3 -o conftest -L/usr/local/lib conftest_c.o conftest.o -lz -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a ld: Undefined symbols: _gsym_test_func, referenced from: _main in conftest_c.o clang: error: linker command failed with exit code 1 (use -v to see invocation) I do not understand why the linker cannot find the symbol _gsym_test_func defined in conftest.o
5
1
952
Sep ’23
"dyld Symbol not found" only on device
Hello, My Swift / iOS app runs fine on simulator, but fails at linking step when running on physical device with the following error (if relevant, on a M1 Mac) : dyld[10576]: Symbol not found: __ZN5swift34swift50override_conformsToProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEPFPKNS_18TargetWitnessTableIS1_EES4_S8_E Referenced from: &lt;2798FCFA-E27D-34FA-838C-833DABBFC7DC&gt; /private/var/containers/Bundle/Application/***/yyy.app/Frameworks/LyraPaymentSDK.framework/LyraPaymentSDK Expected in: &lt;D4CE9EDB-D775-353D-9E8A-1BDB67F0C849&gt; /private/var/containers/Bundle/Application/***/yyy.app/Frameworks/sentry_client_cocoa.framework/sentry_client_cocoa I guess the problem is related to the LyraPaymentSDK dependencies : i use carthage to grab and build these deps using the following cartfile : github "CosmicMind/Motion" == 3.1.3 github "CosmicMind/Material" == 3.1.8 github "SnapKit/SnapKit" == 5.6.0 binary "https://raw.githubusercontent.com/lyra/ios-sdk/2.6.3/LyraPaymentSDK.json" == 2.6.3 binary "https://raw.githubusercontent.com/lyra/sentry-client-cocoa/4.0.0/sentry_client_cocoa.json" == 4.0.0 github "getsentry/sentry-cocoa" == 8.5.0 The carthage build is done with the following command : sh carthage.sh update --platform ios --use-xcframeworks --no-use-binaries and the carthage.sh script has the following content : #!/usr/bin/env bash # carthage.sh # Usage example: ./carthage.sh build --platform iOS set -euo pipefail xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX) trap 'rm -f "$xcconfig"' INT TERM HUP EXIT # For Xcode 14 make sure EXCLUDED_ARCHS is set to arm architectures otherwise # the build will fail on lipo due to duplicate architectures. CURRENT_XCODE_VERSION=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3) echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1400__BUILD_$CURRENT_XCODE_VERSION = arm64 arm64e armv7 armv7s armv6 armv8" &gt;&gt; $xcconfig echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1400 = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1400__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' &gt;&gt; $xcconfig echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' &gt;&gt; $xcconfig ## optional echo 'IPHONEOS_DEPLOYMENT_TARGET = 11.0' &gt;&gt; $xcconfig echo "ENABLE_BITCODE=NO" &gt;&gt; $xcconfig export XCODE_XCCONFIG_FILE="$xcconfig" carthage "$@" The 6 deps are builded successfully, and the xcframeworks are imported in my XCode project, with the "embeded &amp; sign". Any help would be highly appreciated, i've been struggling with this issue for more than a week without any improvement. Thanks
0
0
611
Sep ’23
Xcode 15.0 linker error (Assertion failed: (rebasePtr->target == low56), function writeChainEntry, file ChainedFixups.cpp, line 1218)
Hi! On the latest version of Xcode (15.0 released on Sept 18th, 23) we are running into a linker failure when we try to archive. The same project builds fine on Xcode 14.3.1. It also builds fine when building a debug build to device. This is the stack from the build output 0 0x1021ab648 __assert_rtn + 72 1 0x102106998 mach_o::PointerFormat_DYLD_CHAINED_PTR_64_OFFSET::unauthRebaseIsVmAddr() const + 0 2 0x102107b44 ___ZN6mach_o13ChainedFixups11buildFixupsENSt3__14spanIKNS_5Fixup10BindTargetELm18446744073709551615EEENS2_IKNS0_17SegmentFixupsInfoELm18446744073709551615EEEyRKNS0_13PointerFormatEjb_block_invoke_2 + 212 3 0x18163c440 _dispatch_client_callout2 + 20 4 0x18164ff1c _dispatch_apply_invoke + 224 5 0x18163c400 _dispatch_client_callout + 20 6 0x18164dfb8 _dispatch_root_queue_drain + 684 7 0x18164e6c0 _dispatch_worker_thread2 + 164 8 0x1817e8038 _pthread_wqthread + 228 ld: Assertion failed: (rebasePtr->target == low56), function writeChainEntry, file ChainedFixups.cpp, line 1218. clang: error: linker command failed with exit code 1 (use -v to see invocation) Any ideas on what we might be doing wrong? Is our best bet to disable the new linker and just keep checking with each new version?
1
1
738
Sep ’23
Failed build: ld assertions being hit with Xcode 15
ld: Assertion failed: (false && "not a GOT atom in non lazy pointers section"), function symbolIndexOfNonLazyAtom, file Layout.cpp, line 4930. When trying to build our project using Xcode 15 RC (15A240d) we are tripping an assertion in the linker step while the build system is running the following command: "/Applications/Xcode 15 RC.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library "/Applications/Xcode 15 RC.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib" -dynamic -dylib -dylib_compatibility_version 1.0.0 -dylib_current_version 1.0.0 -arch arm64 -dylib_install_name @rpath/MyFramework.framework/MyFramework -dead_strip -platform_version ios 12.0.0 17.0 -syslibroot "/Applications/Xcode 15 RC.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk" -O3 -e xport_dynamic -o ${ROOT_PATH}/sdk/iOS/ACSCallingSDK/release-iphoneos/MyFramework.framework/MyFramework -L${ROOT_PATH}/build/EagerLinkingTBDs/release-iphoneos -L${ROOT_PATH}/sdk/iOS/ACSCallingSDK/release-iphoneos -L${ROOT_PATH}/libShared/output/archive/arm64-v8a/release/release-iphoneos -L${ROOT_PATH}/libShared/output/archive/arm64-v8a/release "-L/Applications/Xcode 15 RC.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos" -L/usr/lib/swift -reproducible -filelist ${ROOT_PATH}/build/MyFramework.build/release-iphoneos/Objects-normal/arm64/MyFramework.LinkFileList -rpath /usr/lib/swift -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks -object_path_lto ${ROOT_PATH}/build/MyFramework.build/release-iphoneos/Objects-normal/arm64/MyFramework_lto.o -export_dynamic -add_ast_path ${ROOT_PATH}/build/MyFramework.build/release-iphoneos/Objects-normal/arm64/MyFramework.swiftmodule -lACSCallingSharedLibOutput -lc++ -lz -lobjc -e xport_dynamic -framework MyDependencyCommon -framework CoreTelephony -framework ExternalAccessory -framework SystemConfiguration -framework CoreML -framework CoreServices -weak_framework Vision -framework Accelerate -dependency_info ${ROOT_PATH}/build/MyFramework.build/release-iphoneos/Objects-normal/arm64/MyFramework_dependency_info.dat -framework Foundation -lobjc -lc++ -lSystem "/Applications/Xcode 15 RC.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.ios.a" -F${ROOT_PATH}/build/EagerLinkingTBDs/release-iphoneos -F${ROOT_PATH}/sdk/iOS/ACSCallingSDK/release-iphoneos -F${OUT_PATH}/SpoolCallingStack/Tools_MyDependencyCommon/1c/c6ed5b/8b904fdbe52392e7b02188b0 Stack trace of assertion: 0 0x100edf648 __assert_rtn + 72 1 0x100e90d94 ld::atomNeedsRegularBind(ld::Atom const*, ld::Options const&) + 0 2 0x100e90f38 void dispatchForEach<ld::SectionLayout*, ld::IndirectSymbolTableBuilder::IndirectSymbolTableBuilder(ld::Options const&, ld::LinkedAtomPlacement const&, std::__1::span<ld::SegmentLayout, 18446744073709551615ul>)::$_24>(std::__1::span<ld::SectionLayout*, 18446744073709551615ul>, unsigned long, ld::IndirectSymbolTableBuilder::IndirectSymbolTableBuilder(ld::Options const&, ld::LinkedAtomPlacement const&, std::__1::span<ld::SegmentLayout, 18446744073709551615ul>)::$_24)::'lambda'(unsigned long)::operator()(unsigned long) const + 216 3 0x1aa4c8440 _dispatch_client_callout2 + 20 4 0x1aa4dd544 _dispatch_apply_invoke_and_wait + 224 5 0x1aa4dc84c _dispatch_apply_with_attr_f + 1180 6 0x1aa4dca38 dispatch_apply + 96 7 0x100e9e500 ld::LayoutExecutable::writeToFile(char const*) + 8304 8 0x100e522e8 main + 9424 ld: Assertion failed: (false && "not a GOT atom in non lazy pointers section"), function symbolIndexOfNonLazyAtom, file Layout.cpp, line 4930. clang: error: linker command failed with exit code 1 (use -v to see invocation)
2
0
570
Sep ’23
Getting "Namespace DYLD, Code 1 Library missing" crashes on Ventura
Hello, My app runs fine on Monterey, but on Ventura we get a crash upon launch with the following Termination Reason: Termination Reason: Namespace DYLD, Code 1 Library missing Library not loaded: @rpath/libmylibrary-sdk.dylib Referenced from: <B2C025A7-2A52-3D29-93CF-EB0AE93077AA> /Applications/MyApp.app/Contents/MacOS/MyApp Reason: tried: '/usr/lib/swift/libmylibrary-sdk.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libmylibrary-sdk.dylib' (no such file), '/usr/lib/swift/libmylibrary-sdk.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libmylibrary-sdk.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libmylibrary-sdk.dylib' (no such file), '/usr/lib/swift/libmylibrary-sdk.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libmylibrary-sdk.dylib' (no such file), '/usr/lib/swift/libmylibrary-sdk.dylib' (no such file, not in dyld cache), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/swift/libmylibrary-sdk.dylib' (no such file), '/usr/lib/libmylibrary-sdk.dylib' (no such file, not in dyld cache) (terminated at launch; ignore backtrace) My app depends on mylibrary-sdk.dylib, which I've included in the target using SPM. Again, this setup runs produces an app that runs fine on Monterey. This is very odd, because it seems to be looking for mylibrary-sdk.dylib in /usr/lib/swift/ and /usr/lib/libmylibrary-sdk.dylib ?! If I look at the binary, the dylib is indeed in its Frameworks directory. I've also added @executable_path/../Frameworks to my Runpath Search Paths but that didn't help.
5
1
6.5k
Sep ’23
Xcode 15 - 'DYLD 1 Library missing' error when running simulator with iOS 17 beta
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.
3
0
1.5k
Sep ’23
missing libSystem.B.dylib
I just transitioned to an M2 silicon and compiled some of my previous programs. However, I am running into some execution problems when my code is not able to find the libSystem.B.dylib. I am runing Apple M2 Max, OS 13.5.2 (22G91) I installed XCODE and command line utilities as normal and installed gcc/gfortran using homebrew. The resulting fault text is below dyld[13777]: dyld cache '(null)' not loaded: syscall to map cache into shared region failed dyld[13777]: Library not loaded: /usr/lib/libSystem.B.dylib Referenced from: /Users/gamalakabani/Applications/TALYS_CODE/talys/bin/talys Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/lib/libSystem.B.dylib' (no such file), '/usr/lib/libSystem.B.dylib' (no such file, no dyld cache), '/usr/local/lib/libSystem.B.dylib' (no such file) ./verify: line 12: 13777 Abort trap: 6 $talys &lt; talys.inp &gt; talys.out Is this an issue with homebrew gcc? Any help will be appreciated. Thanks
5
0
1k
Sep ’23
Local Network Privacy FAQ-17
This post is part of the Local Network Privacy FAQ. Why does local network privacy get confused when I install two variants of my app? Local network privacy relies on NECP, a subsystem on Apple platforms that controls which programs have access to which network interfaces. For a brief introduction to this, see A Peek Behind the NECP Curtain. Internally, NECP uses a program’s main executable Mach-O UUID (LC_UUID) to track the identity of that program. If you have two programs with the same UUID, NECP might get confused (r. 30421029). This most commonly happens when you have two variants of the same app that you build from the same source code. For example, you might have a Pro and a Lite version of your app that use the same code. Or you might a core app implementation that you ‘skin’ for different customers by changing just the resources. If you encounter weird local network privacy interactions between two apps, check their LC_UUID values. To do this, run dwarfdump against the app’s main executable. For example: % dwarfdump --uuid Test725715-A.app/Test725715-A UUID: 2406B68D-B76A-3D70-8264-16F4A8E07DC0 (arm64) Test725715-A.app/Test725715-A % dwarfdump --uuid Test725715-B.app/Test725715-B UUID: D4D74EA8-FC68-3925-92AB-7B279DA095F9 (arm64) Test725715-B.app/Test725715-B Note While macOS doesn’t support local network privacy, duplicate UUIDs can cause weird problems with other NECP-based systems. macOS apps have a slightly different bundle structure, so insert Contents/MacOS/ in the path you pass to dwarfdump. For example, if you have a macOS app called Test725715-A, use the path Test725715-A.app/Contents/MacOS/Test725715. In this example the UUIDs are different, which is what you’d expect. If you see the same UUID for both apps, take steps to fix that. If you’re using Xcode, the easiest way to ensure that you have different UUIDs is to build your app from different source code. Here’s one approach that works: Create two source files, Unique-A.m and Unique-B.m. Add each file to its corresponding target. In each file define a string constant with the same name and a different value. For example, Unique-A.m might have: const char * gUnique = "Hello from app A!"; while Unique-B.m has: const char * gUnique = "Hello from app B!"; In your main function, add code to print that value: extern char * gUnique int main(…) { … printf("%s\n", gUnique); … } IMPORTANT Printing gUnique ensures that it’s not dead stripped. Now rebuild your apps and run the dwarfdump test again to confirm that each variant has a different UUID. Note This example is in Objective-C because this issue is less common with Swift code. That’s because in Swift the app’s name becomes the module name. This is reflected in the Swift runtime metadata, which is linked into the app, causing each app to have a different UUID. If you’re building your app with third-party tooling, consult the tool’s vendor as to how best to resolve this issue with their tools. Back to the FAQ
0
0
466
Sep ’23
Linking dylibs to an executable
I have an executable with the following dependencies: GaribenkaMac: @rpath/libwx_osx_cocoau_richtext-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_osx_cocoau_xrc-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_osx_cocoau_html-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_osx_cocoau_qa-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_osx_cocoau_core-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_baseu_xml-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_baseu_net-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) @rpath/libwx_baseu-3.2.0.dylib (compatibility version 0.0.0, current version 0.2.1) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1575.17.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1) I've copied these dylib files into the Contents/MacOS/ folder of the bundle and used commands like this one to link them: $ install_name_tool -change /Users/username/Desktop/wxWidgets.nosync/Library/wxWidgets-3.2.2.1/macbuild/lib/libwx_osx_cocoau_qa-3.2.0.dylib /Users/username/Desktop/Garibenka.nosync/Garibenka.app/Contents/MacOS/libwx_osx_cocoau_qa-3.2.0.dylib /Users/username/Desktop/Garibenka.nosync/Garibenka.app/Contents/MacOS/GaribenkaMac But this seems to have no effect. The app still throws "Library not loaded" error. I have no idea, what I should do, and the documentation didn't really help (I'm very new to Mac, and this all is quite confusing to me). What should I do to fix this?
1
0
587
Sep ’23
Manually linking app
Hi, I'm getting a linker error: /usr/bin/c++ -o app -g -O0 -Wall -Wpointer-arith -L/opt/local/lib osx.o -lpthread Undefined symbols for architecture x86_64: "_CFRunLoopAddSource", referenced from: osx.o "_CFRunLoopGetCurrent", referenced from: osx.o "_CFRunLoopRemoveSource", referenced from: osx.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [madchat] Error 1 I can't find where in the documentation the name of the library I must include in the linker command. Is there a reference somewhere that details WHICH .lib or .a file a function comes from? Thank you
3
0
532
Sep ’23