Database Organization이라는 수업을 듣게 되어 MySQL을 처음 사용해보게 되었다.

여기를 참고해서 MySQL을 설치한 뒤, Workbench를 설치했는데

 

초기 설정을 하는데 

Edit Conection 들어가주고

Store in Keychain 눌러서 비번 설정해주고 Test Connection 누르니까 이런 경고문이 떴다.

 



내가 설치한 MySQL은 8.2.0 버전이었고,

Workbench는 24.1.16 기준으로 가장 최신 버전인 8.0.36 버전이었다.

 

해결 방법

버전을 조금 낮춘 8.0.34로 재설치하니 해결 되었다.

 

MySQL 완전 삭제

MySQL을 다시 설치하기 위해 기존 설치 버전을 삭제해야 했다. 기존 버전 삭제 방법은 여기를 참고했다.

 

 

이 게시글에서는 아래 링크의 튜토리얼을 따라 M1에 openssl1.1.1을 설치할 때와 md5, sha1 소스코드를 컴파일할 때 겪은 문제를 정리한다.

https://indiespark.top/programming/compile-open-ssl-apple-silicon/

 

How to Compile OpenSSL 1.1.1 for Apple Silicon

The long-rumored ARM Mac is on the horizon. With this comes the big work of porting and re-compiling current applications. But many Mac App Store apps are dependent on OpenSSL, which doesn’t yet su…

indiespark.top

 

 

1. fatal error: 'inttypes.h' file not found

Building the ARM Half 단계에서 $ caffeniate make 을 입력했더니 다음과 같은 에러가 발생했다.

에러문

더보기

perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
/Applications/Xcode.app/Contents/Developer/usr/bin/make depend && /Applications/Xcode.app/Contents/Developer/usr/bin/make _all
cc  -I. -Iinclude -fPIC -arch arm64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -D_REENTRANT -DZLIB -DNDEBUG  -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
clang: warning: no such sysroot directory: '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
clang: warning: using sysroot for 'MacOSX' but targeting 'iPhone' [-Wincompatible-sysroot]
In file included from apps/app_rand.c:10:
In file included from apps/apps.h:13:
In file included from ./e_os.h:16:
In file included from include/openssl/e_os2.h:243:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
#include_next 
              ^~~~~~~~~~~~
1 error generated.
make[1]: *** [apps/app_rand.o] Error 1
make: *** [all] Error 2

해결

"Xcode-beta.app"을 "Xcode.app"으로 수정하면 된다. 자세한 openssl 과정은 링크 참고.

"darwin64-arm64-cc" => {
    inherit_from     => [ "darwin-common", asm("aarch64_asm") ],
    CFLAGS           => add("-Wall"),
    cflags           => add("-arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"),
    lib_cppflags     => add("-DL_ENDIAN"),
    bn_ops           => "SIXTY_FOUR_BIT_LONG",
    perlasm_scheme   => "macosx",
},

 

 

2.  md5 관련 컴파일 에러

해결

아래 명령어를 입력해 경로를 변경 해준다.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl@3/lib/

그런데 이 경우 x86_64에서는 해결이 되는데 arm64에서는 여전히 에러다..

.

.

.

해결!!!!!했다!!!

 

원했던 것

arm64 아키텍처에서도 openssl라이브러리 사용한 c프로그램 정상 실행

 

c프로그램 컴파일 시 에러문

3 warnings generated. ld: warning: ignoring file /usr/local/opt/openssl/lib//libcrypto.dylib, 
building for macOS-arm64 but attempting to link with file built for macOS-x86_64 Undefined symbols 
for architecture arm64: "_MD5_Final", referenced from: _main in md5-46c6b0.o "_MD5_Init", referenced 
from: _main in md5-46c6b0.o "_MD5_Update", referenced from: _main in md5-46c6b0.o 
ld: symbol(s) not found for architecture arm64

 

 

해결

위에서 openssl 설치할 때 만든 ~/openssl-1.1.1g-arm64 폴더로 이동해서 아래 명령어 순서대로 입력

./Configure CC=clang CXX=clang++ CFLAGS="-arch arm64" CXXFLAGS="-arch arm64" LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include"
make
make install

 

3. sha1 관련 컴파일 에러

 

c프로그램 컴파일 시 에러문

Undefined symbols for architecture arm64:
  "_SHA1_Final", referenced from:
      _do_fp in sha1-0d35b4.o
  "_SHA1_Init", referenced from:
      _do_fp in sha1-0d35b4.o
  "_SHA1_Update", referenced from:
      _do_fp in sha1-0d35b4.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

해결

컴파일 할 때 -lcrypto 옵션 붙여줘야 함ㅋㅅㅋ

 

