1

'Module was not compiled for testing' when using @testable does not resolve this post issue.


I am integrating Xcode project with CI/CD by using jenkins and fastlane. My Xcode project build success if project do not have test cases. If I added my test cases then xcode build failed in jenkins with error:

error: module 'JenkinsFastlaneExample' was not compiled for testing

ScreenShot of error

enter image description here


In one post I found answer to set scheme flag, I made same like answer but didn't work for me.

enter image description here

enter image description here


My test cases are also successful in Xcode 11.x , iOS 13.x. tested in iPhone XR

enter image description here


I unable to find out why jenkins build is failed.

Demo Repo (if needed) : https://github.com/thedahiyaboy/ios_jenkins_example


Edit:

I also tried to disable my test cases from Xcode so that I can run my cases from mac system only and with hope jenkins will skip test bundles, but getting the same issue.

Community
  • 1
  • 1
dahiya_boy
  • 9,298
  • 1
  • 30
  • 51
  • looks like your tests aren't compiling (maybe), can you run them locally? – Scriptable Mar 17 '20 at 09:36
  • @Scriptable Yes, It is successfull in local xcode. I added screenshot for the same. – dahiya_boy Mar 17 '20 at 09:37
  • do you have a .gitignore file? – Scriptable Mar 17 '20 at 11:22
  • @Scriptable Yes I have. I had selected default `.gitignore` from the github for swift project. – dahiya_boy Mar 17 '20 at 11:26
  • Theres a possibility (if i remember rightly) that your test scheme definition is being ignored by git. remove the line in the .gitignore that contains xcshareddata. do `git add .`, commit and push. then try – Scriptable Mar 17 '20 at 11:30
  • @Scriptable My `.gitiginore` file does not have `xcshareddata`. [My project gitignore file](https://github.com/thedahiyaboy/ios_jenkins_example/blob/master/.gitignore). Still if you wanted me to check after removing gitignore file completely, then i love to do so. – dahiya_boy Mar 17 '20 at 11:36
  • your .gitingore file looks fine. there are some tips in another thread I will link now – Scriptable Mar 17 '20 at 11:51
  • Does this answer your question? ['Module was not compiled for testing' when using @testable](https://stackoverflow.com/questions/30787674/module-was-not-compiled-for-testing-when-using-testable) – Scriptable Mar 17 '20 at 11:52
  • @Scriptable I already been gone through this link (already mentioned in question) but didn't helped me. you can check same just below the error screenshot. – dahiya_boy Mar 17 '20 at 12:04
  • What command you using to run the unit tests? – Scriptable Mar 17 '20 at 12:59
  • @Scriptable Issue was in Jenkins config which was unnoticed by me and even Jenkins console error misleads me to the XCode project. Thanks for giving your time and effort for me. – dahiya_boy Mar 17 '20 at 13:17

1 Answers1

1

In jenkins, configuration was Release (by default) which was unnoticed by me, after replacing it to Debug my build is succeeded.

Reference Image:

enter image description here

Reference Doc:

https://plugins.jenkins.io/xcode-plugin/


Special thanks to Scriptable for giving time and efforts for solving the issue.

dahiya_boy
  • 9,298
  • 1
  • 30
  • 51