Skip to content

yeahsilver/swift-error-compilation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 

Repository files navigation

Swift-Error-Compilation (Korea ver. ๐Ÿ‡ฐ๐Ÿ‡ท)

๋ธ”๋กœ๊ทธ์™€ ํ•จ๊ป˜ ์—…๋กœ๋“œ ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค!

naver blog: https://blog.naver.com/0_0yeggy




Failed to launch "project name"

: Product -> Test ๋Œ๋ ธ๋”๋‹ˆ ํ•ด๊ฒฐ




Main Thread Checker: UI API called on a background thread ํ˜น์€ Exception: "Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread."

  1. Product -> Scheme -> Edit Scheme

  2. Diagnotics -> Main Thread Checker์— ์ฒดํฌ!

  3. ๋‹ค์‹œ ํ•œ๋ฒˆ run ํ•ด์„œ Main Tread ์—๋Ÿฌ๋‚˜๋Š” ๊ณณ ์ฐพ๊ธฐ!

  4. ์—๋Ÿฌ์— ํ•ด๋‹นํ•˜๋Š” ๊ธฐ๋Šฅ DispatchQueue.main.async()๋กœ ๊ฐ์‹ธ์ฃผ๊ธฐ

์˜ˆ์‹œ)
public func startCount(){
        DispatchQueue.main.async {
            self.countLabel.text = "\(self.count)๋ฒˆ"
            self.count = self.count + 1
        }
    }



Attempt to present UIAlertController whose view is not in the window hierarchy with localnotification

  • ์˜ค๋ฅ˜๊ฐ€ ์ƒ์„ฑ๋œ ์ด์œ 

    : ๋กœ๊ทธ์ธ ์ฐฝ์—์„œ ๋กœ๊ทธ์ธ ์‹คํŒจ ์‹œ UIAlertController ๋„์šฐ๊ณ , ๋กœ๊ทธ์ธ์„ ์„ฑ๊ณตํ•  ์‹œ main ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜๋ ค๋‹ค๊ฐ€ ์˜ค๋ฅ˜ ์ƒ์„ฑ

  • ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ ์ด์œ 

    : ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ, ํ™”๋ฉด ์ด๋™์„ ๋จผ์ €ํ•˜๊ณ  UIAlertController๋ฅผ ๋„์›Œ์„œ

  • ์˜ค๋ฅ˜ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

    : ๊ธฐ๋Šฅ์„ ํ•จ์ˆ˜๋กœ ๋ถ„๋ฆฌํ•œ ๋’ค, ๊ฐ๊ฐ์— ๋งž๋Š” ํ•จ์ˆ˜ ํ˜ธ์ถœ (์ด๋•Œ main thread ์—๋Ÿฌ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด DispatchQueue.main.async๋กœ ๊ธฐ๋Šฅ์„ ๊ฐ์‹ธ์ฃผ์–ด์•ผํ•จ.)

// ์ฝ”๋“œ ์ผ๋ถ€ ๋ฐœ์ทŒ
if myResponse.statusCode == 200 {
   let user = try JSONDecoder().decode(LoginInfo.self, from: data)
   print(user.userInfo.id)
                        
   self.idText = user.userInfo.id
   self.nameText = user.userInfo.name
   self.majorText = user.userInfo.major
   self.moveToMain()                        
} else if myResponse.statusCode == 404 || myResponse.statusCode == 500 {
          self.alert()
}

func moveToMain(){
        DispatchQueue.main.async {
            let vc = self.storyboard?.instantiateViewController(identifier: "main") as! MainViewController
                          
            vc.modalPresentationStyle = .fullScreen
            vc.idText = self.idText
            vc.nameText = self.nameText
            vc.majorText = self.majorText
                          
            self.present(vc, animated: true)
        }
    }

 func alert(){
         DispatchQueue.main.async {
            let alert = UIAlertController(title: "๊ฒฝ๊ณ ", message: "์•„์ด๋”” ๋˜๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž˜๋ชป ์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค.", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "ํ™•์ธ", style: .cancel, handler: nil))
            self.present(alert, animated: true, completion: nil)
        }
    }
moveToMain() ๊ธฐ๋Šฅ์„ ํ•จ์ˆ˜์— ์ง‘์–ด๋„ฃ์œผ๋‹ˆ main ํŽ˜์ด์ง€์— ๋ฐ์ดํ„ฐ๋„ ์ „๋‹ฌ์ด ์ž˜ ๋˜์—ˆ๋‹ค! ( ์ด์ „์—๋Š” ์•ˆ๋์Œ )


typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array but found a dictionary instead.", underlyingError: nil))

==> type ์˜ค๋ฅ˜

๋ณ€๊ฒฝ ์ „
let exam = try JSONDecoder().decode([ExamInfo].self, from: data)
๋ณ€๊ฒฝ ํ›„
let exam = try JSONDecoder().decode(ExamInfo.self, from: data)



