Cocoapods: Swift Conversion Should Be Inhibited by inhibit_all_warnings!

Created on 3 Apr 2019  路  8Comments  路  Source: CocoaPods/CocoaPods

馃寛

Report

What did you do?

I opened my existing workspace with a new version of Xcode which included a new Swift version. (Xcode 10.2, Swift 5.0)

My Podfile includes inhibit_all_warnings!.

What did you expect to happen?

I expected that all warnings I saw would apply only to my app code and not to Pods.

What happened instead?

I was given warnings that Swift 5 conversion was available for Pod projects.

Request

Manually marking those targets as "Don't Remind Me" with Xcode results in the following changes in my project file:

/* Begin PBXProject section */
        BFDFE7DC352907FC980B868725387E98 /* Project object */ = {
            isa = PBXProject;
            attributes = {
                LastSwiftUpdateCheck = 0930;
                LastUpgradeCheck = 0930;
                TargetAttributes = {
                    3B89420BB3D74AD2DCF0D76DA7C98D30 = {
                        LastSwiftMigration = 1020;
                    };
                    72AC8D674DF3E00D18AF01E060D70EBC = {
                        LastSwiftMigration = 1020;
                    };
                    AFD3EF90CF874B6247EE8C79F6BF3B5D = {
                        LastSwiftMigration = 1020;
                    };
                };
            };

If you could generate the Pods project with ALL targets marked with LastSwiftMigration = 9999; then I'd never be asked to migrate the Swift version of Pods targets. And then this occasional warning would also be suppressed by inhibit_all_warnings!. 馃寛

CocoaPods Environment

Stack

   CocoaPods : 1.6.1
        Ruby : ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]
    RubyGems : 3.0.2
        Host : Mac OS X 10.14.3 (18D109)
       Xcode : 10.2 (10E125)
         Git : git version 2.20.1
Ruby lib dir : /usr/local/Cellar/ruby/2.6.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ c04d675f6a80a93b03a264e0811dd862bf0c8e9b

Installation Source

Executable Path: /Users/path/to/redacted/vendor/bundle/ruby/2.6.0/bin/pod

Plugins

cocoapods-acknowledgements : 1.1.3
cocoapods-deintegrate      : 1.0.3
cocoapods-plugins          : 1.0.0
cocoapods-search           : 1.0.0
cocoapods-stats            : 1.1.0
cocoapods-trunk            : 1.3.1
cocoapods-try              : 1.1.0

Podfile

# Uncomment this line to define a global platform for your project
 platform :ios, '11.2'

# ignore all warnings from all pods
inhibit_all_warnings!

target 'Redacted' do
  use_frameworks!

  # Pods for Redacted
  pod 'Crashlytics', '3.8.3'
  pod 'Fabric', '1.6.10'

  target 'RedactedTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'RedactedIntegrationTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'RedactedUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

plugin 'cocoapods-acknowledgements'
moderate help wanted enhancement

Most helpful comment

Just found a neat trick that is working at the moment. Just add this to your pod file:

post_install do |installer|
  # This removes the warning about swift conversion, hopefuly forever!
  installer.pods_project.root_object.attributes['LastSwiftMigration'] = 9999
  installer.pods_project.root_object.attributes['LastSwiftUpdateCheck'] = 9999
  installer.pods_project.root_object.attributes['LastUpgradeCheck'] = 9999
end

All 8 comments

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:

Just found a neat trick that is working at the moment. Just add this to your pod file:

post_install do |installer|
  # This removes the warning about swift conversion, hopefuly forever!
  installer.pods_project.root_object.attributes['LastSwiftMigration'] = 9999
  installer.pods_project.root_object.attributes['LastSwiftUpdateCheck'] = 9999
  installer.pods_project.root_object.attributes['LastUpgradeCheck'] = 9999
end

Hey @gpambrozio
Any clue of how to suppress Enable New Build System recommended settings warning?
Screen Shot 2020-07-15 at 2 35 26 AM
I've tried adding installer.pods_project.root_object.attributes['LastUpgradeCheck'] = 9999 then did pod install but it still shows up.

@EvgenyKarkan sorry, not sure. But if you can "manually" clear this error you can probably look at the diff of what XCode did to your project and try to reproduce that on the script. It's what I did to figure this trick.

Yep, I already did & was able to suppress it for the main target.
What I saw in the diff was exactly bumping LastUpgradeCheck version:
Screen Shot 2020-07-15 at 2 46 54 AM
But for some reason it doesn't work for Pods target.
Thanks for your reply!

Even after @gpambrozio nice solution I still had warnings. I found out that those were because of xcuserdata schemas - those also have LastUpgradeCheck fields that needs to be updated. My my final solution looks like this:

post_install do |installer|
  # This removes the warning about swift conversion, hopefuly forever!
  installer.pods_project.root_object.attributes['LastSwiftMigration'] = 9999
  installer.pods_project.root_object.attributes['LastSwiftUpdateCheck'] = 9999
  installer.pods_project.root_object.attributes['LastUpgradeCheck'] = 9999

  shared_data_dir = Xcodeproj::XCScheme.user_data_dir(installer.pods_project.path)
  Dir["#{shared_data_dir}/*.xcscheme"].each do |scheme_path|
    scheme = Xcodeproj::XCScheme.new scheme_path
    scheme.doc.root.attributes['LastUpgradeVersion'] = 9999
    scheme.save!
  end
end

Even after @gpambrozio nice solution I still had warnings. I found out that those were because of xcuserdata schemas - those also have LastUpgradeCheck fields that needs to be updated. My my final solution looks like this:

post_install do |installer|
  # This removes the warning about swift conversion, hopefuly forever!
  installer.pods_project.root_object.attributes['LastSwiftMigration'] = 9999
  installer.pods_project.root_object.attributes['LastSwiftUpdateCheck'] = 9999
  installer.pods_project.root_object.attributes['LastUpgradeCheck'] = 9999

  shared_data_dir = Xcodeproj::XCScheme.user_data_dir(installer.pods_project.path)
  Dir["#{shared_data_dir}/*.xcscheme"].each do |scheme_path|
    scheme = Xcodeproj::XCScheme.new scheme_path
    scheme.doc.root.attributes['LastUpgradeVersion'] = 9999
    scheme.save!
  end
end

It looks like working for me, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marzapower picture marzapower  路  3Comments

steffendsommer picture steffendsommer  路  3Comments

tlandsmancars picture tlandsmancars  路  3Comments

evermeer picture evermeer  路  3Comments

soleares picture soleares  路  3Comments