forked from tuist/tuist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tests crashing when accessing SPM dependency resource bundle (tui…
…st#6895) * Adds the base sample project * Adds tests to demonstrate the problem * Tweaks the ResourcesProjectMapper Removes the perhaps unnecessary BuildAcceptanceTest I added? * Runs lint-fix * Adds an install command before testing * Reverts the changes from tuist#6865 * Re-runs lint fix * Revert "Reverts the changes from tuist#6865" This reverts commit 08cc4d1. * Gates the bundle resource fix behind an #if canImport(XCTest) compiler directive. * Empty commit to re-attempt CI, which failed to install Mise * Runs mise lint again * Adds extended comment with link to PR
- Loading branch information
Showing
11 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import ProjectDescription | ||
|
||
let project = Project( | ||
name: "Feature", | ||
targets: [ | ||
.target( | ||
name: "Feature", | ||
destinations: .iOS, | ||
product: .framework, | ||
bundleId: "io.tuist.app", | ||
deploymentTargets: .iOS("16.0"), | ||
infoPlist: .default, | ||
sources: "Sources/**", | ||
dependencies: [ | ||
.project(target: "SharedUI", path: "../SharedUI"), | ||
] | ||
), | ||
.target( | ||
name: "FeatureTests", | ||
destinations: .iOS, | ||
product: .unitTests, | ||
bundleId: "io.tuist.app.tests", | ||
deploymentTargets: .iOS("16.0"), | ||
infoPlist: .default, | ||
sources: "Tests/**", | ||
dependencies: [ | ||
.target(name: "Feature"), | ||
] | ||
), | ||
] | ||
) |
22 changes: 22 additions & 0 deletions
22
fixtures/framework_with_spm_bundle/Feature/Sources/FeatureView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import SharedUI | ||
import UIKit | ||
|
||
public final class FeatureView: UIView { | ||
let textField = PaymentTextField() | ||
|
||
override public init(frame: CGRect) { | ||
super.init(frame: frame) | ||
addSubview(textField) | ||
NSLayoutConstraint.activate([ | ||
textField.topAnchor.constraint(equalTo: topAnchor), | ||
textField.leadingAnchor.constraint(equalTo: leadingAnchor), | ||
textField.trailingAnchor.constraint(equalTo: trailingAnchor), | ||
textField.bottomAnchor.constraint(equalTo: bottomAnchor), | ||
]) | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
fixtures/framework_with_spm_bundle/Feature/Tests/FeatureViewTest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Feature | ||
import XCTest | ||
|
||
final class FeatureViewTest: XCTestCase { | ||
func testFeatureView() { | ||
let view = FeatureView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import ProjectDescription | ||
|
||
let project = Project( | ||
name: "SharedUI", | ||
targets: [ | ||
.target( | ||
name: "SharedUI", | ||
destinations: .iOS, | ||
product: .framework, | ||
bundleId: "io.tuist.app", | ||
deploymentTargets: .iOS("16.0"), | ||
infoPlist: .default, | ||
sources: "Sources/**", | ||
dependencies: [ | ||
.external(name: "Stripe"), | ||
] | ||
), | ||
] | ||
) |
25 changes: 25 additions & 0 deletions
25
fixtures/framework_with_spm_bundle/SharedUI/Sources/PaymentTextField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import StripePaymentsUI | ||
import SwiftUI | ||
import UIKit | ||
|
||
public final class PaymentTextField: STPPaymentCardTextField, STPPaymentCardTextFieldDelegate { | ||
public init() { | ||
super.init(frame: .zero) | ||
delegate = self | ||
} | ||
|
||
@available(*, unavailable) | ||
public required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} | ||
|
||
public struct PaymentTextFieldRepresentable: UIViewRepresentable { | ||
public init() {} | ||
|
||
public func makeUIView(context _: Context) -> PaymentTextField { | ||
.init() | ||
} | ||
|
||
public func updateUIView(_: PaymentTextField, context _: Context) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"originHash" : "b9f3c72bc0a4f32d237e8fe5b2a237ffccde38f6008fc2a64058af8cbf83bf5f", | ||
"pins" : [ | ||
{ | ||
"identity" : "stripe-ios-spm", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/stripe/stripe-ios-spm", | ||
"state" : { | ||
"revision" : "87b6850b5e6a9a6767c5ed4c43c8a84e2191d65f", | ||
"version" : "23.27.3" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// swift-tools-version: 5.10 | ||
@preconcurrency import PackageDescription | ||
|
||
let package = Package( | ||
name: "PackageName", | ||
dependencies: [ | ||
.package(url: "https://github.com/stripe/stripe-ios-spm", exact: "23.27.3"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import ProjectDescription | ||
|
||
let workspace = Workspace( | ||
name: "Workspace", | ||
projects: ["SharedUI", "Feature"] | ||
) |