问题
I get duplicate symbols error after I updated my Xcode
. (find the code down) Does anybody get this too? And how could be solved?
I tried to remove -ObjC
linker flag from the "Other Linker Flags" section, check after imported .m
instead of .h
, switch the "No Common Blocks" compiler setting to NO, I went to Targets -> Build Phases -> Compile
sources and no duplicates there, tried all with no results.
Any other ideas?
duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/FollowingUserViewController.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/ChatViewController.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/MessagesNotifications.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/AppDelegate.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/PicturesCell.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SMAPMainViewController.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/CheckUserTypeViewController.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SmaptersNearYou.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/PostSlider.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/UserSettings.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/EventSliderCell.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/UserProfile.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/EventCell.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/NewsFeed.o duplicate symbol _textViewMaxHeight in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/EventSliderCell.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/ExpressSliderCell.o duplicate symbol _textViewStandardHeight in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/EventSliderCell.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/ExpressSliderCell.o duplicate symbol _textViewStep in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/EventSliderCell.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/ExpressSliderCell.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/FollowerUserViewController.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/FilterAlertView.o duplicate symbol _space in: /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/SearchView.o /Users/a/Library/Developer/Xcode/DerivedData/SMAP-bshetjpaaresiudzvoubtutnfvuq/Build/Intermediates/SMAP.build/Debug-iphoneos/SMAP.build/Objects-normal/arm64/UserNotificationsViewController.o ld: 20 duplicate symbols for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
回答1:
Below Patch work for me..:)
Code recommended to use warning flags and set GCC_NO_COMMON_BLOCKS to YES.
Setting it back to NO solved the problem!
回答2:
I finally found it! You can compile after setting enable testability to NO in your Build settings.
From The Xcode 8 Release Notes:
When the Enable Testability build setting is enabled, Xcode 8 will pass -export_dynamic to the linker to preserve all global symbols for testing. This effectively overrides dead code stripping, which can expose link failures from unused functions that reference undefined symbols. If necessary, disabling testability will allow the link to proceed without source changes. (27684883)
Of course, the best thing to do is to either: a) remove the unused code that is causing the linker issues, or b) actually fix the linker issues.
回答3:
I understand most people are solving this by either the No Common Blocks or the Dead Code setting, but that is actually a workaround for the real issue. In my case, I was using a Pod file that was adding the same libraries I already had linked, so basically I removed the duplicate files in my Build Phases link libraries that were already compiled in my Pod file and the Archive feature worked.
回答4:
I found that I had constants declared in each 2 different classes, in .m file. This was allowed before this new version of xCode, but now appears like duplicate even those 2 classes don't import eachother and has nothing to do one with another.
const NSInteger space = 10; <-- the name "space" should be unique over the app, even it's in .m file
回答5:
for my case, Xcode 9 , we were declaring constants in some header file
Constants.h
static NSString *const kSomeString = @"SomeString";
so importing Constants.h in multiple .m files causes the duplicated symbols
Solution:
Constants.h
extern NSString * const kSomeString;
Constants.m
NSString *const kSomeString = @"SomeString";
回答6:
In your Xcode 9 project you will see left hand side 3 column search icon click that then search for: -Objc in the search bar and then you will see a pod config file open that. Now remove the -ObjC from the inherited it will solve the issue.
回答7:
I did not want to change any of these settings since no one really knows what other side effects these may have. So I iust globally searched for that variable name, replaced the name the caused the conflict in one class to variable_Classname.
That solved the issue for me without changing any setting
回答8:
From the error info, it must be some file dupicate in your project. Such as FilterAlertView, UserNotificationsViewController, SearchView, ExpressSliderCell...,And so on. You can see this in your error info.
回答9:
The solution is in this post. You're not up to date with this, but at least it solves the problem for now and at least in my scenario I don't have any problems with that version.
回答10:
These are the steps that I took to resolve this issue:
- Select the first duplicated compiled source … Search for something in the error message like: CDVWKWebViewEngine or EventSliderCell.o in your case;
- Select your project in XCODE (top left) then select Build Phases;
- In the filter text field enter the compile source that has been reported as duplicated (e.g. CDVWKWebViewEngine);
- You should receive at least 2 results for that source - one in cordova-plugin-ionic-… and another in cordova-plugin-wkwebview-...;
- Select the cordova-plugin-wkwebview-… one and click on the “-“ sign (bottom left);
- Now try to build again and do this for all the compile sources that are duplicated.
来源:https://stackoverflow.com/questions/39512823/duplicate-symbols-for-architecture-arm64-after-xcode-8-0-update