Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building tests in Xcode #4607

Merged
merged 4 commits into from
Nov 30, 2022

Conversation

ryanaveo
Copy link
Contributor

Fix #4606

SwiftLintTestHelpers is a testTarget in order to use @testable imports for SwiftLintFramework, which had previously failed to compile for release when the target was declared as a regular target with the following error:

> swift build -c release

error: module 'SwiftLintFramework' was not compiled for testing
@testable import SwiftLintFramework

However, this breaks building/testing the target in Xcode with the following error:

Unable to resolve build file: XCBCore.BuildFile (The workspace has a reference to a missing target with GUID 'PACKAGE-TARGET:SwiftLintTestHelpers')

In order for SwiftLintTestHelpers to use internal symbols in SwiftLintFramework without using @testable import, we use @_spi imports instead. This fixes the issues when building on Xcode and for release.

Test Plan

  • swift build -c release
Compiling plugin Generate Manual...
Compiling plugin SwiftLintPlugin...
Building for production...
[32/32] Compiling SwiftLintTestHelpers RuleDescription+Examples.swift
Build complete! (225.61s)
  • Xcode builds successfully

Notes
Rule.swift needed to be broken into two files to pass the file length rule

@ryanaveo ryanaveo force-pushed the raveo-fix-xcode-building-on-0.50.1 branch from 8d089e8 to ae75fef Compare November 29, 2022 23:59
@SwiftLintBot
Copy link

SwiftLintBot commented Nov 30, 2022

1 Warning
⚠️ If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
18 Messages
📖 Linting Aerial with this PR took 1.2s vs 1.2s on main (0% slower)
📖 Linting Alamofire with this PR took 1.56s vs 1.58s on main (1% faster)
📖 Linting Brave with this PR took 8.21s vs 8.22s on main (0% faster)
📖 Linting DuckDuckGo with this PR took 3.16s vs 3.18s on main (0% faster)
📖 Linting Firefox with this PR took 10.15s vs 10.18s on main (0% faster)
📖 Linting Kickstarter with this PR took 11.21s vs 11.2s on main (0% slower)
📖 Linting Moya with this PR took 0.63s vs 0.64s on main (1% faster)
📖 Linting NetNewsWire with this PR took 3.53s vs 3.53s on main (0% slower)
📖 Linting Nimble with this PR took 0.69s vs 0.69s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.22s vs 8.22s on main (0% slower)
📖 Linting Quick with this PR took 0.25s vs 0.26s on main (3% faster)
📖 Linting Realm with this PR took 12.52s vs 12.55s on main (0% faster)
📖 Linting SourceKitten with this PR took 0.49s vs 0.49s on main (0% slower)
📖 Linting Sourcery with this PR took 2.59s vs 2.57s on main (0% slower)
📖 Linting Swift with this PR took 4.94s vs 4.92s on main (0% slower)
📖 Linting VLC with this PR took 1.42s vs 1.43s on main (0% faster)
📖 Linting Wire with this PR took 9.68s vs 9.63s on main (0% slower)
📖 Linting WordPress with this PR took 12.18s vs 12.21s on main (0% faster)

Here's an example of your CHANGELOG entry:

* Fix building tests in Xcode.  
  [ryanaveo](https://github.com/ryanaveo)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

@jpsim jpsim changed the title Fix unable to build/test project on Xcode on release 0.51.0 Fix building tests in Xcode Nov 30, 2022
Copy link
Collaborator

@jpsim jpsim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ryanaveo !

@jpsim jpsim merged commit 92304cd into realm:main Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to run unit tests in Xcode on release 0.50.1
3 participants