Remove -Objc flag from Cocoapods install
Asked Answered
V

1

7

My project won't build if I keep the -Objc flag in other linker flags and I inherit the flag from Cocoapods. I can delete this from Pods.debug.xcconfig and all works, however, every time I run pod update it comes back and I have to delete it again.

Is there a podfile script I could add to automate removing the -Objc flag?

I'm using Cocoapods v0.37.2. I'd like to remove -Objc from the following snippet taken from Pods.release.xcconfig and Pods.debug.xcconfig.

OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"sqlite3" -framework "AVFoundation" -framework "Alamofire"

btw the need to remove the -Objc flag is caused by Parse and Facebook SDKs.

Velites answered 14/7, 2015 at 15:20 Comment(1)
Which Cocoapods you are using? Give us an example with -Objc so you can test too.Fallonfallout
T
7

I don't know if you still need this, but I was able to do it with a post_install script on the Podfile. I have different targets and this works very well:

post_install do |installer|
installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        new_xcconfig = xcconfig.sub('OTHER_LDFLAGS = $(inherited) -ObjC', 'OTHER_LDFLAGS = $(inherited)')
        File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
    end
  end
end

I took most of the script from this answer, but I wasn't able to make it work with the v 1.5 that he posted, so I just modified the v 1.0, hope you can use it or it can help someone in the future.

Treenware answered 13/10, 2016 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.