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

Xcode 15 supporting #25

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Example/.prefire.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test_configuration:
- target: PrefireExample
- test_file_path: PrefireExampleTests/PreviewTests.generated.swift
- simulator_device: "iPhone15,2"
- required_os: 16
- required_os: 17
10 changes: 5 additions & 5 deletions Example/PreFireExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
9735EE38289C5CF300309267 /* PrefireExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9735EE28289C5CF200309267 /* PrefireExampleApp.swift */; };
9735EE3C289C5CF300309267 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9735EE2A289C5CF300309267 /* Assets.xcassets */; };
9735EE49289C5F3A00309267 /* TestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9735EE48289C5F3A00309267 /* TestView.swift */; };
976559002977E56000352D54 /* PreviewTests.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 976558FF2977E56000352D54 /* PreviewTests.generated.swift */; };
9777F17528D0F4200072827B /* CicrleImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9777F17428D0F4200072827B /* CicrleImage.swift */; };
9779D5F428A3F13F0083DBD3 /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 9779D5F328A3F13F0083DBD3 /* SnapshotTesting */; };
97B1477828EA335A0014DEC5 /* AuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97B1477728EA335A0014DEC5 /* AuthView.swift */; };
Expand All @@ -35,7 +34,6 @@
9735EE2A289C5CF300309267 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9735EE2F289C5CF300309267 /* PrefireExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PrefireExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
9735EE48289C5F3A00309267 /* TestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestView.swift; sourceTree = "<group>"; };
976558FF2977E56000352D54 /* PreviewTests.generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreviewTests.generated.swift; sourceTree = "<group>"; };
9777F17428D0F4200072827B /* CicrleImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CicrleImage.swift; sourceTree = "<group>"; };
9779D5E628A3ECBA0083DBD3 /* PrefireExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PrefireExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
97AB804128D9F0DB00414704 /* Prefire */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Prefire; path = ..; sourceTree = "<group>"; };
Expand Down Expand Up @@ -117,7 +115,6 @@
9779D5E728A3ECBB0083DBD3 /* PrefireExampleTests */ = {
isa = PBXGroup;
children = (
976558FF2977E56000352D54 /* PreviewTests.generated.swift */,
);
path = PrefireExampleTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -185,7 +182,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1340;
LastUpgradeCheck = 1410;
LastUpgradeCheck = 1500;
TargetAttributes = {
9735EE2E289C5CF300309267 = {
CreatedOnToolsVersion = 13.4.1;
Expand Down Expand Up @@ -256,7 +253,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
976559002977E56000352D54 /* PreviewTests.generated.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -283,6 +279,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
Copy link
Contributor

Choose a reason for hiding this comment

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

is this a requirement to support? otherwise how do we get Xcode to pickup the generated PreviewTests in the build directory without creating a subclass:

final class MyPreviewTests: PreviewTests {

}

Copy link
Contributor

Choose a reason for hiding this comment

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

ah scratch that. it has picked it up

Copy link
Owner Author

Choose a reason for hiding this comment

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

is this a requirement to support? otherwise how do we get Xcode to pickup the generated PreviewTests in the build directory without creating a subclass:

final class MyPreviewTests: PreviewTests {

}

This is the easiest way to navigate to the generated tests that I have found. Of course, there is an option without creating a subclass - run the tests and then you can use them to go to the file.

Copy link
Owner Author

Choose a reason for hiding this comment

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

ah scratch that. it has picked it up

You're right

CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
Expand Down Expand Up @@ -316,6 +313,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -342,6 +340,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
Expand Down Expand Up @@ -375,6 +374,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "dc46eeb3928a75390651fac6c1ef7f93ad59a73b",
"version" : "1.11.1"
"revision" : "696b86a6d151578bca7c1a2a3ed419a5f834d40f",
"version" : "1.13.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
204 changes: 0 additions & 204 deletions Example/PrefireExampleTests/PreviewTests.generated.swift

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Plugins/PrefireTestsPlugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension PrefireTestsPlugin: XcodeBuildToolPlugin {
}

let testFilePath = configuration?.testFilePath.flatMap({ context.xcodeProject.directory.appending(subpath: $0).string })
?? "\(context.pluginWorkDirectory)/\(target.displayName)/PreviewTests.generated.swift"
?? "\(context.pluginWorkDirectory)/PreviewTests.generated.swift"

let templateFilePath = configuration?.templateFilePath.flatMap({ context.xcodeProject.directory.appending(subpath: $0).string })
?? executable.string.components(separatedBy: "Binaries").first! + "Templates/" + "PreviewTests.stencil"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ struct ContentView: View {
### **Snapshot tests**

Just run generated tests 🚀
And all tests will be generated in DerivedData.

<img src="https://i.postimg.cc/XNPVPL1G/Untitled-2.gif" width="300">

Plugin `PrefireTestsPlugin` will do everything for you 🛠️

For detailed instruction you can see [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing)
For detailed instruction you can see [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing) or examine an example project.

---

Expand Down Expand Up @@ -190,7 +191,7 @@ test_configuration:
- required_os: 16
```
- `target` - Your project Target for Snapshot tests. __Default__: _FirstTarget_
- `test_file_path` - Filepath to generated file. __Default__: _DeriveData_
- `test_file_path` - Filepath to generated file (⚠️ Not compatible with Xcode 15). __Default__: _DeriveData_
- `template_file_path` - Stencil file for generated file. Optional parameter. __Default__: _Templates/PreviewTests.stencil_ from the package
- `simulator_device` - Device for Snapshot testing. __Default__: _iPhone 14 Pro_
- `required_os` - iOS version for Snapshot testing. __Default__: _iOS 16_
Expand Down