Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot link framework Xcode warning #7251

Closed
luispadron opened this issue Dec 1, 2017 · 25 comments
Closed

Cannot link framework Xcode warning #7251

luispadron opened this issue Dec 1, 2017 · 25 comments
Labels
r:new build system Issues related to Xcode's new build system introduced in Xcode 9
Milestone

Comments

@luispadron
Copy link

ℹ 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

@dnkoutso
Copy link
Contributor

dnkoutso commented Dec 6, 2017

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

@dnkoutso dnkoutso added the r:new build system Issues related to Xcode's new build system introduced in Xcode 9 label Dec 6, 2017
@cjwhitsitt
Copy link

cjwhitsitt commented Dec 20, 2017

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

@dnkoutso
Copy link
Contributor

dnkoutso commented Dec 20, 2017 via email

@cjwhitsitt
Copy link

@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.

@flovilmart
Copy link

flovilmart commented Mar 9, 2018

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

@segiddins
Copy link
Member

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

@flovilmart
Copy link

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

@segiddins
Copy link
Member

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

@flovilmart
Copy link

Let’s wait and see then!

@kacper1703
Copy link

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.

@gravy-luke
Copy link

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

@mannd
Copy link

mannd commented Mar 30, 2018

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

@flovilmart
Copy link

@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?

@fysteven
Copy link

I see the same problem here, too.

@flovilmart
Copy link

flovilmart commented Mar 31, 2018

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?

@iThinker
Copy link

iThinker commented Apr 16, 2018

@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.

@iThinker
Copy link

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.

@flovilmart
Copy link

On my patch, I remove afterwards the foundation framework.

@agordeev
Copy link

@flovilmart Florent, have you resolved this?

@flovilmart
Copy link

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

@dnkoutso dnkoutso added this to the 1.6.0 milestone May 9, 2018
@dnkoutso
Copy link
Contributor

dnkoutso commented May 9, 2018

Believe this is fixed by CocoaPods/Xcodeproj#571

@nacho4d
Copy link

nacho4d commented Jul 30, 2018

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?

@brow
Copy link

brow commented Aug 3, 2018

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

@nacho4d
Copy link

nacho4d commented Aug 4, 2018

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 :)

@RafaelPlantard
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r:new build system Issues related to Xcode's new build system introduced in Xcode 9
Projects
None yet
Development

No branches or pull requests