Skip to content

Commit b58e662

Browse files
authored
Support for release builds (#60)
* Support release builds * wip * wip
1 parent 2b3f81c commit b58e662

File tree

12 files changed

+222
-260
lines changed

12 files changed

+222
-260
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
name: MacOS
1818
runs-on: macOS-latest
1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Run tests
2222
run: make test
2323

2424
ubuntu:
2525
name: Ubuntu
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
2929
- name: Run tests
3030
run: make test-linux
3131

@@ -57,7 +57,7 @@ jobs:
5757
with:
5858
branch: swift-5.8.1-release
5959
tag: 5.8.1-RELEASE
60-
- uses: actions/checkout@v3
60+
- uses: actions/checkout@v4
6161
- name: Build
6262
run: swift build -c ${{ matrix.config }}
6363
- name: Run tests (debug only)
@@ -67,3 +67,19 @@ jobs:
6767
# that is generally available.
6868
if: ${{ matrix.config == 'debug' }}
6969
run: swift test
70+
71+
static-stdlib:
72+
name: Static standard library
73+
strategy:
74+
matrix:
75+
os: [ubuntu-20.04]
76+
runs-on: ${{ matrix.os }}
77+
steps:
78+
- uses: swift-actions/setup-swift@v1
79+
with:
80+
swift-version: '5.8.0'
81+
- name: Install dependencies
82+
run: sudo apt-get install -y libcurl4-openssl-dev
83+
- uses: actions/checkout@v4
84+
- name: Build for static-stdlib
85+
run: make build-for-static-stdlib

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ test-debug:
1414
test: test-debug
1515
@swift test -c release
1616

17+
test-linux: test-debug
18+
1719
test-linux: test
1820

1921
test-linux-docker:
@@ -36,6 +38,10 @@ test-linux-static-stdlib:
3638
swift:5.6.2-focal \
3739
bash -c "swift build -c release -Xswiftc -static-stdlib"
3840

41+
build-for-static-stdlib:
42+
@swift build -c debug --static-swift-stdlib
43+
@swift build -c release --static-swift-stdlib
44+
3945
format:
4046
@swift format \
4147
--ignore-unparsable-files \

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ import XCTestDynamicOverlay // ✅
4141

4242
…and your application or library will continue to compile just fine.
4343

44-
> ⚠️ Important: The dynamically loaded `XCTFail` is only available in `DEBUG` builds in order
45-
to prevent App Store rejections due to runtime loading of symbols.
46-
4744

4845
## Example
4946

Sources/XCTestDynamicOverlay/Internal/XCTCurrentTestCase.swift

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
#if DEBUG
2-
#if canImport(ObjectiveC)
3-
import Foundation
1+
#if canImport(ObjectiveC)
2+
import Foundation
43

5-
@_spi(CurrentTestCase) public var XCTCurrentTestCase: AnyObject? {
6-
guard
7-
let XCTestObservationCenter = NSClassFromString("XCTestObservationCenter"),
8-
let XCTestObservationCenter = XCTestObservationCenter as Any as? NSObjectProtocol,
9-
let shared = XCTestObservationCenter.perform(Selector(("sharedTestObservationCenter")))?
10-
.takeUnretainedValue(),
11-
let observers = shared.perform(Selector(("observers")))?
12-
.takeUnretainedValue() as? [AnyObject],
13-
let observer =
14-
observers
15-
.first(where: { NSStringFromClass(type(of: $0)) == "XCTestMisuseObserver" }),
16-
let currentTestCase = observer.perform(Selector(("currentTestCase")))?
17-
.takeUnretainedValue()
18-
else { return nil }
19-
return currentTestCase
20-
}
21-
#else
22-
@_spi(CurrentTestCase) public var XCTCurrentTestCase: AnyObject? {
23-
nil
24-
}
25-
#endif
4+
@_spi(CurrentTestCase) public var XCTCurrentTestCase: AnyObject? {
5+
guard
6+
let XCTestObservationCenter = NSClassFromString("XCTestObservationCenter"),
7+
let XCTestObservationCenter = XCTestObservationCenter as Any as? NSObjectProtocol,
8+
let shared = XCTestObservationCenter.perform(Selector(("sharedTestObservationCenter")))?
9+
.takeUnretainedValue(),
10+
let observers = shared.perform(Selector(("observers")))?
11+
.takeUnretainedValue() as? [AnyObject],
12+
let observer =
13+
observers
14+
.first(where: { NSStringFromClass(type(of: $0)) == "XCTestMisuseObserver" }),
15+
let currentTestCase = observer.perform(Selector(("currentTestCase")))?
16+
.takeUnretainedValue()
17+
else { return nil }
18+
return currentTestCase
19+
}
2620
#else
2721
@_spi(CurrentTestCase) public var XCTCurrentTestCase: AnyObject? {
2822
nil

Sources/XCTestDynamicOverlay/XCTExpectFailure.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
#if DEBUG && canImport(ObjectiveC)
3+
#if canImport(ObjectiveC)
44
/// Instructs the test to expect a failure in an upcoming assertion, with options to customize
55
/// expected failure checking and handling.
66
///

0 commit comments

Comments
 (0)