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!
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.
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.
Yes, I'm doing it like the way you mentioned, but I always have a failure !
@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.
@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.
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.
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?
You have changed the setting in your project.
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?
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?
https://github.com/CocoaPods/CocoaPods/issues/2053
https://github.com/CocoaPods/CocoaPods/issues/4171
@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.
@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!
You're saying this only happens when you've changed the ONLY_ACTIVE_ARCH
setting though, right?
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.
The left is yours, the right is the project defaults, a debug build by defaults here to "Yes"
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.)
@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...
Ah, I totally get the confusion now — personally, I almost never bother with the project build settings but go straight to the targets :)
Which is interesting, cause I tend to go the opposite direction. Settings only at project level, then if needed at the target level.
Considering this experience - does it make sense to think on some pods improvements? Or this whole issue is pure developer-fault-only?
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
Is this a bug, or some configuration setting missing from the Podfile? A bug in a podspec?
@jpaas Did you change the ONLY_ACTIVE_ARCH
setting of your project or any of the targets?
@neonichu I only changed the settings on the Pods project. No target changes.
@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.
Will do. Thanks @neonichu
Im also having this problem and it is very frustrating. I tried everything I found on stackoverflow and none helped.
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
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!
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)
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.
thank you
I tried all settings mentioned above but still no luck. Has anybody resolved it yet,would be helpful if can share the solution.
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
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:
0) after clean pod install
...
1) 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
2) setting ONLY_ACTIVE_ARCH
on project target level to YES
3) project finally builds with no issues.
4) setting ONLY_ACTIVE_ARCH
on project target level to NO – project still builds with no issues
5) performing Deep Clean; building with ONLY_ACTIVE_ARCH
to NO works again.
I hate CocoaPods
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
?
Most helpful comment
I hate CocoaPods