Building a package with --configuration release disables assertions in Swift code, but not in C/C++/ObjC.
The behaviour should be consistent across languages, and we should introduce a separate command-line option to explicitly control assertions for both swift and clang in release builds, since it is often useful to test in release+asserts.
$ swift test -c release
...
Assertion failed: (0 && "c assert"), function cFunc, file /private/tmp/asserts/Sources/casserts/casserts.c, line 5.
Exited with signal code 6
While in debug, assertions are enabled for both
$ swift test
...
Fatal error: swift assert: file asserts/asserts.swift, line 2
Exited with signal code 4
...
Assertion failed: (0 && "c assert"), function cFunc, file /private/tmp/asserts/Sources/casserts/casserts.c, line 5.
Exited with signal code 6
Attachment: Download
Environment
Swift 5.3, Xcode 12Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Package Manager | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 88f80158fc8eac071055b74bfae5d006Issue Description:
Building a package with
--configuration
release disables assertions in Swift code, but not in C/C++/ObjC.The behaviour should be consistent across languages, and we should introduce a separate command-line option to explicitly control assertions for both swift and clang in release builds, since it is often useful to test in release+asserts.
While in debug, assertions are enabled for both