No value associated with key CodingKeys(stringValue: "owner`", intValue: nil)

=> ?์„ ์ƒ๋žตํ•ด์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์˜€๋‹ค....

๋ณ€๊ฒฝ ์ „
struct ExamInfo: Codable{
    let owner: OwnerInfo
    let title: String
    let courseName: String
    let courseCode: String
    let startTime: String
    let endTime: String
}
๋ณ€๊ฒฝ ํ›„
struct ExamInfo: Codable{
    let owner: OwnerInfo?
    let title: String?
    let courseName: String?
    let courseCode: String?
    let startTime: String?
    let endTime: String?
}



cell.detailTextViewLabel์ด ๋ณด์ด์ง€ ์•Š์„ ๋•Œ

=> cell์˜ ์Šคํƒ€์ผ์„ ๋ณ€๊ฒฝํ•˜๋ผ

๋ณ€๊ฒฝ ์ „
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
๋ณ€๊ฒฝ ํ›„
let cell = UITableViewCell(style: .subtitle, reuseIdentifier: nil)



json์œผ๋กœ ๋ฐ์ดํ„ฐ๋Š” ์ž˜ ๋“ค์–ด์™”๋Š”๋ฐ table view๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š๋Š”๊ฒฝ์šฐ

=> complete() ์ถ”๊ฐ€!

DispatchQueue.main.async {  completed() }



class has no initializers

==> ๋ณ€์ˆ˜ ํƒ€์ž… ๋’ค์— '!' ๋ถ™ํ˜”๋”๋‹ˆ ํ•ด๊ฒฐ




'NSInvalidArgumentException', reason: 'Invalid type in JSON write(__SwiftValue)'

=> ์ฒซ๋ฒˆ์งธ ์ฝ”๋“œ๋ฅผ ๋‘๋ฒˆ์งธ ์ฝ”๋“œ๋กœ ๋ณ€๊ฒฝ

๋ณ€๊ฒฝ ์ „
guard let httpBody = try? JSONSerialization.data(withJSONObject: parameter, options: []) else { return }
๋ณ€๊ฒฝ ํ›„
let httpBody = try! JSONEncoder().encode(parameter)



xcconfig unable to open file (in target in project )

  1. pod deintegrate ์ž…๋ ฅ

  2. sudo gem install cocoapods-clean ์ž…๋ ฅ

  3. pod clean ์ž…๋ ฅ

  4. pod setup ์ž…๋ ฅ

  5. pod install ์ž…๋ ฅ

โ€‹

ํ›„์— ์ž์‹ ์˜ ํ”„๋กœ์ ํŠธ ์ด๋ฆ„.xcworkspace๋ฅผ open ํ›„ command + b๋กœ ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ




Command CompileSwift failed with a nonzero exit code

=> shift + command + k ์ž…๋ ฅ์‹œ ํ•ด๊ฒฐ




this class is not key value coding-compliant for the key ___."

=> View Controller์— Class ์ด๋ฆ„ ํ™•์ธ




My structure does not conform to protocol 'Decodable' / 'Encodable'

https://stackoverflow.com/questions/53252019/my-structure-does-not-conform-to-protocol-decodable-encodable/53252126




TMS-90683: Missing Purpose String in Info.plist

  1. ์•„๋ž˜์˜ ๋งํฌ์™€ ๊ฐ™์ด Privacy ์ถ”๊ฐ€ํ•˜๊ธฐ

https://kka7.tistory.com/40

ํ•ด๋‹น ์ž‘์—…์„ ์ง„ํ–‰ํ•˜์˜€๋Š”๋ฐ๋„ ์•ˆ๋˜๋ฉด?

  1. ์ˆ˜๋™์œผ๋กœ ์ž…๋ ฅํ•˜๊ธฐ

plist.info ๋ฅผ source code๋กœ ์—ฐ ๋‹ค์Œ, ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•˜์ž

๋จผ์ € plist.info์— ์˜ค๋ฅธ์ชฝ ๋งˆ์šฐ์Šค ๋ฒ„ํŠผ์„ ํด๋ฆญํ•œ ๋’ค, OpenAs ์—์„œ Source Code๋ฅผ ์„ ํƒํ•œ๋‹ค. ๊ทธ ํ›„

<key>NSCalendarsUsageDescription</key>
<string>This app need to access your calendar events</string>
<key>NSCameraUsageDescription</key>
<string>This app need to access your camera events</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app need to access your photo library events</string>

์ด๋ ‡๊ฒŒ ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•ด์ฃผ์ž.


5 duplicate symbols for architecture x86_64

Project -> Build Setting -> Other Linker Flag -> "$(OTHER_LDFLAGS) -ObjC" ์‚ฝ์ž…

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published