Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library from pods not found #4248

Closed
dumoko opened this issue Sep 23, 2015 · 37 comments
Closed

Library from pods not found #4248

dumoko opened this issue Sep 23, 2015 · 37 comments

Comments

@dumoko
Copy link

dumoko commented Sep 23, 2015

Hi guys!
First of all thank for the great work you are doing, it's really huge for the whole community, we really appreciate that :)

Now regarding to the issue...
It's been reproducing since December 2014, so the version of Xcode and pod themselves varied through time, so the version of Xcode and pods doesn't really matter.
I tried to raise an issue last time, here, but since I wasn't able to give a sample project that reproduces the issue, I didn't get the solution I tried to ask for.
But today I am able to provide you a sample project, so you can see what I meant back then.

Actual problem
After the project was cloned, or after some changes in pods were made (whether new pods added or old ones updated), each time it was saying there is a compile time error, smth like

ld: library not found for -lAFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)

And it wasn't AFNetworking fault, if it was removed, then any other would scream about the same.

The pseudo-solution
I didn't find in the internet that somebody would have the same problem. So I found the solution myself:

  1. Select Pods project in the workspace
  2. Select Pods project again in the middle-window
  3. Go to Build Settings
  4. In Build Active Architecture Only (which has YES for Debug), select NO
  5. Build again, everything works.
    Every time doing so is very frustrating.

Reproducing steps with the sample project
I was not able to reproduce the bug by creating a new project.
So I took our project, that was using around 30 pods, 6 configurations, 6 storyboards, 1 target, and around 30 LOCs, and deleted everything unrelated to the pod issue, also renaming the targets and the project itself.
The main point about it - is that it still has the problem. If anybody would clone it, run pod install and build it, it will show the compile error.

You can find the almost-empty project here:
https://github.com/OlegAnghelov/Chain

Please, take a look on it, try to clone and build it yourself, and help us get rid of this annoying problem... If you need any additional information, just let me know, I will get everything you need :)

Thanks a lot in advance!

@alaaghribi
Copy link

I have exactly the same problem as yours (Xcode7), but even when I set Build Active Architecture Only to NO I always have something like ld: library not found for -lPods-REFrostedViewController. And it's not related to REFrostedViewController, because for example if I remove it from Other Linker Flags, I have that error with the just next library.

@dumoko
Copy link
Author

dumoko commented Sep 23, 2015

Btw, another point I would like to mention.
When the project is meeting the prerequisites for a failing try, it starts compiling the files from the main project.
Seems that switching the flag acts as a trigger to recompile the pods project, which is really curious.
But it might be irrelevant.

@alaaghribi don't switch the flags per pod target. Switch the flag per whole Pod project.

@alaaghribi
Copy link

Yes, I'm doing it like the way you mentioned, but I always have a failure !
screen_shot_2015-09-23_at_7_09_23_pm

@neonichu
Copy link
Member

@OlegAnghelov hm, this works just fine with me with Xcode 6.4 once I clear the non-standard ONLY_ACTIVE_ARCH setting.

Basically, both your project and the Pods project need to have the same setting for this, otherwise some architectures will be missing. If you want a custom setting in your project, you'll have to change it as well in Pods project.

@dumoko
Copy link
Author

dumoko commented Sep 23, 2015

@neonichu
Please be more specific.
Where did you change the "non-standard ONLY_ACTIVE_ARCH" setting? In the Chain target or Pods-project?
If you set it in the Chain target - it's against the best practices. And it's just a workaround, it's not the root of the problem. Other proejcts work fine.
I need to get to the root of the problem, not just found a hacky way to ignore the compile error.

@neonichu
Copy link
Member

It's not a "hacky way" to use Xcode defaults.

As I said above, this cannot work if you use different settings for both projects involved — if you want to use a non-standard setting in your project, you have to change the Pods project's setting as well. If you want to avoid doing it manually, you can use a post-install hook.

@dumoko
Copy link
Author

dumoko commented Sep 23, 2015

