51

enter image description here

Since updating to Xcode10 and Swift 4.2, I always get this build time warnings in my pod. what do I have to do to remove these warnings?

I have tried to delete derived data, clean and build project, but it doesn't work :(

I find someone asks the same question here https://github.com/Alamofire/Alamofire/issues/2624 and there is an answer from Jon Shier, but I still can't resolve the issue after removing the previous xcworkspace and update cocoapods, I have not implemented to change "Generate Position-Dependent Executable" setting because I can't find it. please share if you can find the solution of this issue :)

Yoon5oo
  • 489
  • 5
  • 11
sarah
  • 2,726
  • 22
  • 53
  • Well, I removed 'DerivedData' and it works for me! – Kampai Oct 25 '18 at 12:32
  • 2
    in my case, yes it will disappear for a while, but after coming back to Xcode for a few days later, it will appear again. – sarah Oct 25 '18 at 23:13
  • 2
    [**Do not post images of code or errors!**](https://meta.stackoverflow.com/q/303812/995714) Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. If you post images of code or error messages make sure you also copy and paste or type the actual code/message into the post directly. – Rob Nov 07 '18 at 04:00
  • 13
    It's perfectly fine to post imaghes from a visual IDE – Fattie Jun 20 '19 at 10:57
  • 3
    A post is a thousand times more clear with images of code and errors. – zeeshan Jan 25 '20 at 13:10
  • Has anybody found a working fix for this? – Dmitry Feb 14 '20 at 00:24

5 Answers5

31

Setting "Generate Position-Dependent Code" to Yes does not feel like the right fix. Position-independent is preferred. Non-app targets like frameworks and libraries will always be position independent anyway, hence the warning.

The warning shown is a linker message and the other setting in @Marcpek's screen shot seems more suitable: "Linking > Generate Position-Dependent Executable". QuickHelp shows this is the LD_NO_PIE setting.

Generate Position-Dependent Executable LD_NO_PIE setting

Even though this inherits No anyway from the OS defaults I tried setting it to No again in my CocoaPod targets explicitly and that seemed to work, fixing the linker warning.

Any project settings you make will be lost the next time you run pod install so edit the Podfile to make the change permanent. Add config.build_settings['LD_NO_PIE'] = 'NO' into post_install phase:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['LD_NO_PIE'] = 'NO'
        end
    end
end
Ben
  • 1,123
  • 10
  • 18
19

What finally worked for me is to enable position-dependent code for the Pods project. I tried disabling warnings from pods and clearing (instead of enabling) the Generate Position-Dependent Code setting before but that didn't really work.

Disable -pie for Pods

To enable position-dependent code (and hence remove -pie, which is Position Independent Code), after opening the xcworkspace, go to the Pods project build settings (the settings for the whole Pods project, see screenshot), search for position and set the Generate Position-Dependent Code build setting to Yes.

Changing pie setting for Pods

Marcpek
  • 436
  • 4
  • 6
  • 1
    It worked for me, Xcode 11. However, I am not sure why it started all of a sudden? I have other projects too with similar Pods on Xcode 11, but this problem started only yesterday with this one particular project. – zeeshan Jan 25 '20 at 15:38
5

One option is to switch to linking pods as static libraries instead of frameworks. use_frameworks! was required when Swift didn't support static libraries, but now that it does, you can remove that line from your Podfile, pod install, and the warning should be gone.

More info on the history of use_frameworks: https://stackoverflow.com/a/49469205/8831

stevex
  • 5,055
  • 30
  • 49
0

I have fixed by setting Build Settings -> Packaging -> Convert Copied Files = yes

Serg Smyk
  • 344
  • 1
  • 7
-4
  • update cocoapods
  • delete xcworkspace
  • run "pod install"
  • clear Build folder in menu "Product"