CocoaPods / Rome

Makes it easy to build a list of frameworks.
MIT License
694 stars 64 forks source link

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

Open bpoplauschi opened 5 years ago

bpoplauschi commented 5 years ago

Report

What did you do?

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

```ruby
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 commented 5 years ago

I don think that is related with this project.

Thomvis commented 5 years ago

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

bpoplauschi commented 5 years ago

@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 commented 5 years ago

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

dirkoswanepoel commented 5 years ago

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 commented 5 years ago

Same issue happens with CocoaPods 1.7.0.rc.1

Unknoob commented 5 years ago

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

dirkoswanepoel commented 5 years ago

Is there any workaround?

Unknoob commented 5 years ago

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

dirkoswanepoel commented 5 years ago

Has someone tried this on Cocoapods 1.7.0.rc.2

Unknoob commented 5 years ago

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

Unknoob commented 5 years ago

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 commented 5 years ago

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

bpoplauschi commented 5 years ago

Very nice @Unknoob - appreciate your solution

bpoplauschi commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

Update for CocoaPods 1.9.1: