Cocoapods: Xcode generated warning to update the Pods project to use whole module optimization

Created on 30 Aug 2018  Â·  15Comments  Â·  Source: CocoaPods/CocoaPods

Report

What did you do?

pod install

What did you expect to happen?

I expected Xcode to not generate a warning suggesting to update the Pods project to use "recommended settings."

What happened instead?

Xcode generated a warning suggesting to update the Pods project to use "recommended settings." Specifically, in my Swift project, the suggestion is to enable whole module optimization (build setting SWIFT_OPTIMIZATION_LEVEL).

CocoaPods Environment

Stack

   CocoaPods : 1.6.0.beta.1
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
    RubyGems : 2.5.2.3
        Host : Mac OS X 10.13.6 (17G65)
       Xcode : 9.4.1 (9F2000)
         Git : git version 2.15.2 (Apple Git-101.1)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ de1dc11533e59cac2cbdeb80d3a0fd4d7670f77a

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.1
cocoapods-try         : 1.1.0

Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '9.1'

target 'CocoaPods_TestProject' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for CocoaPods_TestProject
  pod 'SnapKit'
  pod 'XCGLogger'

end

Project that demonstrates the issue

https://github.com/Chris-Corea/CocoaPods-Issue

Most helpful comment

I think I finally found the issue - PR incoming soon

All 15 comments

My issue describes the same issue as mentioned in #7944, however, aside from using 1.6.0.beta.1, I thought it would be useful to mention that my xcodeproj version is 1.6.0.

› xcodeproj --version
1.6.0

Thanks Chris! I'll try to repro with your sample project

Looks like both Xcode 9 and Xcode 10 want this:

 'SWIFT_OPTIMIZATION_LEVEL'            => '-Owholemodule',

but https://github.com/CocoaPods/Xcodeproj/pull/578 updated the settings to this:

 'SWIFT_COMPILATION_MODE'            => 'wholemodule',
 'SWIFT_OPTIMIZATION_LEVEL'          => '-O',

when I looked into #7944 I had it reversed. @segiddins any ideas on what's going on here? I can also repro this by creating a new project in the Xcode 10 beta.

Partially, but that was encompassing a lot of stuff that is now fixed

I generated the settings with the update from Xcode script, but it's possible the latest betas have changed the default

Make sense

Dug into this some more.

Both Xcode 9.4 and 10 use these settings when creating a new iOS app target or static library:

 'SWIFT_COMPILATION_MODE'            => 'wholemodule',
 'SWIFT_OPTIMIZATION_LEVEL'          => '-O',

but when creating a framework, it does this instead:

 'SWIFT_OPTIMIZATION_LEVEL'            => '-Owholemodule',

still trying to figure out why it does so (I can't seem to find that in any of the project templates built into Xcode) but this feels like an Xcode bug to me. Swift 4.1 replaced -Owholemodule with a separate -whole-module flag (see here), and this is reflected in Xcode's SWIFT_COMPILATION_MODE setting.

So it seems that Xcode wants to stick with the old settings for frameworks only. You can test this by removing use_frameworks! in a Podfile that causes the warning, and the warning will go away

Should this still remain open?

Checked again on Xcode 10 (public release), now the frameworks are behaving correctly but now Xcode wants the project itself to specify these settings. Will look into this some more

Doesn't appear to happen in a fresh project - @Chris-Corea can you confirm the issue no longer occurs on Xcode 10? (release build, 10A255)

I can still reproduce this with Xcode 10 (release build, 10A255). Attached is a screenshot.

screen shot 2018-09-24 at 1 03 24 pm

darn, ok, will keep digging 😞

I think I finally found the issue - PR incoming soon

Confirmed that https://github.com/CocoaPods/Xcodeproj/pull/611 fixes the issue with your example project 🙌

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marzapower picture marzapower  Â·  3Comments

steffendsommer picture steffendsommer  Â·  3Comments

pronebird picture pronebird  Â·  3Comments

iosdev-republicofapps picture iosdev-republicofapps  Â·  3Comments

pallaviMN picture pallaviMN  Â·  3Comments