diff --git a/.gitignore b/.gitignore index cbd71e6..eaa8671 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ output/ *.xcarchive/ *.bc *.dia -_build/ \ No newline at end of file +_build/ +**/.build/* diff --git a/PBXProjParser/Sources/PBXProjParser/Workspace/Reference.swift b/PBXProjParser/Sources/PBXProjParser/Workspace/Reference.swift new file mode 100644 index 0000000..581c8a6 --- /dev/null +++ b/PBXProjParser/Sources/PBXProjParser/Workspace/Reference.swift @@ -0,0 +1,87 @@ +// +// Reference.swift +// +// +// Created by Thomas Hedderwick on 18/10/2023. +// +import Foundation + +protocol Reference { + var location: Location { get } + static var elementName: String { get } +} + +enum Location { + // TODO: Find where we can get a definitive list of these. Xcode must have them somewhere? + case container(String) + case group(String) + + enum Error: Swift.Error { + case invalidLocation(String) + } + + init(_ location: String) throws { + let split = location + .split(separator: ":", maxSplits: 1, omittingEmptySubsequences: false) + .map(String.init) + + guard + let key = split.first, + let value = split.last + else { throw Error.invalidLocation("Couldn't extract key/value pair from split: \(split)") } + + switch key { + case "container": self = .container(value) + case "group": self = .group(value) + default: throw Error.invalidLocation("Key didn't match a supported location key: \(key)") + } + } + + var path: String { + switch self { + case .container(let path): return path + case .group(let path): return path + } + } +} + +class Group: Reference { + static let elementName: String = "Group" + + let location: Location + let name: String? + var references: [Reference] = [] + + init(location: String, name: String?) throws { + self.location = try .init(location) + self.name = name + } +} + +struct FileRef: Reference { + static let elementName: String = "FileRef" + + let location: Location + let enclosingGroup: Group? + + init(location: String, enclosingGroup: Group? = nil) throws { + self.location = try .init(location) + self.enclosingGroup = enclosingGroup + } + + var path: String { + guard + let enclosingGroup + else { return location.path } + + switch enclosingGroup.location { + case let .group(path), let .container(path): + if path.last == "/" { + return path + location.path + } + + return path + "/" + location.path + // return URL(fileURLWithPath: path).appendingPathComponent(location.path).path + } + } +} diff --git a/PBXProjParser/Sources/PBXProjParser/Workspace/WorkspaceParser.swift b/PBXProjParser/Sources/PBXProjParser/Workspace/WorkspaceParser.swift new file mode 100644 index 0000000..4bca3fe --- /dev/null +++ b/PBXProjParser/Sources/PBXProjParser/Workspace/WorkspaceParser.swift @@ -0,0 +1,88 @@ +// +// WorkspaceParser.swift +// +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import Foundation + +struct Workspace { + private(set) var fileReferences: [FileRef] = [] + private(set) var groupReferences: [Group] = [] +} + +struct WorkspaceParser { + static func parse(_ path: URL) throws -> Workspace { + // Parse the `contents.xcworkspacedata` (XML) file and get the list of projects + let contentsPath = path.appendingPathComponent("contents.xcworkspacedata") + + let data = try Data(contentsOf: contentsPath) + let delegate = WorkspaceDataParserDelegate() + let parser = XMLParser(data: data) + parser.delegate = delegate + parser.parse() + + return .init( + fileReferences: delegate.fileReferences, + groupReferences: delegate.groupReferences + ) + } +} + +private class WorkspaceDataParserDelegate: NSObject, XMLParserDelegate { + private(set) var fileReferences: [FileRef] = [] + private(set) var groupReferences: [Group] = [] + + static let supportedElements = [Group.elementName, FileRef.elementName] + + private var groupPath: [Group] = [] + + func parser( + _ parser: XMLParser, + didStartElement elementName: String, + namespaceURI: String?, + qualifiedName qName: String?, + attributes attributeDict: [String: String] = [:] + ) { + guard Self.supportedElements.contains(elementName) else { + logger.debug("Skipping parsing of unsupported element: \(elementName)") + return + } + + guard + let location = attributeDict["location"] + else { + logger.debug("Location attribute for element \(elementName) is nil, this shouldn't be the case: \(attributeDict)") + return + } + + do { + switch elementName { + case Group.elementName: + let group = try Group(location: location, name: attributeDict["name"]) + groupPath.append(group) + groupReferences.append(group) + case FileRef.elementName: + let file = try FileRef(location: location, enclosingGroup: groupPath.last) + fileReferences.append(file) + groupPath.last?.references.append(file) + // Ignore any element that doesn't match the search space + default: + break + } + } catch { + logger.debug("Parsing element: \(elementName) failed. Reason: \(error)") + } + } + + func parser( + _ parser: XMLParser, + didEndElement elementName: String, + namespaceURI: String?, + qualifiedName qName: String? + ) { + guard elementName == Group.elementName else { return } + groupPath.removeLast() + } +} diff --git a/PBXProjParser/Sources/PBXProjParser/XcodeWorkspace.swift b/PBXProjParser/Sources/PBXProjParser/XcodeWorkspace.swift index 424da25..608dfea 100644 --- a/PBXProjParser/Sources/PBXProjParser/XcodeWorkspace.swift +++ b/PBXProjParser/Sources/PBXProjParser/XcodeWorkspace.swift @@ -23,13 +23,14 @@ class XcodeWorkspace { self.path = path // Parse the `contents.xcworkspacedata` (XML) file and get the list of projects - let contentsPath = path.appendingPathComponent("contents.xcworkspacedata") - - let data = try Data(contentsOf: contentsPath) - let parser = XCWorkspaceDataParser(data: data) + let workspace = try WorkspaceParser.parse(path) + let paths = workspace + .fileReferences + .map { $0.path } + .filter { $0.hasSuffix("xcodeproj") } let baseFolder = path.deletingLastPathComponent() - projectPaths = parser.projects + projectPaths = paths .map { baseFolder.appendingPathComponent($0, isDirectory: true) } projects = try projectPaths.map(XcodeProject.init(path:)) @@ -58,111 +59,3 @@ class XcodeWorkspace { projects.flatMap { $0.packages } } } - -// swiftlint:disable private_over_fileprivate -/// A xcworkspace parser -fileprivate class XCWorkspaceDataParser: NSObject, XMLParserDelegate { - let parser: XMLParser - var projects = [String]() - - var isInGroup = false - var currentGroupPath: [String] = [] - - let groupTag = "Group" - let fileRefTag = "FileRef" - - init(data: Data) { - parser = .init(data: data) - - super.init() - - parser.delegate = self - parser.parse() - } - - func parser( - _ parser: XMLParser, - didStartElement elementName: String, - namespaceURI: String?, - qualifiedName qName: String?, - attributes attributeDict: [String: String] = [:] - ) { - switch elementName { - case groupTag: - handleGroupTag(attributeDict) - case fileRefTag: - handleFileRefTag(attributeDict) - default: - break - } - } - - /// Returns the location attribute value from the provided attributes, if one exists - /// - Parameter attributeDict: the attribute dictionary to extract a location attribute from - /// - Returns: the path of the location attribute value - private func extractLocation(_ attributeDict: [String: String]) -> String? { - guard let location = attributeDict["location"] else { return nil } - - if location.starts(with: "group:") { - return location.replacingOccurrences(of: "group:", with: "") - } else if location.starts(with: "container:") { - let location = location.replacingOccurrences(of: "container:", with: "") - - if !location.isEmpty { return location } - - // Sometimes, location could be empty, in this case _normally_ you'll have a name attribute - return attributeDict["name"] - } - - return nil - } - - /// Handle a Group tag - /// - /// Group tags require additional logic - since they can contain nested child paths via either additional group tags or file ref tags. - /// Set a flag in this function that's handled in `handleFileRefTag(_:)` - /// - Parameter attributeDict: the attributes attached to this tag - private func handleGroupTag(_ attributeDict: [String: String]) { - // For groups, we want to track the 'sub' path as we go deeper into the tree, - // this will allow us to create 'full' paths as we see file refs - guard let location = extractLocation(attributeDict) else { return } - currentGroupPath.append(location) - isInGroup = true - } - - /// Handle a FileRef tag - /// - /// Since Group tags can build out parts of paths, we also handle cases where this file ref is part of a group structure. - /// - Parameter attributeDict: the attributes attached to this tag - private func handleFileRefTag(_ attributeDict: [String: String]) { - // For file refs, we have two options - if we're not in a group we can just use the path as-is. - // If we're in a group, we will need to construct the current path from the depth we're currently in - guard - let location = extractLocation(attributeDict), - location.hasSuffix(".xcodeproj") - else { return } - - if isInGroup { - // Add a '/' in between group subpaths, then add the current location to the end - let fullLocation = currentGroupPath.reduce(into: "") { $0.append($1); $0.append("/") }.appending(location) - projects.append(fullLocation) - } else { - projects.append(location) - } - } - - func parser( - _ parser: XMLParser, - didEndElement elementName: String, - namespaceURI: String?, - qualifiedName qName: String? - ) { - // If we're ending a group tag, we can pop the matching group off of the stack as we're done with it - guard elementName == groupTag else { return } - - _ = currentGroupPath.popLast() - - isInGroup = !currentGroupPath.isEmpty - } -} -// swiftlint:enable private_over_fileprivate diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo.xcodeproj/project.pbxproj b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..87f59e2 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo.xcodeproj/project.pbxproj @@ -0,0 +1,597 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + CEBFD7A82ADFE8D20047795C /* FooApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBFD7A72ADFE8D20047795C /* FooApp.swift */; }; + CEBFD7AA2ADFE8D20047795C /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBFD7A92ADFE8D20047795C /* ContentView.swift */; }; + CEBFD7AC2ADFE8D20047795C /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBFD7AB2ADFE8D20047795C /* Item.swift */; }; + CEBFD7AE2ADFE8D30047795C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CEBFD7AD2ADFE8D30047795C /* Assets.xcassets */; }; + CEBFD7B12ADFE8D30047795C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CEBFD7B02ADFE8D30047795C /* Preview Assets.xcassets */; }; + CEBFD7BB2ADFE8D30047795C /* FooTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBFD7BA2ADFE8D30047795C /* FooTests.swift */; }; + CEBFD7C52ADFE8D30047795C /* FooUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBFD7C42ADFE8D30047795C /* FooUITests.swift */; }; + CEBFD7C72ADFE8D30047795C /* FooUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBFD7C62ADFE8D30047795C /* FooUITestsLaunchTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + CEBFD7B72ADFE8D30047795C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CEBFD79C2ADFE8D20047795C /* Project object */; + proxyType = 1; + remoteGlobalIDString = CEBFD7A32ADFE8D20047795C; + remoteInfo = Foo; + }; + CEBFD7C12ADFE8D30047795C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CEBFD79C2ADFE8D20047795C /* Project object */; + proxyType = 1; + remoteGlobalIDString = CEBFD7A32ADFE8D20047795C; + remoteInfo = Foo; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + CEBFD7A42ADFE8D20047795C /* Foo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Foo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + CEBFD7A72ADFE8D20047795C /* FooApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooApp.swift; sourceTree = ""; }; + CEBFD7A92ADFE8D20047795C /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + CEBFD7AB2ADFE8D20047795C /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = ""; }; + CEBFD7AD2ADFE8D30047795C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + CEBFD7B02ADFE8D30047795C /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + CEBFD7B62ADFE8D30047795C /* FooTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FooTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + CEBFD7BA2ADFE8D30047795C /* FooTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooTests.swift; sourceTree = ""; }; + CEBFD7C02ADFE8D30047795C /* FooUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FooUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + CEBFD7C42ADFE8D30047795C /* FooUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooUITests.swift; sourceTree = ""; }; + CEBFD7C62ADFE8D30047795C /* FooUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FooUITestsLaunchTests.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + CEBFD7A12ADFE8D20047795C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CEBFD7B32ADFE8D30047795C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CEBFD7BD2ADFE8D30047795C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + CEBFD79B2ADFE8D20047795C = { + isa = PBXGroup; + children = ( + CEBFD7A62ADFE8D20047795C /* Foo */, + CEBFD7B92ADFE8D30047795C /* FooTests */, + CEBFD7C32ADFE8D30047795C /* FooUITests */, + CEBFD7A52ADFE8D20047795C /* Products */, + ); + sourceTree = ""; + }; + CEBFD7A52ADFE8D20047795C /* Products */ = { + isa = PBXGroup; + children = ( + CEBFD7A42ADFE8D20047795C /* Foo.app */, + CEBFD7B62ADFE8D30047795C /* FooTests.xctest */, + CEBFD7C02ADFE8D30047795C /* FooUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + CEBFD7A62ADFE8D20047795C /* Foo */ = { + isa = PBXGroup; + children = ( + CEBFD7A72ADFE8D20047795C /* FooApp.swift */, + CEBFD7A92ADFE8D20047795C /* ContentView.swift */, + CEBFD7AB2ADFE8D20047795C /* Item.swift */, + CEBFD7AD2ADFE8D30047795C /* Assets.xcassets */, + CEBFD7AF2ADFE8D30047795C /* Preview Content */, + ); + path = Foo; + sourceTree = ""; + }; + CEBFD7AF2ADFE8D30047795C /* Preview Content */ = { + isa = PBXGroup; + children = ( + CEBFD7B02ADFE8D30047795C /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + CEBFD7B92ADFE8D30047795C /* FooTests */ = { + isa = PBXGroup; + children = ( + CEBFD7BA2ADFE8D30047795C /* FooTests.swift */, + ); + path = FooTests; + sourceTree = ""; + }; + CEBFD7C32ADFE8D30047795C /* FooUITests */ = { + isa = PBXGroup; + children = ( + CEBFD7C42ADFE8D30047795C /* FooUITests.swift */, + CEBFD7C62ADFE8D30047795C /* FooUITestsLaunchTests.swift */, + ); + path = FooUITests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + CEBFD7A32ADFE8D20047795C /* Foo */ = { + isa = PBXNativeTarget; + buildConfigurationList = CEBFD7CA2ADFE8D30047795C /* Build configuration list for PBXNativeTarget "Foo" */; + buildPhases = ( + CEBFD7A02ADFE8D20047795C /* Sources */, + CEBFD7A12ADFE8D20047795C /* Frameworks */, + CEBFD7A22ADFE8D20047795C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Foo; + productName = Foo; + productReference = CEBFD7A42ADFE8D20047795C /* Foo.app */; + productType = "com.apple.product-type.application"; + }; + CEBFD7B52ADFE8D30047795C /* FooTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = CEBFD7CD2ADFE8D30047795C /* Build configuration list for PBXNativeTarget "FooTests" */; + buildPhases = ( + CEBFD7B22ADFE8D30047795C /* Sources */, + CEBFD7B32ADFE8D30047795C /* Frameworks */, + CEBFD7B42ADFE8D30047795C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + CEBFD7B82ADFE8D30047795C /* PBXTargetDependency */, + ); + name = FooTests; + productName = FooTests; + productReference = CEBFD7B62ADFE8D30047795C /* FooTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + CEBFD7BF2ADFE8D30047795C /* FooUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = CEBFD7D02ADFE8D30047795C /* Build configuration list for PBXNativeTarget "FooUITests" */; + buildPhases = ( + CEBFD7BC2ADFE8D30047795C /* Sources */, + CEBFD7BD2ADFE8D30047795C /* Frameworks */, + CEBFD7BE2ADFE8D30047795C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + CEBFD7C22ADFE8D30047795C /* PBXTargetDependency */, + ); + name = FooUITests; + productName = FooUITests; + productReference = CEBFD7C02ADFE8D30047795C /* FooUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + CEBFD79C2ADFE8D20047795C /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1500; + LastUpgradeCheck = 1500; + TargetAttributes = { + CEBFD7A32ADFE8D20047795C = { + CreatedOnToolsVersion = 15.0; + }; + CEBFD7B52ADFE8D30047795C = { + CreatedOnToolsVersion = 15.0; + TestTargetID = CEBFD7A32ADFE8D20047795C; + }; + CEBFD7BF2ADFE8D30047795C = { + CreatedOnToolsVersion = 15.0; + TestTargetID = CEBFD7A32ADFE8D20047795C; + }; + }; + }; + buildConfigurationList = CEBFD79F2ADFE8D20047795C /* Build configuration list for PBXProject "Foo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = CEBFD79B2ADFE8D20047795C; + productRefGroup = CEBFD7A52ADFE8D20047795C /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + CEBFD7A32ADFE8D20047795C /* Foo */, + CEBFD7B52ADFE8D30047795C /* FooTests */, + CEBFD7BF2ADFE8D30047795C /* FooUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + CEBFD7A22ADFE8D20047795C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CEBFD7B12ADFE8D30047795C /* Preview Assets.xcassets in Resources */, + CEBFD7AE2ADFE8D30047795C /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CEBFD7B42ADFE8D30047795C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CEBFD7BE2ADFE8D30047795C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + CEBFD7A02ADFE8D20047795C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CEBFD7AA2ADFE8D20047795C /* ContentView.swift in Sources */, + CEBFD7AC2ADFE8D20047795C /* Item.swift in Sources */, + CEBFD7A82ADFE8D20047795C /* FooApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CEBFD7B22ADFE8D30047795C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CEBFD7BB2ADFE8D30047795C /* FooTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CEBFD7BC2ADFE8D30047795C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CEBFD7C52ADFE8D30047795C /* FooUITests.swift in Sources */, + CEBFD7C72ADFE8D30047795C /* FooUITestsLaunchTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + CEBFD7B82ADFE8D30047795C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = CEBFD7A32ADFE8D20047795C /* Foo */; + targetProxy = CEBFD7B72ADFE8D30047795C /* PBXContainerItemProxy */; + }; + CEBFD7C22ADFE8D30047795C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = CEBFD7A32ADFE8D20047795C /* Foo */; + targetProxy = CEBFD7C12ADFE8D30047795C /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + CEBFD7C82ADFE8D30047795C /* Debug */ = { + 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++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + CEBFD7C92ADFE8D30047795C /* Release */ = { + 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++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + CEBFD7CB2ADFE8D30047795C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Foo/Preview Content\""; + DEVELOPMENT_TEAM = ""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = kim.cracksby.Foo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + CEBFD7CC2ADFE8D30047795C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Foo/Preview Content\""; + DEVELOPMENT_TEAM = ""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = kim.cracksby.Foo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + CEBFD7CE2ADFE8D30047795C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = kim.cracksby.FooTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Foo.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Foo"; + }; + name = Debug; + }; + CEBFD7CF2ADFE8D30047795C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = kim.cracksby.FooTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Foo.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Foo"; + }; + name = Release; + }; + CEBFD7D12ADFE8D30047795C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = kim.cracksby.FooUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Foo; + }; + name = Debug; + }; + CEBFD7D22ADFE8D30047795C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = kim.cracksby.FooUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = Foo; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + CEBFD79F2ADFE8D20047795C /* Build configuration list for PBXProject "Foo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CEBFD7C82ADFE8D30047795C /* Debug */, + CEBFD7C92ADFE8D30047795C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CEBFD7CA2ADFE8D30047795C /* Build configuration list for PBXNativeTarget "Foo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CEBFD7CB2ADFE8D30047795C /* Debug */, + CEBFD7CC2ADFE8D30047795C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CEBFD7CD2ADFE8D30047795C /* Build configuration list for PBXNativeTarget "FooTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CEBFD7CE2ADFE8D30047795C /* Debug */, + CEBFD7CF2ADFE8D30047795C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + CEBFD7D02ADFE8D30047795C /* Build configuration list for PBXNativeTarget "FooUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CEBFD7D12ADFE8D30047795C /* Debug */, + CEBFD7D22ADFE8D30047795C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = CEBFD79C2ADFE8D20047795C /* Project object */; +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/AccentColor.colorset/Contents.json b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/AppIcon.appiconset/Contents.json b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/Contents.json b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/ContentView.swift b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/ContentView.swift new file mode 100644 index 0000000..ef2e2eb --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/ContentView.swift @@ -0,0 +1,61 @@ +// +// ContentView.swift +// Foo +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import SwiftUI +import SwiftData + +struct ContentView: View { + @Environment(\.modelContext) private var modelContext + @Query private var items: [Item] + + var body: some View { + NavigationSplitView { + List { + ForEach(items) { item in + NavigationLink { + Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") + } label: { + Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) + } + } + .onDelete(perform: deleteItems) + } + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + EditButton() + } + ToolbarItem { + Button(action: addItem) { + Label("Add Item", systemImage: "plus") + } + } + } + } detail: { + Text("Select an item") + } + } + + private func addItem() { + withAnimation { + let newItem = Item(timestamp: Date()) + modelContext.insert(newItem) + } + } + + private func deleteItems(offsets: IndexSet) { + withAnimation { + for index in offsets { + modelContext.delete(items[index]) + } + } + } +} + +#Preview { + ContentView() + .modelContainer(for: Item.self, inMemory: true) +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/FooApp.swift b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/FooApp.swift new file mode 100644 index 0000000..f286f8b --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/FooApp.swift @@ -0,0 +1,32 @@ +// +// FooApp.swift +// Foo +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import SwiftUI +import SwiftData + +@main +struct FooApp: App { + var sharedModelContainer: ModelContainer = { + let schema = Schema([ + Item.self, + ]) + let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) + + do { + return try ModelContainer(for: schema, configurations: [modelConfiguration]) + } catch { + fatalError("Could not create ModelContainer: \(error)") + } + }() + + var body: some Scene { + WindowGroup { + ContentView() + } + .modelContainer(sharedModelContainer) + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Item.swift b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Item.swift new file mode 100644 index 0000000..3c8ac24 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Item.swift @@ -0,0 +1,18 @@ +// +// Item.swift +// Foo +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import Foundation +import SwiftData + +@Model +final class Item { + var timestamp: Date + + init(timestamp: Date) { + self.timestamp = timestamp + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Preview Content/Preview Assets.xcassets/Contents.json b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/Foo/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooTests/FooTests.swift b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooTests/FooTests.swift new file mode 100644 index 0000000..43b97f8 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooTests/FooTests.swift @@ -0,0 +1,36 @@ +// +// FooTests.swift +// FooTests +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import XCTest +@testable import Foo + +final class FooTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + // Any test you write for XCTest can be annotated as throws and async. + // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooUITests/FooUITests.swift b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooUITests/FooUITests.swift new file mode 100644 index 0000000..b90a9c4 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooUITests/FooUITests.swift @@ -0,0 +1,41 @@ +// +// FooUITests.swift +// FooUITests +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import XCTest + +final class FooUITests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testLaunchPerformance() throws { + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { + // This measures how long it takes to launch your application. + measure(metrics: [XCTApplicationLaunchMetric()]) { + XCUIApplication().launch() + } + } + } +} diff --git a/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooUITests/FooUITestsLaunchTests.swift b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooUITests/FooUITestsLaunchTests.swift new file mode 100644 index 0000000..57f906b --- /dev/null +++ b/TestAssets/WeirdContainerPaths/Infrastructure/Foo/FooUITests/FooUITestsLaunchTests.swift @@ -0,0 +1,32 @@ +// +// FooUITestsLaunchTests.swift +// FooUITests +// +// Created by Thomas Hedderwick on 18/10/2023. +// + +import XCTest + +final class FooUITestsLaunchTests: XCTestCase { + + override class var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + + override func setUpWithError() throws { + continueAfterFailure = false + } + + func testLaunch() throws { + let app = XCUIApplication() + app.launch() + + // Insert steps here to perform after app launch but before taking a screenshot, + // such as logging into a test account or navigating somewhere in the app + + let attachment = XCTAttachment(screenshot: app.screenshot()) + attachment.name = "Launch Screen" + attachment.lifetime = .keepAlways + add(attachment) + } +} diff --git a/TestAssets/WeirdContainerPaths/WeirdWorkspace.xcworkspace/contents.xcworkspacedata b/TestAssets/WeirdContainerPaths/WeirdWorkspace.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..5247277 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/WeirdWorkspace.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/TestAssets/WeirdContainerPaths/WeirdWorkspace.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/TestAssets/WeirdContainerPaths/WeirdWorkspace.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/TestAssets/WeirdContainerPaths/WeirdWorkspace.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +