evgenyneu / Cosmos

A star rating control for iOS/tvOS written in Swift
MIT License
2.19k stars 368 forks source link

Fix to support iOS7 #28

Closed acecilia closed 8 years ago

evgenyneu commented 8 years ago

Hi, @acecilia. Thank you very much for this fix. I applied it in a separate branch called ios-7-support. Users who need to support iOS 7 will be able to use a CosmosDistrib.swift file. I have also added a note in the readme.

evgenyneu commented 8 years ago

Here are the instructions for the iOS 7 setup method: https://github.com/marketplacer/Cosmos/wiki/iOS-7-support

acecilia commented 8 years ago

Nice! And one question ;P Why do you maintain the source code and an extra file like CosmosDistrib.swift? Why don't just download the source code (with the separated files)? Thats what I am doing using cocoaseeds

And another question (that maybe needs an issue): when I add any IBDesignable to my storyboard, interface builder builds just my main target (not the tests targets). But After adding Cosmos, Interface Builder builds my main target, and also unity tests and UI tests. Do you know why? The only solution I found to avoid this is to remove the tests targets from my project (not nice)

acecilia commented 8 years ago

Ok, still do not know why adding the source code of Cosmos to my ios7 project was making interface builder to run test targets when using IBDesignables, but I resolved it by removing cosmos files from the "Compile sources" section in my test targets (inside project -> Build Phases).

evgenyneu commented 8 years ago

Hi @acecilia, you are of course right, you can include the original separate files from the library, it will work just as well. The reason I distribute the library in form of one file is for those people who just want to quickly copy/paste it in their project and try. The CosmosDistrib.swift is compiled automatically from multiple source files each time I change anything.

Thanks for educating me about the cocoaseeds, I did not know about it.

I did not quite understand your question about the test targets. Can you explain step by step how you added the Cosmos to your project so I can reproduce the problem locally?

Cheers.

acecilia commented 8 years ago

Sure. First I added this line to my seedsfile: github "marketplacer/Cosmos", "ios-7-support", :files => "Cosmos/**/*.swift"

Then I updated the seeds with seed install (similar to pod install). After that I created a view in my storyboard and added the CosmosView class. Then I clicked on Editor->Refresh all views.

The result was that interface builder was building the project and also the unity and UI tests. Without using the CosmosView in the storyboard it is just building the project target, not the tests targets (the right thing, why do we need tests at this point??). To avoid building the tests I removed the cosmos files from the "Compile sources" section in my test targets (inside project -> Build Phases). I think they where added there automatically when seed install. Anyway, dont worry too much because this cocoaseeds and ios7 support is really tricky and strange things are happening all the time ;P

Thanks for your support!

evgenyneu commented 8 years ago

Hi @acecilia, I followed your instructions with cocoaseeds and got the same problem. You are right, for some reason cocoaseeds included all the Cosmos source files into the test targets. I would suggest creating an issue ticket for the cocoaseeds project because it may cause problems for other people. Thanks again for your contribution and good luck.