Then why all other projects work fine without these "not hacky way"? What makes my project so special that it doesn't compille without changing this settings?

@neonichu
Copy link
Member

You have changed the setting in your project.

@dumoko
Copy link
Author

dumoko commented Sep 23, 2015

I just created a new project, and the debug is set to yes by default.
And if I add the pods to this new project, it will work perfectly fine.

Another problem is that your solution just doesn't work.
I went to Chain Project -> build settings -> set value to "no".
Commited and pushed the changes.
Cloned the project, installed pods, and despite that it's a "no" in the Chain Project, the same problem persists. So, lets try smth else.

Hey, sorry if I sound harsh, I really don't mean so, cause I really appreciate your time that you spend right now digging into someone's else problems.
But I really try understand why this project is so special, why any other project works just fine.
Mb there is a sense to take a closer look, a deeper look?

@dumoko
Copy link
Author

dumoko commented Sep 23, 2015

As you can see there is also a warning in the project:
Pods-Chain was rejected as an implicit dependency for 'libPods-Chain.a' because its architectures 'x86_64' didn't contain all required architectures 'i386 x86_64'

so maybe these can give a hint?
#2053
#4171

@segiddins
Copy link
Member

@OlegAnghelov as @neonichu has said, the issue is coming from you changing the build setting. If you really wish to change that build setting, you'll also need to use a post-install hook in your podfile to mirror that change in the pods project.

@dumoko
Copy link
Author

dumoko commented Sep 24, 2015

@segiddins
I would really appreciate if we can evaluate more on this, cause I am really trying to understand your point.

So which setting do you call "Standard"?
I just created a new project, and here are default settings:
https://www.dropbox.com/s/180hbr0dzg4jvxb/Screenshot%202015-09-25%2000.36.19.png?dl=0
When I install pods, push it to repository, clone it from repository, and install pods again, everything works fine. When I do the same with the Chain projects, it fails, despite the fact that the build settings are the same.

If I misunderstood which build settings are you talking about, please point that out.

Thanks in advance!

@segiddins
Copy link
Member

You're saying this only happens when you've changed the ONLY_ACTIVE_ARCH setting though, right?

@dumoko
Copy link
Author

dumoko commented Sep 25, 2015

Thanks again for bearing with me :)

No.
The only thing I was initially mentioning about ONLY_ACTIVE_ARCH is that changing it to non-default state in Pods project helps me solve the compile error.
If you clone the project, you will see that all ONLY_ACTIVE_ARCH are default and correct from the very beginning. But still after pod install a compile error will appear.

@orta
Copy link
Member

orta commented Sep 25, 2015

screen shot 2015-09-25 at 09 22 58

The left is yours, the right is the project defaults, a debug build by defaults here to "Yes"

@neonichu
Copy link
Member

BTW, the easiest way to see if you got a non-default setting is that it will be bold in the Build Settings view. You can go back to the default by hitting delete while you have it selected.

(Unfortunately, some settings are bold in the project settings by default, because they actually get changed by Xcode itself during project creation, but in the grand scheme of things, this is true :) Especially for the target settings, which are the most interesting.)

@dumoko
Copy link
Author

dumoko commented Sep 25, 2015

@orta
Thanks for the screenshots, it helped removing the misunderstanding about which build settings are we all talking about.

@neonichu
Thanks for the given hints :) I experimented with the delete key, and not all the results were nice, i totally get what you mean by "interesting" :)

to all:
Thanks to all you hints I was able to do some more experiments.
Again, the main problem is fresh clone -> pod install -> compile error.
So after couple of iterations I figured out that the main_project->project build settings does not resolve the issue.
But the main_project->main_target build settings with setting the ONLY_ACTIVE_ARCH to debug to YES actually does solve the issue.

So we got all our projects finally working well...
Thanks guys for bearing with me. You are great :)
I guess we can close the issue...

@dumoko dumoko closed this as completed Sep 25, 2015
@neonichu
Copy link
Member

