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

pre_compile hook is called to late with CocoaPods 1.6.0.beta.2 #75

Open
bpoplauschi opened this issue Nov 14, 2018 · 17 comments
Open

pre_compile hook is called to late with CocoaPods 1.6.0.beta.2 #75

bpoplauschi opened this issue Nov 14, 2018 · 17 comments

Comments

@bpoplauschi
Copy link

Report

What did you do?

  • run pod install on an empty folder with just this Podfile
platform :ios, '8.0'

plugin 'cocoapods-rome'

target 'caesar' do
  pod 'Alamofire'
end
  • What did you expect to happen?
    To get an output folder with the compiled Alamofire framework

  • What happened instead?
    Got the SWIFT_VERSION missing error.

Command

pod install

Stack

   CocoaPods : 1.6.0.beta.2
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin17]
    RubyGems : 2.7.7
        Host : Mac OS X 10.13.6
       Xcode : Version 10.0 (10A255)
         Git : git version 2.17.1 (Apple Git-112)
Ruby lib dir : 
Repositories : master - https://github.com/CocoaPods/Specs.git @ 3b87cd44ee362bf10ba1b86e622b3bb219ef5c94

Plugins

cocoapods (1.6.0.beta.2, 1.6.0.beta.1, 1.5.3)
cocoapods-core (1.6.0.beta.2, 1.6.0.beta.1, 1.5.3)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
cocoapods-rome (1.0.1)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.1)
cocoapods-try (1.1.0)

Podfile

platform :ios, '8.0'

plugin 'cocoapods-rome'

target 'caesar' do
  pod 'Alamofire'
end

Error

[!] Unable to determine Swift version for the following pods:

- `Alamofire` does not specify a Swift version and none of the targets (`caesar`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
@dnkoutso
Copy link
Contributor

I don think that is related with this project.

@Thomvis
Copy link

Thomvis commented Mar 6, 2019

I encountered the same problem. Downgrading to 1.5.3 consistently solves the issue for me.

@bpoplauschi
Copy link
Author

@Thomvis same for me.
I never got a response back from the CP team on this issue. Maybe it's related to @dnkoutso 's comment. Why do you think it's not related to this project? I described a clear scenario where the plugin doesn't function correctly with CocoaPods 1.6.0.beta.2

@Unknoob
Copy link

Unknoob commented Apr 8, 2019

Getting the same error with Cocoapods 1.6.1, downgrading to 1.5.3 also solved the issue for me.

@dirkoswanepoel
Copy link

Unfortunately the Xcode 10.2 simulators don't work with cocoapods 1.5.3 for me. The version of fourflusher used in cocoapods 1.5.3 doesn't support xcode 10.2. And I also get the same "Alamofire does not specify a Swift version and none of the targets" error with cocoapods 1.6.1.

@bpoplauschi
Copy link
Author

Same issue happens with CocoaPods 1.7.0.rc.1

@Unknoob
Copy link

Unknoob commented May 3, 2019

I was hoping CocoaPods 1.7.0 would fix this issue. Maybe the issue should be posted to the CocoaPods project?

@dirkoswanepoel
Copy link

Is there any workaround?

@Unknoob
Copy link

Unknoob commented May 7, 2019

Only thing that worked for me is using CocoaPods 1.5.3, which does not work with XCode 10.2.

@dirkoswanepoel
Copy link

dirkoswanepoel commented May 16, 2019

Has someone tried this on Cocoapods 1.7.0.rc.2

@Unknoob
Copy link

Unknoob commented May 20, 2019

Can confirm pre_compile hooks are not working on Cocoapods 1.7.0.rc.2 either.
😞

@Unknoob
Copy link

Unknoob commented May 20, 2019

I opened an issue on the Cocoapods repo and dnkoutso helped me find a fix. 🎉

Just add this to your Podfile:

pre_install do |installer|
    installer.analysis_result.specifications.each do |s|
      s.swift_version = '4.2' 
    end
end

It will modify the spec earlier and the compilation will work.

@dirkoswanepoel
Copy link

I’ve also found that the pre release version of Alamofire works. It includes the Swift version.

@bpoplauschi
Copy link
Author

Very nice @Unknoob - appreciate your solution

@bpoplauschi
Copy link
Author

Update and weird case: if anyone still sees the error after applying the fix above

[!] Unable to determine Swift version for the following pods:

- `POD_XXX` does not specify a Swift version and none of the targets (`targetname`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

it might be because they are only explicitly picking subspecs from a pod in their Podfile and this leads to installer.analysis_result.specifications not containing the target for the Pod.

Example

pod 'OHHTTPStubs/Swift', version
pod 'OHHTTPStubs/HTTPMessage', version
pod 'OHHTTPStubs/Mocktail', version

and the simple fix is just explicitly adding the pod without any subspec

pod 'OHHTTPStubs', version

@jlnr
Copy link

jlnr commented Jun 13, 2019

With CocoaPods 1.7.1, I had to update the workaround to use the new pluralized swift_versions attribute:

s.swift_versions << '4.2' if s.swift_versions.empty?

@bpoplauschi
Copy link
Author

Update for CocoaPods 1.9.1:

  • setting either s.swift_version or s.swift_versions doesn't entirely do the job, as apparently both will affect the value of the swift_versions array, but swift_version remains nil and fails
  • the only solution I could find was to use
target 'XXX' do
  current_target_definition.swift_version = '5.0'
end

That current_target_definition.swift_version gets picked up and set as the Swift version for those pods that are missing the swift_version.
I no longer need the pre_install hook.
See CocoaPods/CocoaPods#9799

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants