Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove -Objc flag from Cocoapods install

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.

like image 621
thattyson Avatar asked Jul 14 '15 15:07

thattyson


1 Answers

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.

like image 89
Fernando Mata Avatar answered Nov 20 '22 10:11

Fernando Mata