Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoapods optimization level for schemes

Looking at the project file for Cocoapods Pods.xcodeproj it looks like every single scheme for every library (except for Debug scheme) has an optimization level of Fastest, Smallest.

Is there a quick and easy way to change the Podfile or some other configuration of Cocoapods so that the optimization level is None for specific schemes when I use pod install?

enter image description here

like image 594
Awesome-o Avatar asked Feb 12 '14 00:02

Awesome-o


2 Answers

I use post_install hook in Podfile. Like this:

post_install do |installer|
    installer.pods_project.build_configurations.each do |config|
        if config.name.include?("Debug")
            config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
            config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
        end
    end
end

EDIT GCC_OPTIMIZATION_LEVEL is ignored for Swift Pods. If you're using Swift Pods you also need to set SWIFT_OPTIMIZATION_LEVEL.

like image 129
Toru Hosokawa Avatar answered Oct 09 '22 22:10

Toru Hosokawa


To anybody seeing this using cocoapods 0.38.0 or later:

Use "pods_project" instead of "project"

The previous answers use the word "project" (installer.project.build_configurations.each)

Project was deprecated and replaced with pods_project. https://github.com/CocoaPods/CocoaPods/issues/3747

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    if config.name.include?("Debug")
      config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
    end
  end
end
like image 39
user1366911 Avatar answered Oct 09 '22 23:10

user1366911