행복해..사실 안 행복해... 이걸 대체 몇 시간을

 

 

 

Ubuntu 22.04를 설치했는데 한글 입력이 되지 않았다.

설정에서 언어를 한글로 바꾸는 등 별 뻘짓을 다 했는데 키보드 설정을 손 댔어야 했다.

 

설정 방법은 다음과 같다.

 

1. ibus-hangul 패키지 설치

한글 패키지가 설치 되어있지 않다면 터미널에 아래 명령어를 입력해 설치해준다.

$ sudo apt-get install ibus ibus-hangul

 

2. 아래 명령어를 입력해 IBus 기본 설정 창으로 이동해 입력기 탭에서 Korean-Hangul을 추가한다.

$ ibus-setup

 

3. [설정] - [키보드] 창으로 이동해 Korean (Hangul)을 추가한다.

 

4. 추가 후 [기본 설정]을 클릭하면 한영 전환 키를 확인하고 변경할 수 있다.

프로필 수정 화면 구현 이전 글

0.Overview

.

.

.

프로필 수정 화면을 구현하기 위한 기본 UI이다. 

여기서 다룰 내용은 TextField와 TextView에 관련된 내용이다.

 

🧐 TextField vs TextView

먼저 둘 다 텍스트를 편집하기 위한 객체이다. 사용자로부터 텍스트를 입력받고, UI에 반영한다

 

TextField와 TextView의 차이가 뭘까, 사실 난 TextField의 존재만 알았다.

TextField에 2줄 이상의 텍스트가 입력되지 않자 해결 방법을 찾다가 TextView를 알게 되었다. 이게 힌트다.

 

TextField는 한 줄만 입력 받을 수 있고, TextView는 여러 줄 입력 받을 수 있다.

 

또 다른 차이로는, Placeholder 설정 방식이다.

TextField의 경우 Placeholder를 스토리보드에서 쉽게 설정 해줄 수 있는 반면, TextView는 코드로만 구현이 가능하다. (TextField도 물론 코드로 구현 가능하다.)

 

* Placeholder란, TextField 혹은 TextView에 사용자가 아무 것도 입력하지 않았을 때 나타나는 텍스트이다.

아래 이미지를 보면, Username 입력 칸에 'Username'이라고 표시된 부분이 바로 Placeholder이다.

 

Username 입력창은 한 줄만 입력받아도 충분하기 때문에 TextField이고, Bio 입력창은 여러 줄 입력 가능하도록 TextView로 구현했다.

여기에 텍스트를 입력하면, 다음과 같이 입력된 텍스트가 나타난다.

 

아직 초보라 스토리보드를 많이 활용하는데, 스토리보드에서 TextField를 클릭하면 우측 인스펙터 영역의 attribute inspector 탭에서 Placeholder를 쉽게 설정할 수 있다.

 

반면에 TextView는 코드로 따로 구현해야 한다.

    class MyProfileEditViewController: UIViewController {
    	// 프로퍼티 선언
    	@IBOutlet weak var bioTextView: UITextView!
        var placeholderLabel: UILabel!
        .
        .

viewDidLoad 함수에 다음과 같이 placeholder에 들어갈 문구, 폰트, 색상, 크기, 위치 등을 지정해준다.

        // bioTextViewD의 placeHolder 설정
        placeholderLabel = UILabel()
        placeholderLabel.numberOfLines = 0
        placeholderLabel.text = "Bio"
        placeholderLabel.font = UIFont.systemFont(ofSize: (bioTextView.font?.pointSize)!)
        bioTextView.addSubview(placeholderLabel)
        placeholderLabel.textColor = .lightGray
        placeholderLabel.isHidden = !bioTextView.text.isEmpty
        placeholderLabel.sizeToFit()
        placeholderLabel.frame.origin = CGPoint(x: 0, y: (bioTextView.font?.pointSize)! / 2)

그러면 아래처럼 Bio라는 Placeholder가 설정된 것을 확인할 수 있다. 하지만 텍스트를 입력했을 때 사라지지 않는다.

텍스트를 입력했을 때 placeholder가 사라지도록 하기 위해서는 텍스트가 입력될 때마다 글자수를 확인하여 placeholder의 숨김 여부를 결정하도록 해야 한다.

 

다음과 같이 구현할 수 있다.

// 텍스트 입력할 때마다 placeholderLabel의 숨김 여부 결정
@objc private func textDidChange(_ notification: Notification) {
        placeholderLabel.isHidden = !bioTextView.text.isEmpty
}
// NotificationCenter에 textDidChange 등록
NotificationCenter.default.addObserver(self,
                                       selector: #selector(textDidChange(_:)),
                                       name: UITextView.textDidChangeNotification,
                                       object: bioTextView)

전체 코드

//  MyProfileEditViewController.swift

import UIKit

class MyProfileEditViewController: UIViewController {
    
    
    @IBOutlet weak var bioTextView: UITextView!
    var placeholderLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupAttribute()
    }
    
    @objc private func textDidChange(_ notification: Notification) {
            placeholderLabel.isHidden = !bioTextView.text.isEmpty
    }
    
    func setupAttribute() {
        
        // NotificationCenter에 textDidChange 등록
        NotificationCenter.default.addObserver(self,
                                               selector: #selector(textDidChange(_:)),
                                               name: UITextView.textDidChangeNotification,
                                               object: bioTextView)
        
        // bioTextViewD의 placeHolder 설정
        placeholderLabel = UILabel()
        placeholderLabel.numberOfLines = 0
        placeholderLabel.text = "Bio"
        placeholderLabel.font = UIFont.systemFont(ofSize: (bioTextView.font?.pointSize)!)
        bioTextView.addSubview(placeholderLabel)
        placeholderLabel.textColor = .lightGray
        placeholderLabel.isHidden = !bioTextView.text.isEmpty
        placeholderLabel.sizeToFit()
        placeholderLabel.frame.origin = CGPoint(x: 0, y: (bioTextView.font?.pointSize)! / 2)
    }

}

 

 

 

참고 링크

https://ios-development.tistory.com/693

 

[iOS - swift] TextView placeholder 적용 방법

placeholder 적용 textView 초기화 text를 placeHolder 문자열, color를 placeHolder 색상으로 변경 delegate 설정 // ViewController.swift let textViewPlaceHolder = "텍스트를 입력하세요" lazy var textView..

ios-development.tistory.com

https://roniruny.tistory.com/151

 

[iOS] NotificationCenter?

🔹 Notification? observer들에게 전달되는 구조체로 정보가 담겨있고, 해당 알림을 등록한 observer에게만 전달됩니다. 구조체는 아래와 같이 구성되어 있습니다. 1️⃣ name : 전달하고자 하는 notificati

roniruny.tistory.com

 

지금 진행 중인 프로젝트가 SNS와 성격이 비슷하다. 그래서 SNS의 기본적인 기능, 그 중에서도 프로필 화면 관련해서 겪은 시행착오를 토대로 알게 된 내용을 정리해 보려 한다.

 

다룰 내용은 다음과 같다.

 

1. UITextVeiw에 Placeholder 설정하기(UITextField와 UITextField의 차이)

가장 먼저 기본 UI를 구성해야 한다. UIImageView나 UILabel 등의 배치 및 Constraints(제약조건) 설정 등의 기본적인 내용 보다는, UITextField와 UITextView의 차이, UITextVIew의 placeholder 설정 방법 등 새로 알게 된 내용 위주로 정리하려 한다. 

 

2. 다른 뷰컨트롤러로 데이터 전달 (Delegate Pattern)

사용할 뷰컨트롤러는 총 두 개이다. 하나는 '내 프로필 화면', 다른 하나는 '내 프로필 수정 화면'이다.

'내 프로필 화면'에서 '프로필 수정' 버튼을 눌렀을 때, 기존 프로필 정보(프로필 사진, 사용자 이름, 소개 글)을 '프로필 수정 화면'으로 넘겨주는 기능을 구현할 것이다.

 

3. 카메라 / 앨범 접근 후 사진 가져오기

프로필 사진을 업로드하기 위한 기능이다. UIImagePicker를 사용해 사진을 가져오는 방법, 카메라 / 앨범 접근을 위해 '접근허용' 설정 방법 등을 다룰 것이다.

 

4. 수정된 프로필 정보를 이전 뷰(내 프로필 화면)으로 전달하기 (Delegate Pattern)

2번 내용과 비슷하다. 굳이 따로 다룰 필요가 있을까 싶긴 한데.. 마무리 느낌으로 ^~^

사실 지금 하고 있는 프로젝트에서는 이 부분이 가장 문제이다.. 블로그에서는 간단히 뷰컨트롤러 -> 뷰컨트롤러 간의 데이터 전달이라 비교적 쉽다. 하지만 프로젝트에서는 뷰컨트롤러 -> 셀 로 전달해야 하는데, 뷰컨트롤러와 셀의 swift 파일이 달라서 그런지 셀에 접근하는 방법을 모르겠다.. 어차피 서버와 연동하면 서버에서 데이터를 받아오면 그만이니 큰 문제는 아닌 것 같긴 한데, 찝찝한걸....구구절절,,,,

아무튼 여기선 간단히 구현해보려 한다.

.

.

.

짠 후다닥 만든 허접한 기본 화면.. 차근차근 시작해 보자!!

+ Recent posts