Added test_spec section for pod so that unit tests will be run as part of pod lib lint. However although the pod supports iOS, tvOS, macOS and watchOS the unit tests don't run for WatchOS due to testing limitations on that platform. I can't figure out how to stop tests being applied for watchOS which causes a failure due to unit testing support mentioned.
Sketch of Podspec to highlight what I've tried
Pod::Spec.new do |s|
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.10"
s.watchos.deployment_target = "2.0"
s.tvos.deployment_target = "9.0"
s.source_files = 'Source/*.{m,swift,h}'
# This was first try, which lead to initial problem
s.test_spec 'Unit-Test' do |t|
t.source_files = 'Tests/*.{m,swift,h}'
t.dependency 'Quick'
t.dependency 'Nimble'
end
# Tried this but seems to inherit watchOS deployment_target
s.test_spec 'Unit-Test' do |t|
t.ios.deployment_target = "9.0"
t.osx.deployment_target = "10.10"
t.tvos.deployment_target = "9.0"
t.source_files = 'Tests/*.{m,swift,h}'
t.dependency 'Quick'
t.dependency 'Nimble'
end
# Tried this but seems test_spec can't be tied to platform like this, gives error:
# [!] Invalid `MyLib.podspec` file: undefined method `test_spec' for #<Pod::Specification::DSL::PlatformProxy:0x007fe29f19d640>.
s.ios.test_spec 'Unit-Test' do |t|
t.ios.deployment_target = "9.0"
t.source_files = 'Tests/*.{m,swift,h}'
t.dependency 'Quick'
t.dependency 'Nimble'
end
# Tried this which parses but during build get error:
# - ERROR | [OSX] unknown: Encountered an unknown error (The platform of the target `App` (macOS 10.10) is not compatible with `MyLib/Unit-Test-iOS (0.9.2)`, which does not support `osx`.
s.test_spec 'Unit-Test-iOS' do |t|
t.platform = :ios, "9.0"
t.source_files = 'Tests/*.{m,swift,h}'
t.dependency 'Quick'
t.dependency 'Nimble'
end
end
Any suggestions on how to achieve this?
Thanks
Mark
Hm thanks for the report, that might be true so far because test specs are just like subspecs.
Have you tried t.ios.source_files in the test_spec or t.osx.source_files instead?
You can also prefix dependencies with t.ios.dependency and t.osx.dependency etc.
Have the same problem, t.ios.source_files doesn't make a difference. the validator should probably just skip tests for watchos.
@jberkel you can also use --skip-tests if its blocking you from publishing.
@dnkoutso ok. i've actually implemented a test running validator a while ago, just trying to get rid of the custom code and ran into this. it's good that specs now are fully supported.
👌 will need to investigate this further. There are plenty of bug fixes going in to test specs for 1.4.0.
@dnkoutso pod trunk push doesn't seem to accept --skip-tests, manually commenting out the code for now
@jberkel it was added https://github.com/CocoaPods/cocoapods-trunk/pull/93.
Maybe it was not released?
@dnkoutso Looks like it hasn't been. I'll do a release this weekend.
This is out in cocoapods-trunk 1.3.0 https://rubygems.org/gems/cocoapods-trunk/versions/1.3.0
@DanToml thanks! this issue should probably be kept open, though.
@jberkel You are correct, I didn't read the original issue properly 👍
Will investigate this now for 1.4.0.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:
still need to verify this, probably going for 1.5.0.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Keep open.
Voting for this bug; it is really frustrating. Let me know if this is the best way to say "me too" ;)
@icecrystal23 using Github's reactions on the original issue submission is also a great way to upvote something :)
@mwoollard do you remember if your issue only had to deal with lint?
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:
@amorde any reason for re-open? I think this can be closed due to inactivity and because the PR probably handles this.
ah totally missed that PR when I checked this - my bad 👍
If I have a Podspec that supports all 4 Apple platforms, when I add test_spec it generates unit test target for 'watchOS' as well, despite it is not supported and isn't working if try to run tests. it's not a big deal so far, but just wondering — Is it considered to be OK or is it going to be fixed in future releases? Thanks!
The fix they accepted from me only fixes it if you specify platforms specifically for the test spec, like this example in the original bug post. It will be available in the next release of 1.6.0 (beta2 or actual).
s.test_spec 'Unit-Test-iOS' do |t|
t.platform = :ios, "9.0"
t.source_files = 'Tests/*.{m,swift,h}'
t.dependency 'Quick'
t.dependency 'Nimble'
end
Most helpful comment
Voting for this bug; it is really frustrating. Let me know if this is the best way to say "me too" ;)