Xcode 7.3 Unit Tests .xcdatamodel "cdtool cannot compile" - ios

I have experiencing really weird build error. It all builds well for a normal target but since an update to Xcode 7.3 the Tests target started throwing error
"cdtool cannot compile" on one of my model versions "CoreData 9.xcdatamodel"
during the build. The project builds and runs perfectly for a normal, non test target.
I checked in on different Macs and even on an external CI provider (bitrise.io) - the issues exists everywhere.

Related

Unit test not running on IOS swift 5

I'm implementing unit test in Xcode 13 (13A233). I wrote simple test but my xcode fails running test on this project. On other projects it's running fine. It produces an error
Assertions: System: Test runner never began executing tests after launching. If you believe this error represents a bug, please attach the result bundle at /Users/apple/Library/Developer/Xcode/DerivedData/MunchON-eeidlzwuounsfvbrmieuosqzpsih/Logs/Test/Test-MunchON (Staging)-2021.10.05_11-35-54-+0500.xcresult
I'm unable to resolve this issue. Other questions that i have checked already:
http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/
Xcode 4.2, can't run unit test
OCUnit tests not running / not being found
OCUnit test cases not running
Try deleting DerivedData
Open Xcode > Preferences > Locations
Click on the arrow to open DerivedData folder
Delete all from DerivedData folder
Reopen Xcode project
P.S. DerivedData contains cached data such that indexed files etc
FYI It is safe
I had a similar problem and solved it by checking the "Allow testing Host Application APIs" option in the test target.

XCode 12.5 w/ MacOS 11.3 - Fails to Archive: Illegal Instruction: 4

This question has been asked a few times in the past, but none of those answers seem to match what is currently going on.
I have an app (SwiftUI) that builds, runs, tests fine on simulators and devices. But when attempting to Archive for iOS and/or MacOS, the archiving fails with a vague error "Illegal instruction: 4". The compiler then lists a bunch of files and directories which offer no help.
ERROR MESSAGE SNIPPET:
CompileSwift normal arm64 (in target 'App Name' from project 'App Name')
...Lists a bunch of directories
error: Illegal instruction: 4 (in target 'App Name' from project 'App Name')
The weird thing is that prior to the XCode and MacOS update, this app will Archive fine. So I am left to assume something was deprecated in this latest release.
My question is: What are some debugging tools to help me start to find where in my code this may be happening? Why would the app build and run fine on simulators and devices but not Archive? makes no sense to me.
I did test this by attempting to Archive on another MacBook with MacOS 11.0.1 and XCode 12.2, and it Archives fine.. Although, this is really useless since you cant upload a binary compiled with an older version of XCode.. *I was able to upload the binary using the older Xcode version, not sure if it will let me release this, but I will try that for now.
I have considered deleting and reinstalling XCode, but I don't know if that would be a waste of time. Maybe something didn't update properly?
At a loss. Any insight is appreciated.
update
When I edit the scheme and change Archive from Release to Debug, it Archive's?!
What am I missing?
2nd update:
When changing the build settings, under the Project, Swift Compilier, Code Generation, Optimization level from Optimize for Speed -O to No Optimization -Onone, the app Archives with no issues.

Xcode 11.4 archive fails when building target dependency

I have a framework project which gets build using a shell script under Build Phase. It uses xcodebuild to do that.
Since I have updated the Xcode to 11.4, I am getting the following error when the consuming project tries to build the dependency for above framework( The same works fine when I build the framework on it's own).
unable to create directory '/Users/.../Library/Developer/Xcode/DerivedData/App-cnatioifembsmzdvoyyuogceigiw/Build/Intermediates.noindex/ArchiveIntermediates/AppName-Staging/BuildProductsPath/Debug-iphoneos/FrameworkName.framework' (in target 'TargetName' from project 'ProjectName')
I have checked the write permission on the directory. I have given full hard disk access to Xcode under Security and Privacy but it is still happening.
Any guidance will be appreciated.
Thanks in advance.

Jenkins build failed with Xcode if project have test cases

'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
In one post I found answer to set scheme flag, I made same like answer but didn't work for me.
My test cases are also successful in Xcode 11.x , iOS 13.x. tested in iPhone XR
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.
In jenkins, configuration was Release (by default) which was unnoticed by me, after replacing it to Debug my build is succeeded.
Reference Image:
Reference Doc:
https://plugins.jenkins.io/xcode-plugin/
Special thanks to Scriptable for giving time and efforts for solving the issue.

Xcode Server Bot Issue: warning. Build Service Error. Issue: archive at path 'some/path' is malformed

I'm using Cocoapods and KIF to run Continuous Integration on an Xcode server. I have successfully set this up for one project to report on each commit. I'm now using a second project and get the error:
Bot Issue: warning. Build Service Error.
Issue: archive at path '/Library/Developer/XcodeServer/Integrations/Integration-81d42936b22a04037fd4aebed1074e5e/Archive.xcarchive' is malformed.
Integration Number: 1.
Description: archive at path '/Library/Developer/XcodeServer/Integrations/Integration-81d42936b22a04037fd4aebed1074e5e/Archive.xcarchive' is malformed.
The tests passed when ran on the Xcode server machine using Xcode. I tried downloading Provisioning Profiles etc via Xcode but that didn't help. I deleted the Bot and created a new one but that also did't help.
Any help is welcome
At least in my case (and there may be multiple causes), this was caused by having "Skip Install" set on every target, which causes you to end up with an empty archive (but only on Xcode Server).
Basically, xcodebuild (the command-line tool) has lots of critical differences from Xcode in the way it handles archiving. It builds targets that aren't listed in the scheme, and it obeys the Skip Archive flag even for targets listed in the scheme. By contrast, when building locally, Xcode ignores the Skip Archive flag and archives any targets in the scheme (and only the targets listed in the scheme).
I would encourage you to file a bug every time you run into situations where a project builds locally but fails on the server. If everyone did this, perhaps these differences would eventually get fixed....

Resources