UPDATE: please leave a comment when you have this working without problems on your system. That would confirm that this is a problem in my setup, rather than a bug in XCode.
After upgrading my development system to XCode 4.5.1, and compiling with IOS SDK 6.0, I get the following errors when running on the IOS 4.3 simulator:
dyld: lazy symbol binding failed: Symbol not found: _objc_release
Referenced from: /Users/baraupp/Library/Application Support/iPhone Simulator/4.3.2/Applications/AFD73AB4-7047-468B-A20B-9C941850ED3C/Flyskyhy.app/Flyskyhy
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation
dyld: Symbol not found: _objc_release
Referenced from: /Users/baraupp/Library/Application Support/iPhone Simulator/4.3.2/Applications/AFD73AB4-7047-468B-A20B-9C941850ED3C/Flyskyhy.app/Flyskyhy
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation
I have set the deployment target to 4.3, and I use ARC in the project, with some files on -fno-objc-arc. Compiling and linking succeeds without errors, it fails when trying to run on the simulator. It used to work fine before I upgraded.
EDIT:
I found a similar Stackoverflow question that asks almost exactly the same thing, and its answer suggests adding -fobjc-arc to the other linker flags. Unfortunately, that did not solve my problem. EDIT: I checked the flags that are actually used in the link phase, and the -fobjc-arc flag is present while linking, also without me adding -fobjc-arc explicitly.
As suggested by Brad in the comments, I added the library libarclite_iphoneos.a to the project, but that did not help either. I found that library in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc, which is a weird location in my view, but I could not find it anywhere else.
I also did 'nm' on that library, and it does not define the missing _objc_retain symbol either. It does define a _objc_retain$non_lazy_ptr, though, not sure what that means.
EDIT: I found out that the library gets ignored:
ld: warning: ignoring file libarclite_iphoneos.a, missing required architecture i386 in file libarclite_iphoneos.a
So obviously, it is not the correct file. But I cannot find the same file anywhere else on my system (I have searched with 'find').
Any ideas?
The problem was triggered by a +initialize method in a class category. Apparently, the Apple linker does not handle that case correctly.
After searching the web a lot, I saw that other people also have had issues with +load and +initialize methods, ARC and 4.3 compatibility.
In my case, I initialized a static variable in a category as such:
#implementation NSDictionary (FormAccess)
static NSRegularExpression *pattern;
+ (void) initialize
{
pattern = [[NSRegularExpression alloc] initWithPattern:#"(\\w+)|\\[([0-9]+)\\]" options:0 error:nil];
}
...
#end
The problem disappeared when I replaced that with an explicit initialization the first time the variable was used. I did not need to add any linker flags.
Note that if you have a non-ARC project that uses some ARC files, you still need to add the "-fobjc-arc" flag to "Other Linker Flags", to avoid the same error message.
Related
I'm trying to run an existing application to see how well it works with the latest Xcode beta and to try to use SwiftUI in an existing project. When I run the project on Simulator I get the following run-time crash:
dyld: Symbol not found: __ZTISt11logic_error
Referenced from: /Users/lucas/Library/Developer/CoreSimulator/Devices/224333CF-0388-4F57-9633-6CAB37B33510/data/Containers/Bundle/Application/<Guid>/<AppName>.app/<AppName>
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
in /Users/<name>/Library/Developer/CoreSimulator/Devices/224333CF-0388-4F57-9633-6CAB37B33510/data/Containers/Bundle/Application/<Guid>/<AppName>.app/<AppName>
Setting everything to iOS 13 made the error go away but that won't work in the near future. Also tried to remove anything related to Audio and AV frameworks but that didn't help.
Apparently same bug, but with different symbol:
dyld: Symbol not found: __ZTISt9bad_alloc
Referenced from: <bla-bla-bla>
Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.1.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
in <bla-bla-bla>
#Jeremy's answer worked for me. To help find it, the file is at
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox.tbd
and the lines you take out are:
weak-def-symbols: [ __ZTI11CAException, __ZTIN8DSPGraph9ExceptionE, __ZTINSt3__112bad_weak_ptrE,
__ZTINSt3__117bad_function_callE, __ZTISt11logic_error, __ZTISt12length_error,
__ZTISt12out_of_range, __ZTISt13runtime_error, __ZTISt16invalid_argument,
__ZTISt18bad_variant_access, __ZTISt8bad_cast, __ZTISt9bad_alloc,
__ZTISt9exception, __ZTS11CAException, __ZTSN8DSPGraph9ExceptionE,
__ZTSNSt3__112bad_weak_ptrE, __ZTSNSt3__117bad_function_callE,
__ZTSSt11logic_error, __ZTSSt12length_error, __ZTSSt12out_of_range,
__ZTSSt13runtime_error, __ZTSSt16invalid_argument, __ZTSSt18bad_variant_access,
__ZTSSt8bad_cast, __ZTSSt9bad_alloc, __ZTSSt9exception ]
This is a bug in the iOS 13 Beta SDK. You can hack around it by editing the AudioToolbox.tbd file within the SDK to remove the __ZTISt11logic_error (et al) symbols that shouldn't have been exported from there, or you can edit your link line to include -lc++ before -framework AudioToolbox (such that the static linker uses the correct references in libc++ rather than the once that were incorrectly referenced from AudioToolbox).
Or you can wait for a future beta with the fix ;)
I had crash with quite same error:
dyld: Symbol not found: __ZTISt11logic_error
Referenced from: <bla-bla-bla>
Expected in: /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
in <bla-bla-bla>
But I faced it when I was compiling own C++ project in Clion, so nothing linked with Simulator or iOs.
At that time I had XCode 10.2.1. I have tried multiple stuff to fix this crash, but nothing helped.
Luckily I found this post, so I downgraded my XCode to 10.1 and it's Command Line Tools. And it helped me!
So, even if my advice may not help with XCode 11 beta, I hope it can help other developers with the same error as you have.
This is an Xcode bug, but with a work-around. In your target's "Frameworks Libraries & Embedded Content" section, add libc++.tbd and make sure it's the at the top of the list. That should be all your need.
After upgrading to Xcode 7.1 and fixing some issues with my cocoapods (I had pods in both the main target and the test target), I now have the following warnings.
ld: warning: directory not found for option
'-F/Users/john/development/OurLatitude/OurLatitude/Pods/GoogleMaps/Frameworks”'
ld: warning: Auto-Linking supplied
'/Users/john/development/OurLatitude/OurLatitude/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/GoogleMaps',
framework linker option at
/Users/john/development/OurLatitude/OurLatitude/Pods/GoogleMaps/Frameworks/GoogleMaps.framework/GoogleMaps
is not a dylib
Originally I did only had the Auto-Linking
warning, but some how managed to pick up the directory not found warning
I have the following in my test target search path:
"$(PODS_ROOT)/GoogleMaps/Frameworks" $(inherited) $(PROJECT_DIR)/Pods/GoogleMaps/Frameworks”
If I delete this entry I get the following error:
ld: framework not found GoogleMaps for architecture i386
at one point I think this was complaining about armv7, I forget what I changed that affected that.
Including the path in my test target searchpath, is just a warning and everything , including the test seem to run, but I would like to get rid of the warning if possible.
Any ideas?
I tried what was suggested in this answer, but it only seemed to make matters worse.
I have a symbol that is being referenced in an Xcode dynamic library target, but it is not defined there. I NEED this symbol to be undefined. This is because it will be compiled differently in each process that includes it (based upon some compile time defines).
The dynamic library target in Xcode that fails to link because it contains a reference to this symbol (which is not unexpected), but I know that the symbol will be available at run time. I will be compiling this function into each target that the common library is linked to.
I am trying to get the linker to mark this particular symbol for dynamic lookup at run time.
I have been able to get it to link if I specify "-undefined dynamic_lookup" as one of the "Other Linker Flags" in my Xcode project. The problem is that I don't want to go that far. I know that only 1 symbol is supposed to be undefined. I want all the rest of the symbols to generate errors if they are left as undefined (I want to avoid a run time missing symbol error basically).
I found a ld linker option that seems like it should do what I need (from ld man page):
-U symbol_name
Specified that it is ok for symbol_name to have no definition. With -two_levelnamespace, the resulting symbol will be marked dynamic_lookup which means dyld will search all loaded images.
However, I cannot seem to get it to work. Whenever I specify "-U symbolName" or "-UsymbolName" in the "Other Linker Flags" I am still greeted with this linker error:
Undefined symbols for architecture x86_64:
"_symbolName", referenced from: <various object files>
Am I using -U incorrectly perhaps? Is it not really the option I need, or is it just not working like it is supposed too?
Set -Wl,-undefined,dynamic_lookup to OTHER_LDFLAGS.
Link: Xcode clang link: Build Dynamic Framework (or dylib) not embed dependencies
Setting -Wl,-undefined,dynamic_lookup is dangerous, since it disables all undefined warning.
Use -Wl,-U,symbol_namein OTHER_LDFLAGS to disable warnings for a single symbol.
In Xcode:
Go to Project/Select Target
Click Build Settings
Search Other Linker Flags
Enter options
I am encountering 'duplicate symbol' errors in Xcode 4.5.1 when I try to build a project after adding my own framework. I verified the framework files for duplicates and there are none. But when I add the framework to a project, it complains with these error. Please suggest..
duplicate symbol _NXArgc in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
/Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
duplicate symbol _NXArgv in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
/Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
duplicate symbol ___progname in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
/Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
duplicate symbol _environ in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
/Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
duplicate symbol start in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/crt1.3.1.o
/Users/idcc/Test/MyFW/Products/MyTestFW.framework/MyTestFW
ld: 8 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks in advance..
I had the same issue with using two third party framework. I resolved that by removing "all_load" from "Other Linker Flags" in build settings.
Those symbols are in crt.o, the startup code of standard C library. Normally it should be the entry point of executable file to initialize global variables and objects. It will also call your main function.
But for a framework, you should not include it in your binary because framework should not have main.
I believe you have "Link with Standard Library" option as "YES" in your framework's target build setting. This will link crt.o into your framework. And when you link the framework into a project, there will be duplicated symbols.
Please set the option "Link with Standard Library" to NO in your build setting.
Your application has provided an implementation in which there are 8 duplication symbols.
There are a number of ways you might have done this:
You have two modules declaring the same class. Perhaps one is no longer needed?
You are importing any header file in both the files .m and .h :-( Remove from one place.)
You are importing any .m file somewhere. :- (Import .h file instead of .m file)
You have defined and declared any const variable in outside(above) the #interface{} in any of .h file, it might being duplicated. :- (Do it in the .m file.)
Also check, if global variables like constants are defined correctly in .h file in application.
The correct way of defining global variable is to use extern variable in .h file.
Note :This is not an issue with the previous Xcode version. I faced the problem with Xcode 6.3 and it was solved.
If you have this problem only when you run the app in the simulator, it gets solved by deleting the local folder
~/Library/Developer/CoreSimulator
Xcode will restore it after the first build and run.
PLEASE MAKE SURE YOU BACKUP ANY SETTINGS before doing this (especially those related to simulator devices).
Tested on Xcode Version 7.2.1 (7C1002)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_AppDelegate_Shared", referenced from:
_OBJC_CLASS_$_AppDelegate_iPad in AppDelegate_iPad.o
"_OBJC_METACLASS_$_AppDelegate_Shared", referenced from:
_OBJC_METACLASS_$_AppDelegate_iPad in AppDelegate_iPad.o ld: symbol(s) not found for architecture i386 clang: error: linker command
failed with exit code 1 (use -v to see invocation)
Hello, this is a straight up AppDelegate, and I'm getting this error. Any ideas? There's no library to link to or anything. I've seen these errors time and time again in XCode, but the causes have ranged from a libxml2 library being not right (needed libxml2.7.3), to just something odd in XCode itself. No idea what to do next, but obviously would like the program to compile. Thanks!
same here. thanks for the answer.
I had just (literally 30 seconds ago) dragged the files in.
I used the same files in other projects no problem.
got this linker error (updated to XCode 4.3 yesterday)
and same problem, the .m file was checked for the Test target membership, but NOT the app target.
possibly a 4.3 bug. it seems it is defaulting to adding dragged in files to the test build and not the app build.
thanks... you helped me find it very fast. I was not looking forward to that.