简体   繁体   中英

Linker command failed with exit code 1 error in Xcode project

I was working on my project and suddenly after editing the code and compiling gave this error:

ld: warning: directory not found for option '-
L/Users/mani/Documents/Classes/Twitter+OAuth/Libraries & Headers' ld: duplicate symbol _OBJC_CLASS_$_playSiew in /Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/playSiew.o and /Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/Thumb.o for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I never touched the project settings, just edited the code.

What's more strange is that I took out last revised code from svn but still I got the the same error.

You may be accidentally #import 'ing a .m file instead of a .h. Use Cmd+Shift+F and search for ".m" (without quotes). It will most likely lie in one of the classes mentioned in the warning. If not, clean and run again.

I was also having same issue and I did following and issue is gone.

Go to Product -> Clean and re-run the project.

I hope it might be useful for some other developers.

几分钟前遇到这个问题(是的,我知道自原始主题开始已有7个月)我发现问题的根源是由于我在XCode中将文件拖放到我的项目中而不是右键单击选择添加文件到项目。

Check playSiew.m is in Compile Sources section. isn't it?

You can find Compile Sources section follow this step

  1. Select YourProjectName
  2. Select TARGETS
  3. Select Build Phases

If don't have playSiew.m in this section . You must to add it to this section.

As I said the problem wasn't the code but some settings. So what I did was copying the code from my friends' Mac (it was working fine), and installed a fresh copy of the project to my Mac. It worked.

我在一个测试用例中导入了一个 ,我在我的pod文件中指定了主要目标但不是测试目标

I also got this error because I had accidentally included two versions of the same source file. Deleted the wrong one and the problem went away...

If you're working in Unity and export to iOS and you are using a plugin, go to Xcode Build Settings and set ENABLE BITCODE = NO. I'm guessing this might apply to other situations as well

Faced similar issue, while running the code on a simulator, tried all the above mentioned options, still got the same error. Tried connecting the iOS device and build the code, it worked for us. This can be a quick workaround.

the same error i faced. so, i just removed reference of that classes which are generating the errors and than again gave reference and the error was gone...

as D80Buckeye says there should be problem of dragging and dropping files instead of Clicking on "Add Files"

如果这对其他任何人都有用 - 我只是遇到了同样的错误,原因是在我的头文件中而不是在主文件中初始化变量。

I just encountered the same error. If you are using embedded Libraries, make sure your Deployment Target is set to iOS 8.0 or higher.

你只需要添加以下框架:quartzcore.framework

The only way we can get past this bug on our project is to do a Clean and then build for iPad Retina. After that it will build successfully for any device. Weird.

In my case i have add reference of FacebookLoginSDK framework but forget to give search path in build setting. After removing its reference everything was fine.

So conclusion is if you are adding any external framework be careful.

If this happens to you with CoreData generated classes, combine the +CoreDataProperties and +CoreDataClass into the +CoreDataProperties class and delete the +CoreDataClass. Make sure to search Derived Data for leftovers of the +CoreDataClass. Even after deleting the Derived Data and cleaning I sometimes had Xcode just generate the +CoreDataClass again and again. Deleting it manually in Finder and then re-bulding helped me solve this.

try this, go to Target -> Build Settings,then search these three as following,

GCC_NO_COMMON_BLOCKS,

CLANG_WARN_INFINITE_RECURSION,

CLANG_WARN_SUSPICIOUS_MOVE,

set NO to each value then clean and build.

I tried several of the answers listed but none worked for me. I got the error after updating XCode (while it was still open which may have contributed to the problem)

First , I deleted my Derived Data folder: XCode => Preferences => Locations => Double Click on arrow next to path indicating where the Derived Data folder is. Then "Move to Trash" I don't think that's what the problem was, but it's amazing how many times this has been an issue for me working on different problems.

Second , I 'Quit' the simulator.

Third , I 'Quit' XCode.

Fourth , I opened up my project in XCode again and then did a Clean and Build (found in the Product menu)

Fifth , I ran my project and it worked fine

Cleaning the project not works for me. Restart the Xcode works for me...

For me it was different. I had the same error when I removed a Pod and solved it by removing this pod from the Other Linker Flags in the Build Settings

在此输入图像描述

then clean your project [Product > Clean] and rebuild

Go to general and linked frameworks and libraries in xcode and remove all the files there.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM