notes

2020. 6. 29.
UIImagePickerControllerOriginalImage

FoodTracker 예제 중 Work with View Controllers 튜토리얼에 버그... 는 아니고 옛날 자료라서 지금 안돌아가는 게 있었다.

링크를 찾아 아래와 같이 해결

    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

        // The info dictionary may contain multiple representations of the image. You want to use the original.
-        guard let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else {
+        guard let selectedImage = info[.originalImage] as? UIImage else {
            fatalError("Expected a dictionary containing as image, but was provided the following: \(info)")
        }

        // Set photoImageView to display the selected image.
        photoImageView.image = selectedImage

        // Dismiss the picker.
        dismiss(animated: true, completion: nil)
    }
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {

        // The info dictionary may contain multiple representations of the image. You want to use the original.
-        guard let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else {
+        guard let selectedImage = info[.originalImage] as? UIImage else {
            fatalError("Expected a dictionary containing as image, but was provided the following: \(info)")
        }

        // Set photoImageView to display the selected image.
        photoImageView.image = selectedImage

        // Dismiss the picker.
        dismiss(animated: true, completion: nil)
    }

2020. 6. 28.
vscode가 포맷팅 하면서 자꾸 jsx에 빈칸을 넣으면

원인

.jsx 파일의 File AssociationBabel JavaScript로 되어있어서 생기는 문제.

해결 1

화면 하단의 language mode 영역을 클릭 -> JavaScript React로 바꾸면 해결

Screen Shot 2020-06-28 at 17 52 41

해결 2

물론 settings.json에서 바꿀수도 있다.

"files.associations": {
  "*.jsx": "javascriptreact"
}
"files.associations": {
  "*.jsx": "javascriptreact"
}

2020. 6. 28.
vscode에서 swift language server 돌리기

xcode에선 vim key 바인딩, hover action 등등이 간단하게 안되는 것 같아 vscode에 개발 환경 꾸미는 게 가능할까 알아보았다.

  1. 원하는 위치에 sourcekit-lsp를 클론 받는다.
  2. $ cd sourcekit-lst/Editors/vscode
  3. $ npm run createDevPackage
  4. $ code --install-extension out/sourcekit-lsp-vscode-dev.vsix
  5. 공식엔 여기까지 하면 된다고 나와있긴 한데, vscode에서 Starting client failed Launching server using command sourcekit-lsp failed. 라며 에러가 발생했다.
  6. $ xcrun -f sourcekit-lspsourcekit-lsp가 설치된 경로를 알아내서 복사한다.
  7. vscode settings.json에 아래를 추가한다.
  8.   "sourcekit-lsp.serverPath": "<경로>"
      "sourcekit-lsp.serverPath": "<경로>"
  9. vscode를 reload 한다.
  10. Screen Shot 2020-06-28 at 14 34 30
  11. https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swiftlint 도 설치하면 좋다 카더라.