Cocoapods: Cannot link framework Xcode warning

Created on 1 Dec 2017  Â·  25Comments  Â·  Source: CocoaPods/CocoaPods

ℹ Please fill out this template when filing an issue.
All lines beginning with an ℹ symbol instruct you with
what info we expect.
Please remove this line and all above before submitting.

Before you start, are you using the latest CocoaPods release?
A lot changes with Xcode releases that are not backwards compatible.

Not an issue about the CocoaPods command line app? Please file an issue in the appropriate repo - https://github.com/CocoaPods
Issues are for feature requests, and bugs; questions should go to Stack Overflow

Using CocoaPods <= 0.39: http://blog.cocoapods.org/Sharding/

Using Xcode 8: Requires CocoaPods 1.1.0 or above.

Issue with Nanaimo not loading:
Please run [sudo] gem uninstall nanaimo and remove all but the latest version.

Issues with pod search? Try deleting your cache rm -rf ~/Library/Caches/CocoaPodsfirst.

[ x ] I've read and understood the *CONTRIBUTING guidelines and have done my best effort to follow.

Report

What did you do?

Build project in Xcode

What did you expect to happen?

No warnings

What happened instead?

Received warning:

Target Pods-GradePointWidget product Pods_GradePointWidget cannot link framework Foundation.framework

and

Target Pods-GradePoint product Pods_GradePoint cannot link framework Foundation.framework

CocoaPods Environment

Stack

   CocoaPods : 1.3.1
        Ruby : ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
    RubyGems : 2.6.13
        Host : Mac OS X 10.13.1 (17B1003)
       Xcode : 9.1 (9B55)
         Git : git version 2.15.0
Ruby lib dir : /Users/luis/.rbenv/versions/2.4.2/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 7f3d176dda94ec73ab00f3956cf59eadc013ec49

Installation Source

Executable Path: /Users/luis/.rbenv/versions/2.4.2/bin/pod

Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0

Podfile

platform :ios, '9.0'
use_frameworks!

def all_pods
  pod 'UICircularProgressRing'
  pod 'UIEmptyState'
  pod 'LPSnackbar'
end

target 'GradePoint' do
  all_pods
end

target 'GradePointTests' do 
  all_pods
end

target 'GradePointUITests' do 
  all_pods
end

target 'GradePointWidget' do
  pod 'UICircularProgressRing'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|

    puts target.name

    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.0'

    end
  end
end

Project that demonstrates the issue

You can test the project out here

new build system

Most helpful comment

Found the culprit, I'll open the PR's soon enough: https://github.com/CocoaPods/Xcodeproj/blob/master/lib/xcodeproj/project/project_helper.rb#L63.

Which leads me to a question for the implementation:

  1. Should we add a new use_new_build_system flag that would set it also on the workspace when generating it
  2. Should we patch xcodeproj in order not to generate the targets OR remove the targets after they have been generated?

All 25 comments

Seems related to the new build system. Will tag it as such.

I have an app target ("Mockingbird") and Today widget ("InstantBalance"), both of which are getting this. I'm using Swift 3 throughout.

Target Pods-InstantBalance product Pods_InstantBalance cannot link framework Foundation.framework
Target Pods-Mockingbird product Pods_Mockingbird cannot link framework Foundation.framework

Everything seems to run fine still though.

Stack

   CocoaPods : 1.3.1
        Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
    RubyGems : 2.6.14
        Host : Mac OS X 10.12.6 (16G29)
       Xcode : 9.2 (9C40b)
         Git : git version 2.14.3
Ruby lib dir : ~/.rvm/rubies/ruby-2.4.1/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ feb4938c83aa400e6e759b093299dea0426fdfb6

Plugins

    - cocoapods-deintegrate : 1.0.1
    - cocoapods-plugins     : 1.0.0
    - cocoapods-search      : 1.0.0
    - cocoapods-stats       : 1.0.0 (post_install hook)
    - cocoapods-trunk       : 1.2.0
    - cocoapods-try         : 1.1.0

Podfile

ENV['COCOAPODS_DISABLE_STATS'] = "true"

platform :ios, '9.3'
use_frameworks!

def core_pods
  pod 'Alamofire', '~> 4.5.0'
  pod 'SwiftyJSON'
  pod 'Bond', '6.3.0'
  pod 'KeychainSwift', '~> 8.0'
  pod 'PromiseKit'
  pod 'Log'
  pod 'SnapKit', '~> 3.2.0'
  pod 'Koyomi', '~> 1.2'
  pod 'Firebase/Core'
  pod 'Firebase/Crash'
  pod 'Firebase/Performance'
end

def testing_pods
  pod 'Quick'
  pod 'Nimble', inhibit_warnings: true
  pod 'Fakery'
end

target 'Mockingbird' do
  project 'Mockingbird', 'Acceptance' => :debug
  core_pods
end

target 'MockingbirdTests' do
  project 'Mockingbird', 'Acceptance' => :debug
  core_pods
  testing_pods
end

target 'MockingbirdAcceptanceTests' do
  project 'Mockingbird', 'Acceptance' => :debug
  core_pods
  testing_pods
  pod 'KIF'
  pod 'KIF/IdentifierTests'
  pod 'OHHTTPStubs/Swift'
end

target 'InstantBalance' do
  project 'Mockingbird', 'Acceptance' => :debug
  core_pods
end

Are you using the new build system?

On Wed, Dec 20, 2017 at 9:43 PM Jay Whitsitt notifications@github.com
wrote:

