Skip to content

Commit

Permalink
#51: [refactor] Now trying to get the SwiftUIDiscogs target to compile.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtibbetts committed Aug 14, 2022
1 parent 3c91134 commit 67390bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
20 changes: 20 additions & 0 deletions SwiftDiscogs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
969FBD4A207AB29300C32471 /* DiscogsArtistView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969FBD49207AB29300C32471 /* DiscogsArtistView.swift */; };
96A8AC9F219214EE0098BF87 /* Discogs.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96A8ACA1219214EE0098BF87 /* Discogs.strings */; };
96BA81C8225C1ED50003D65C /* DiscogsDisambiguationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BA81C7225C1ED50003D65C /* DiscogsDisambiguationViewController.swift */; };
96BB31C628A8A5B900564F6C /* Medi8 in Frameworks */ = {isa = PBXBuildFile; productRef = 96BB31C528A8A5B900564F6C /* Medi8 */; };
96BB31C828A8A5BD00564F6C /* JSONClient in Frameworks */ = {isa = PBXBuildFile; productRef = 96BB31C728A8A5BD00564F6C /* JSONClient */; };
96BB37FF2251139500806E56 /* ArtistsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BB37FE2251139500806E56 /* ArtistsViewController.swift */; };
96BB380422545AA200806E56 /* MediaLibrary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BB380322545AA200806E56 /* MediaLibrary.swift */; };
96C656B12129204A0041CAD6 /* Discogs.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96C656B0212920490041CAD6 /* Discogs.xcassets */; };
Expand Down Expand Up @@ -557,7 +559,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96BB31C628A8A5B900564F6C /* Medi8 in Frameworks */,
96E7CE4125EB646400EBC43E /* SwiftDiscogs.framework in Frameworks */,
96BB31C828A8A5BD00564F6C /* JSONClient in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1244,6 +1248,10 @@
96E7CE4425EB646400EBC43E /* PBXTargetDependency */,
);
name = SwiftUIDiscogs;
packageProductDependencies = (
96BB31C528A8A5B900564F6C /* Medi8 */,
96BB31C728A8A5BD00564F6C /* JSONClient */,
);
productName = SwiftUIDiscogs;
productReference = 96D5B6E32497361200B555AC /* SwiftUIDiscogs.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -2172,6 +2180,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"SwiftUIDiscogs/Preview Content\"";
DEVELOPMENT_TEAM = 3MY7LL9G36;
ENABLE_PREVIEWS = YES;
Expand All @@ -2197,6 +2206,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"SwiftUIDiscogs/Preview Content\"";
DEVELOPMENT_TEAM = 3MY7LL9G36;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -2427,6 +2437,16 @@
package = 969EBFB725EA2FD00008DE91 /* XCRemoteSwiftPackageReference "JSONClient" */;
productName = JSONClient;
};
96BB31C528A8A5B900564F6C /* Medi8 */ = {
isa = XCSwiftPackageProductDependency;
package = 969EBFB425EA2F940008DE91 /* XCRemoteSwiftPackageReference "Medi8" */;
productName = Medi8;
};
96BB31C728A8A5BD00564F6C /* JSONClient */ = {
isa = XCSwiftPackageProductDependency;
package = 969EBFB725EA2FD00008DE91 /* XCRemoteSwiftPackageReference "JSONClient" */;
productName = JSONClient;
};
/* End XCSwiftPackageProductDependency section */

/* Begin XCVersionGroup section */
Expand Down
11 changes: 4 additions & 7 deletions SwiftUIDiscogs/DiscogsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ public struct DiscogsClient {
return session
}()

public func search(for searchTerms: String,
handleResult: @escaping (Result<[Artist], Error>) -> Void) {
public func search(for searchTerms: String) async throws -> [Artist] {
let url = URL(string: "/database/search?q=\(searchTerms)", relativeTo: DiscogsClient.baseUrl)!
urlSession.dataTask(with: url) { (data, response, error) in
if (response as? HTTPURLResponse)?.statusCode == 200 {
// handleResult(
}
}.resume()
let data = try await urlSession.data(from: url)

return []
}

}
6 changes: 3 additions & 3 deletions SwiftUIDiscogs/SearchResults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class DiscogsSearch: ObservableObject {

private var discogsClient = DiscogsClient()

func search(terms: String) -> Future<[SearchResult], Error> {
discogsClient.search(for: terms) { (artists, error) in
<#code#>
func search(terms: String) {
Task {
let artists = try await discogsClient.search(for: terms)
}
}

Expand Down

0 comments on commit 67390bd

Please sign in to comment.