Ah, I totally get the confusion now — personally, I almost never bother with the project build settings but go straight to the targets :)

@orta
Copy link
Member

orta commented Sep 26, 2015

Which is interesting, cause I tend to go the opposite direction. Settings only at project level, then if needed at the target level.

@dumoko
Copy link
Author

dumoko commented Sep 26, 2015

Considering this experience - does it make sense to think on some pods improvements? Or this whole issue is pure developer-fault-only?

@jpaas
Copy link

jpaas commented Jan 4, 2016

I'd like to echo @OlegAnghelov 's question. There seems to be a problem with out of the box behavior here. I just created a new new project, added a couple of pods and it wouldn't link until I

  1. modified the "Build Active Architectures Only" setting on the Pods project to build all architectures even under debug
  2. did a project clean (strange but true)

Is this a bug, or some configuration setting missing from the Podfile? A bug in a podspec?

@neonichu
Copy link
Member

neonichu commented Jan 4, 2016

@jpaas Did you change the ONLY_ACTIVE_ARCH setting of your project or any of the targets?

@jpaas
Copy link

jpaas commented Jan 4, 2016

@neonichu I only changed the settings on the Pods project. No target changes.

@neonichu
Copy link
Member

neonichu commented Jan 4, 2016

@jpaas hard to say what is happening then without more information.

If you think it is a bug, you should open a new issue, with the information listed in our contribution guidelines, so that we can debug the issue.

@jpaas
Copy link

jpaas commented Jan 4, 2016

Will do. Thanks @neonichu

@jpaas
Copy link

jpaas commented Jan 4, 2016

#4725 opened

@gholias
Copy link

gholias commented Jan 12, 2016

Im also having this problem and it is very frustrating. I tried everything I found on stackoverflow and none helped.

@adamski
Copy link

adamski commented Jan 16, 2016

I also have this issue but the Active Architectures solution didn't work for me. See http://stackoverflow.com/questions/34792596/ld-library-not-found-for-lreact

@slotmaster
Copy link

I am having the same problem. My old target works fine. I tried to create a new target and got this error on simulator but it's working on device. After playing with it for hours, it still doesn't work. What's worse, I reverted all my changes but it's broken on both my new and old targets, both on device and simulator. Very frustrating!

@patrick-sheehan
Copy link

A solution I found was removing the broad Pods frameworks from my Target's 'Link Binary With Libraries' and adding the actual frameworks I wanted (listed in my workspace, installed thru pods)

@adamski
Copy link

adamski commented Jan 21, 2016

My solution was to set "Per-configuration Build Products Path" to $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) - the generated project had this set to something else.

@shijian123
Copy link

thank you

@deepp
Copy link

deepp commented Apr 28, 2016

I tried all settings mentioned above but still no luck. Has anybody resolved it yet,would be helpful if can share the solution.

@patrick-sheehan
Copy link

This problem happened to me again and my solution this time was that I had removed a debug configuration from the project file. I had to re-add it using git

@suculent
Copy link

suculent commented May 4, 2016

Well, I had exactly the same issue and it gets more frustrating with each appearance. So I've managed to finally build the project after:

  1. after clean pod install...
  2. erasing custom Build Products Path settings, because the issue appeared both on workstation and Jenkins CI and the build folder did contain different contents for Release and Debug configurations
  3. setting ONLY_ACTIVE_ARCH on project target level to YES
  4. project finally builds with no issues.
  5. setting ONLY_ACTIVE_ARCH on project target level to NO – project still builds with no issues
  6. performing Deep Clean; building with ONLY_ACTIVE_ARCH to NO works again.

@SendorWang
Copy link

I hate CocoaPods

@liushuaikobe
Copy link

In my case, I found both -l"MyFrameworkName" and -framework "MyFrameworkName"shows at OTHER_LDFLAGS in Pods-MyProject.debug.xcconfig.

MyFramework is already a binary. Why -l stuff shows at OTHER_LDFLAGS ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests