Skip to content

Commit

Permalink
Merge pull request #121 from woin2ee/develop
Browse files Browse the repository at this point in the history
개발하는데 유용한 환경 세팅 & 이슈 #70 해결
  • Loading branch information
blooper20 authored Oct 31, 2022
2 parents d69fd19 + 53ae70c commit 04943ed
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 59 deletions.
17 changes: 17 additions & 0 deletions Plinic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
E8C4A37229069A3900425064 /* MainTabBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C4A37129069A3900425064 /* MainTabBarView.swift */; };
E8C4A3772906FCF200425064 /* PlaylistAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C4A3762906FCF200425064 /* PlaylistAPI.swift */; };
E8C6C58C29082DEF00479BDA /* RandomThumbnail.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C6C58B29082DEF00479BDA /* RandomThumbnail.swift */; };
E8D0F39B290D105000E32C59 /* DefaultJsonDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D0F39A290D105000E32C59 /* DefaultJsonDecoder.swift */; };
E8D0F398290D0EFE00E32C59 /* Logger+.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D0F397290D0EFE00E32C59 /* Logger+.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -160,6 +162,8 @@
E8C4A37129069A3900425064 /* MainTabBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabBarView.swift; sourceTree = "<group>"; };
E8C4A3762906FCF200425064 /* PlaylistAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistAPI.swift; sourceTree = "<group>"; };
E8C6C58B29082DEF00479BDA /* RandomThumbnail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomThumbnail.swift; sourceTree = "<group>"; };
E8D0F39A290D105000E32C59 /* DefaultJsonDecoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultJsonDecoder.swift; sourceTree = "<group>"; };
E8D0F397290D0EFE00E32C59 /* Logger+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -215,6 +219,7 @@
D0229E6128FE8DAC00C5F38C /* Back-End */ = {
isa = PBXGroup;
children = (
E8D0F399290D102A00E32C59 /* Common */,
E84A3E142903B88B007FAA78 /* Network */,
D0023CB92906628F006057B3 /* CommonAPI */,
E876C0852909149900237FF9 /* SearchAPI */,
Expand Down Expand Up @@ -369,6 +374,7 @@
E86ECD55290472090039D8BF /* View+.swift */,
D04F1B95290915E80020D80C /* UIImage+.swift */,
E86ECD57290472190039D8BF /* ViewDidLoadModifier.swift */,
E8D0F397290D0EFE00E32C59 /* Logger+.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -520,6 +526,14 @@
path = Application;
sourceTree = "<group>";
};
E8D0F399290D102A00E32C59 /* Common */ = {
isa = PBXGroup;
children = (
E8D0F39A290D105000E32C59 /* DefaultJsonDecoder.swift */,
);
path = Common;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -624,6 +638,7 @@
91014F1A2895841F00C58E8B /* GenreTagView.swift in Sources */,
D01F104E290452CB001B61D0 /* PlaylistInfoView.swift in Sources */,
E84A3E102903B294007FAA78 /* Author.swift in Sources */,
E8D0F398290D0EFE00E32C59 /* Logger+.swift in Sources */,
E87AF4F8290A1FA1006F02ED /* PlaylistUrl.swift in Sources */,
9113807828CF13E0006CD66A /* UserResult.swift in Sources */,
9113806928AFDDD4006CD66A /* PlaylistCreateView.swift in Sources */,
Expand All @@ -644,6 +659,7 @@
E876C088290914B700237FF9 /* SearchAPI.swift in Sources */,
E86ECD56290472090039D8BF /* View+.swift in Sources */,
E84A3E122903B2AD007FAA78 /* Playlist.swift in Sources */,
E8D0F39B290D105000E32C59 /* DefaultJsonDecoder.swift in Sources */,
E86ECD58290472190039D8BF /* ViewDidLoadModifier.swift in Sources */,
D0C176B428BE13EF007CB43F /* SearchContentView.swift in Sources */,
91014F182895840500C58E8B /* UserCountsView.swift in Sources */,
Expand Down Expand Up @@ -783,6 +799,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = RELEASE;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
VALIDATE_PRODUCT = YES;
Expand Down
78 changes: 78 additions & 0 deletions Plinic.xcodeproj/xcshareddata/xcschemes/Plinic.release.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D08E273A2893A56A00013A12"
BuildableName = "Plinic.app"
BlueprintName = "Plinic"
ReferencedContainer = "container:Plinic.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D08E273A2893A56A00013A12"
BuildableName = "Plinic.app"
BlueprintName = "Plinic"
ReferencedContainer = "container:Plinic.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D08E273A2893A56A00013A12"
BuildableName = "Plinic.app"
BlueprintName = "Plinic"
ReferencedContainer = "container:Plinic.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
25 changes: 25 additions & 0 deletions Plinic/Back-End/Common/DefaultJsonDecoder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// DefaultJsonDecoder.swift
// Plinic
//
// Created by Jaewon on 2022/10/29.
//

import Foundation
import OSLog

struct DefaultJsonDecoder {

private let decoder = JSONDecoder.init()

func decode<T>(_ type: T.Type, from data: Data) -> T? where T: Decodable {
do {
let decodedData = try decoder.decode(type.self, from: data)
Logger.decoder.notice("디코딩 성공: \(T.self)")
return decodedData
} catch let error {
Logger.decoder.error("디코딩 실패: \(error.localizedDescription)")
return nil
}
}
}
16 changes: 7 additions & 9 deletions Plinic/Back-End/CommonAPI/GenreAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,21 @@ final class GenreAPI: ObservableObject {
private let genresPath: String = "/plinic/genres" // 기본 path

private let networkService = NetworkService.init()

private let jsonDecoder: DefaultJsonDecoder = .init()


// MARK: - 장르 목록(GET)
func getGenres(_ completion: @escaping ((Result<Genres, Error>) -> Void)) {
func getGenres(_ completion: @escaping (Genres?) -> Void) {

networkService.request(path: genresPath, headers: nil) { result in
networkService.request(path: genresPath, headers: nil) { [self] result in
switch result {
case .success(let data):
do {
let genres = try JSONDecoder.init().decode(Genres.self, from: data)
completion(.success(genres))
} catch let error {
completion(.failure(error))
guard let genres = jsonDecoder.decode(Genres.self, from: data) else {
return completion(nil)
}
return completion(genres)
case .failure(let error):
completion(.failure(error))
return completion(nil)
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions Plinic/Extensions/Logger+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Logger+.swift
// Plinic
//
// Created by Jaewon on 2022/10/29.
//

import Foundation
import OSLog

extension Logger {

static let bundleIdentifier = Bundle.main.bundleIdentifier!

static let network = Logger.init(subsystem: bundleIdentifier, category: "Network")
static let decoder = Logger.init(subsystem: bundleIdentifier, category: "Decoder")
}
4 changes: 0 additions & 4 deletions Plinic/Views/Common/ThumbnailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ struct ThumbnailView: View {
.aspectRatio(1, contentMode: .fill)
.cornerRadius(10)
}
.onAppear() {
print("Thumbnail!!!")
print("\(baseUrl)\(imageUrl)")
}
} // VStack
}
}
Expand Down
9 changes: 2 additions & 7 deletions Plinic/Views/Search/SearchContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@ struct SearchContentView: View {
} // 화면 터치 했을 때 키보드 내리기
} // ZStack
.onAppear(){
genreAPI.getGenres() { result in
switch result {
case .success(let genres):
genreAPI.getGenres() { genres in
if let genres = genres {
self.genres = genres
print(self.genres)
print(genres)
case .failure(let failure):
_ = failure
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions Plinic/Views/User/PlaylistCreateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,9 @@ struct PlaylistCreateView: View {
.cornerRadius(5)
.padding([.top, .bottom], 30)
.onAppear(){
genreAPI.getGenres() { result in
switch result {
case .success(let success):
self.genres = success
case .failure(let failure):
_ = failure
genreAPI.getGenres() { genres in
if let genres = genres {
self.genres = genres
}
}
}
Expand Down
17 changes: 7 additions & 10 deletions Plinic/Views/User/UserProfileEditView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,13 @@ struct UserProfileEditView: View {
.cornerRadius(15)
.padding(.bottom, 10)
} // 좋아하는 장르 선택 1
.onAppear(){
genreAPI.getGenres() { result in
switch result {
case .success(let success):
self.genres = success
self.genre1 = success.randomElement() ?? ""
self.genre2 = success.randomElement() ?? ""
self.genre3 = success.randomElement() ?? ""
case .failure(let failure):
_ = failure
.onAppear() {
genreAPI.getGenres() { genres in
if let genres = genres {
self.genres = genres
self.genre1 = genres.randomElement() ?? ""
self.genre2 = genres.randomElement() ?? ""
self.genre3 = genres.randomElement() ?? ""
}
}
}
Expand Down
34 changes: 11 additions & 23 deletions Plinic/Views/User/UserViews/UserPostView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,21 @@ struct UserPostView: View {

@Binding var userInfo: UserInfo

// FIXME: 화면 크기가 다른 기종에서는 고정크기가 문제 생길 수 있음.
var columns = [GridItem(.fixed(180)), GridItem(.fixed(180))]
private let columns = [GridItem(.flexible()), GridItem(.flexible())]

var body: some View {
ZStack {
Color.black.ignoresSafeArea()

Color.black
.ignoresSafeArea()

VStack {

VStack(alignment: .leading) {
Text("작성한 게시글")
.foregroundColor(Color.white)
.fontWeight(.bold)
.font(.system(size: 20))
.frame(width: 390, height: 20, alignment: .leading)
.padding(.leading, 10.0)

ScrollView {
LazyVGrid(columns: columns) {
ForEach(userInfo.writtenPosts, id: \.uuid) { postInfo in
// VStack으로 도형추가
NavigationLink(destination: PostDetailView(
postId: postInfo.id,
profileImageUrl: userInfo.profileImageUrl
Expand All @@ -46,24 +39,19 @@ struct UserPostView: View {
}
.padding(.horizontal, 5)
}
}
// ForEach
}
// LazyVGrid
}
// ScrollView
}
// VStack
}
// ZStack
} // ForEach
} // LazyVGrid
} // ScrollView
} // VStack
} // ZStack
}
}



struct UserMyPostView_Previews: PreviewProvider {
struct UserPostView_Previews: PreviewProvider {
static var previews: some View {
UserPostView(userInfo: .constant(.createMock()))
UserPostView(userInfo: .constant(.createMock()))
.previewDevice("iPhone 13 Pro Max")
UserPostView(userInfo: .constant(.createMock()))
.previewDevice("iPhone 8")
}
Expand Down
4 changes: 4 additions & 0 deletions Plinic/Views/User/userContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ struct UserContentView: View {

let userAPI: UserAPI = .init()

#if RELEASE
@State var userInfo: UserInfo = .createEmpty()
#elseif DEBUG
@State var userInfo: UserInfo = .createMock()
#endif

@State private var postTransform = true

Expand Down

0 comments on commit 04943ed

Please sign in to comment.