I have an app target ("Mockingbird") and Today widget ("InstantBalance"),
both of which are getting this. I'm using Swift 3 throughout.

Target Pods-InstantBalance product Pods_InstantBalance cannot link framework Foundation.framework
Target Pods-Mockingbird product Pods_Mockingbird cannot link framework Foundation.framework

Everything seems to run fine still though.
Stack

CocoaPods : 1.3.1
Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
RubyGems : 2.6.14
Host : Mac OS X 10.12.6 (16G29)
Xcode : 9.2 (9C40b)
Git : git version 2.14.3

Plugins

- cocoapods-deintegrate : 1.0.1
- cocoapods-plugins     : 1.0.0
- cocoapods-search      : 1.0.0
- cocoapods-stats       : 1.0.0 (post_install hook)
- cocoapods-trunk       : 1.2.0
- cocoapods-try         : 1.1.0

Podfile

ENV['COCOAPODS_DISABLE_STATS'] = "true"

platform :ios, '9.3'
use_frameworks!

def core_pods
pod 'Alamofire', '~> 4.5.0'
pod 'SwiftyJSON'
pod 'Bond', '6.3.0'
pod 'KeychainSwift', '~> 8.0'
pod 'PromiseKit'
pod 'Log'
pod 'SnapKit', '~> 3.2.0'
pod 'Koyomi', '~> 1.2'
pod 'Firebase/Core'
pod 'Firebase/Crash'
pod 'Firebase/Performance'
end

def testing_pods
pod 'Quick'
pod 'Nimble', inhibit_warnings: true
pod 'Fakery'
end

target 'Mockingbird' do
project 'Mockingbird', 'Acceptance' => :debug
core_pods
end

target 'MockingbirdTests' do
project 'Mockingbird', 'Acceptance' => :debug
core_pods
testing_pods
end

target 'MockingbirdAcceptanceTests' do
project 'Mockingbird', 'Acceptance' => :debug
core_pods
testing_pods
pod 'KIF'
pod 'KIF/IdentifierTests'
pod 'OHHTTPStubs/Swift'
end

target 'InstantBalance' do
project 'Mockingbird', 'Acceptance' => :debug
core_pods
end

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/CocoaPods/CocoaPods/issues/7251#issuecomment-353161677,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAS8YpgiZXFm3so1LBP3C85_YMBg0HrVks5tCWIdgaJpZM4Qx2YY
.

@dnkoutso, I just realized what you meant by that earlier. Yes I am. I can confirm that using the old build system doesn't produce the warning.

Confirmed as well with latest Xcode (Version 9.3 beta 4 (9Q127n)), new build system and cocoapods 1.4.0

We probably need to either (1) remove the @import Foundation from the generate aggregate target sources or (b) link the aggregate target against foundation

Removing the link in each individual dependency target indeed silences the warning without any other side effect. Also, all links seems to need to be removed for such targets. I’m not sure about aggregate targets

Sent with GitHawk

My understanding is that this is the new build system being overly aggressive with the warning, as specifying frameworks to link against is necessary to be able to import their headers, and the warning should go away in future versions of Xcode

Let’s wait and see then!

I got the same warning: Target Pods-XXX product Pods_XXX cannot link framework Foundation.framework. Using non-beta Xcode 9.3 (9E145), new build system (Preview), CocoaPods 1.4.0. Project builds and runs normally.

I also got this same issue on the released version of Xcode 9.3 (9E145), new build system (Preview), CocoaPods 1.4.0.

Me too, went away with going back to standard build system.

@segiddins @dnkoutso I’d like to give this one a go. Would it be reasonable to to add a use_new_build_system! into the Podfile to switch between the two behaviors or should we detect the build system in the project / workspace?

I see the same problem here, too.

Found the culprit, I'll open the PR's soon enough: https://github.com/CocoaPods/Xcodeproj/blob/master/lib/xcodeproj/project/project_helper.rb#L63.

Which leads me to a question for the implementation:

  1. Should we add a new use_new_build_system flag that would set it also on the workspace when generating it
  2. Should we patch xcodeproj in order not to generate the targets OR remove the targets after they have been generated?

@flovilmart is it possible to do it manually in Podfile in post_install phase? For those who don't want to wait for patch, use new build system, and hate warnings.
Looks like it may be achieved via searching for "Foundation" in frameworks_build_phase and removing it directly.

Looks like this snippet works:

post_install do |installer|
    podsTargets = installer.pods_project.targets.find_all { |target| target.name.start_with?('Pods') }
    podsTargets.each do |target|
        target.frameworks_build_phase.clear
    end
end

Dunno how to remove only Foundation. Or maybe these targets should be removed all together per @flovilmart comment above.

On my patch, I remove afterwards the foundation framework.

@flovilmart Florent, have you resolved this?

I opened a PR, but we’ll go with a different resolution #7570

Hello, I still have the same warning. I have updated to cocoa pods 1.5.3.
Am I missing something in the pod file or something?

@nacho4d The fix for this (#7721) is not in 1.5.3, but presumably will be in the next release.

Ahh, I see. Thanks for letting us know.
Looking forward the next version then.

I hope it is released somewhere this month so I can ship the app without warnings :)

I'm using https://github.com/CocoaPods/CocoaPods/releases/tag/1.6.0.beta.1, and keeps warning me!
Should I pod destruct before use beta version?
I was using 1.5.3

Was this page helpful?
0 / 5 - 0 ratings