반응형

innodb : 일반적인 엔진이며, insert등 dml 을 하는데 유리하다. 작업시 로우 단위로 락이 걸린다.

myISAM : select 가 위주일 때 많이 쓰인다. 만약 dml작업을 한다면 테이블 락이 걸린다.

memory : ????

반응형

'Programming > MySQL' 카테고리의 다른 글

my.cnf  (0) 2022.09.28
1406, Data too long for column 과 STRICT_TRANS_TABLES  (0) 2022.09.28
transaction이 완벽하지 않은듯하다?  (0) 2022.09.28
시스템 환경설정 확인 방법의 차이?  (0) 2022.09.28
파일에 쓰기  (0) 2022.07.28
반응형

$ php -i

반응형

'Programming > PHP' 카테고리의 다른 글

date 계산  (0) 2016.05.26
Fatal error: Maximum execution time of 30 seconds exceeded  (0) 2015.10.22
error 메세지 출력  (0) 2015.10.22
bitnami  (0) 2015.10.21
phpexcel 설치  (0) 2015.10.13
반응형

오라클의 pfile과 같다고 생각하였다.

 

1. my.cnf 파일 없다면 데이터 베이스는 올라올까?

테스트 결과 my.cnf가 없어도 디비는 올라왔다.

오라클에서는 pfile 또는 spfile이 반드시 존재해야하는 반면에 mysql에는 my.cnf이 없어도 작동 되는 것을 확인하였다.

다만 my.cnf에서 설정된 시스템 변경 값이 디폴트로 바뀌는 것도 함께 확인을 하였다.

그런데 테스트로는 올라온것을 확인하였으나, 무조건 my.cnf 파일이 있어야 된다는 의견도 있어서 다소 헷갈리는 부분이다.

 

2. my.cnf 파일은 어디에 존재하는가?

my.cnf가 찾을수 없을 때 아래 명령어로 파일을 찾아 나갈수 있다.

find / -name 'my.cnf' 로 파일의 위치를 찾을수가 있다.

 

다만 여기서 실제 적용되고 있는 파일인지 그게 좀 헷갈린다. 파일 내용을 변경하고 적용해보지 않는 이상은 모르는게 아닌가?

데이터베이스 안에서 찾을 수 있는 방법이 있지 않을까 했지만, 없는 것 같다.

 

그래서 최선의 방법으로 아래 명령어로 따라가서 찾아봐야할 것 같다.

$ mysql --help | grep -A 1 'Default options'

결과값을 보면 여러 경로가 나오는데 이것은 우선순위로 my.cnf 를 참조한다고 한다.

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf 

필자의 my.cnf 경로는 /usr/local/etc/my.cnf 에 존재하였다.

 

3. my.cnf 경로를 변경해 줄 수는 없는 것인가?

그리고 궁금한 것 중 또 하나는 my.cnf 값을 우선순위 경로로 읽고 있다면, 이 우선순위 경로외에 다른 경로에서 불러 올 수 있는 방법은 있지 않을까 라는 의문이 생겼다.

이것은 아래와 같이 설정에서 바꿔줄 수 있다고 한다. 

우선 우리가 mysql을 실행시킬때 사용하는 mysql.server 을 vi 열어 보면 된다.

$ which mysql.server
/usr/local/bin/mysql.server

 

$ vi /usr/local/bin/mysql.server

$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
$bindir/mysqld_safe --defaults-extra-file=/usr/local/etc/my.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &

mysqld_safe 바로 뒤에 위치에 해야한다

이렇게 설정하면 저 파일외에 다른 쪽 my.cnf 파일은 읽어 올수가 없다고 한다. 라고 알고있었지만,

default경로에 my.cnf 파일이 있다면 이 파일부터 읽게 된다.

반응형
반응형

 

set @@global.sql_mode = "ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION";

 

set @@global.sql_mode = 

"ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"

 

 

python에서 mariadb에 인서트를 하는중에 아래와 같은 에러가 출력되었다.

pymysql.err.DataError: (1406, "Data too long for column 'name' at row 1")

 

넣을려는 값이 더 커서 그런가보다 했지만, 다른 쪽에서는 길었음에도 불구하고 데이터가 잘려서 인서트 되는 경우를 보게 되었다.

이상하게 생각되어 찾아보던 중 이런 설정이 있었다.

 

select @@global.sql_mode;
+--------------------------------------------------------------------------------------------------------------------+
| @@global.sql_mode                                                                                                     |
+--------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------------------------------------------------------------------------------+

 

strict_trans_tables 의 값이 있다면 데이터가 안들어가고 에러를 내뱉고, 없다면 자동으로 알아서 데이터를 잘라서 넣어주는 것이였다.

이것을 설정을 바꾼다면 insert가 가능하다.

set @@global.sql_mode = "ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION";

설정이 되었다고 바로 적용되는 것은 아니고 해당세션을 새로 접속하면 적용된 것을 볼 수 있다.

 

 

아래는 테스트한 결과 입니다.

mysql> use prod

Database changed

mysql> create table strict_table_test 
    -> (name varchar(10))
    -> ;
Query OK, 0 rows affected (0.01 sec)

-- 10자리 입력
mysql> insert into strict_table_test values('1111111111');
Query OK, 1 row affected (0.01 sec)

-- 11자리 입력
mysql> insert into strict_table_test values('11111111145');
ERROR 1406 (22001): Data too long for column 'name' at row 1

mysql> select @@global.sql_mode;
+-----------------------------------------------------------------------------------------------------------------------+
| @@global.sql_mode                                                                                                     |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> set @@global.sql_mode = 
    -> "ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION";
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
user@macos mysql % mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.22 Homebrew
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use prod
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

-- 11자리 입력
mysql> insert into strict_table_test values('11111111145');
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> select * from strict_table_test;
+------------+
| name       |
+------------+
| 1111111111 |
| 1111111114 |  => 마지막 1자리를 제외하고 인서트 된 것을 확인할 수 있다.
+------------+
2 rows in set (0.00 sec)

 

반응형

'Programming > MySQL' 카테고리의 다른 글

스토리지 엔진  (0) 2022.10.21
my.cnf  (0) 2022.09.28
transaction이 완벽하지 않은듯하다?  (0) 2022.09.28
시스템 환경설정 확인 방법의 차이?  (0) 2022.09.28
파일에 쓰기  (0) 2022.07.28
반응형

내가 트랙잭션을 걸고 작업을 한다면 문제가 없을것같지만, 다른 세션에서 dml 작업이 들어간다면 혼선이 올수 있을 것 같다.

다른 세션이 dml이 하였을 때 트랜잭션을 건 내 세션에서는 반영이 되는 경우가 있고 안되는 경우가 있는데 왜 그런지 알수가 없었다.

 

start transaction을 하였을 경우 rollback이나 commit이 오기전 까지는 transaction이 계속 활성화 상태로 되어있다고 생각하였다.

그러나 여기서 이상한점은 다른 세션에서 insert를 하였을 경우 transaction 을 건 세션은 select문을 초기 실행 했느냐안했느냐에 따라서 반영이되고안되고를 오락가락 하는것같은데 관련 정리가 필요해 보인다고 생각하였다.

 

이런 의문을 품던중 아래 링크 설명을 보았다. 해당 글을 자세하게 읽어보면 이해를 할 수 있다.

https://zzang9ha.tistory.com/381

 

[MySQL] - 트랜잭션의 격리 수준(Isolation level)

📎 글또 6기 포스팅 1. 미치도록 더웠던 7월의 회고 2. 사용자가 게시물을 작성할 때의 트랜잭션 처리 3. Spring AOP - (1) 프록시 패턴, 데코레이터 패턴 4. [MySQL] - 트랜잭션의 격리 수준(Isolati

zzang9ha.tistory.com

 

show variables like '%isolation%'; 의 격리 수준에 따라 transaction 의 조회하는 상황이 바뀌는 것이였다.

이것은 트랜잭션을 상황에 따라서 변경을 할 수 있다고 하지만, 어떤 케이스에 사용을 해야할지는 의문이다.

 

# tx_isolation 또는 transaction_isolation

tx_isolation으로 사용되오다가 5.7.20부터 transaction_isolation 이  alias 로 추가가 되었다.

그리고 8.0부터는 tx_isolation이 사라졌다.

 

5.7.37 에 2개가 동시에 존재하는 이유는 이때까지는 alias로 사용되어져 왔기때문이라 생각된다.

설정값에는

1. read-uncommitted

2. read-committed

3. repeatable-read

4. serializable

 

1. read-uncommitted

dml 작업이 이루어졌다면 다른 세션에서는  타세션에서 작업한 내용들이 commit 유무를 떠나서 그대로 반영되어 보여진다.

트랜잭션에서 처리가 완료되지 않았음에도 불구하고 다른세션에서 보였다 안보였다 할수있는 것을 더티리드라고 한다.

이런 더티리드가 사용자에게서 혼란을 줄수있기때문에 비권장하는 설정값이다.

 

2. read-committed

dml 작업이 이루어지고, commit을 하였다면 다른 세션에서는 commit된 데이터만 반영되어져서 보여진다.

이것은 오라클에서 적용하는 방법과 가장 유사하다고 생각한다. 보통 이것으로 설정하는 것을 기본으로 한다.

그러나 mysql에서는 이런 방식도 문제가 될수잇다고 한다. 왜냐하면 초반에 select를 하였을때 보여지지 않았던 데이터가 나중에 보여질수 있는 문제가 있다는 것이다. 이것은 입출금 처리가계속 진행중에 다른쪽에서 조회를 한다면 문제가 될수있다고 한다. 조회결과가 들쑥날쑥 변화할수 있다는 것이다.

 

3. repeatable-read

dml 작업이 이루어지고 commit도 이루워졌지만, 다른 세션에서 dml 작업이 이루어지기전에 transaction을 걸었다면 계속 변경되지 않은 값으로 보여진다.

이것은 언두에서 계속 저장해뒀다가 보여주게 되는 것인데, 만약 세션이 닫히지 않았다면 언두는 계속 쌓여져서 불필요한데이터가 남아 있을 수가 있다. mysql을 설치하면 default 값이다.

 

4. serializable

start transaction이 이루어진 세션이 있다면 다른 세션에서는 접근을 할 수가 없다.읽기작업도 할수가 없다.

반응형

'Programming > MySQL' 카테고리의 다른 글

my.cnf  (0) 2022.09.28
1406, Data too long for column 과 STRICT_TRANS_TABLES  (0) 2022.09.28
시스템 환경설정 확인 방법의 차이?  (0) 2022.09.28
파일에 쓰기  (0) 2022.07.28
root 패스워드 변경  (0) 2017.08.21
반응형

show variables like '%datadir%' 와 select @@datadir 의 차이가 뭔가 싶었다.

똑같은 값을 내뱉는데 왜 이렇게 다르게 명령어를 줄까 싶었는데

눈으로 봤을때 차이점은 select @@datadir 로 하였을때는 해당 변수값만 보여주고 variable은 보여지지 않는다는 것이다.

 

mysql> show variables like 'datadir';

+---------------+-----------------------+

| Variable_name | Value                 |

+---------------+-----------------------+

| datadir       | /usr/local/var/mysql/ |

+---------------+-----------------------+

1 row in set (0.00 sec)

 

mysql> select @@datadir;

+-----------------------+

| @@datadir             |

+-----------------------+

| /usr/local/var/mysql/ |

+-----------------------+

1 row in set (0.00 sec)

 

그리고 또하나는 select 했을 경우 like처리가 안된다는 것이다.

mysql> select @@transaction_isolation;

+-------------------------+

| @@transaction_isolation |

+-------------------------+

| REPEATABLE-READ         |

+-------------------------+

1 row in set (0.00 sec)

 

mysql> show variables like '%isolation%';

+-----------------------+-----------------+

| Variable_name         | Value           |

+-----------------------+-----------------+

| transaction_isolation | REPEATABLE-READ |

+-----------------------+-----------------+

1 row in set (0.01 sec)

반응형

'Programming > MySQL' 카테고리의 다른 글

my.cnf  (0) 2022.09.28
1406, Data too long for column 과 STRICT_TRANS_TABLES  (0) 2022.09.28
transaction이 완벽하지 않은듯하다?  (0) 2022.09.28
파일에 쓰기  (0) 2022.07.28
root 패스워드 변경  (0) 2017.08.21
반응형

 

for i in range(0,20):
    globals()['value_{}'.format(i)] = i

print(value_1)
print(value_19)

 

참고로 동적변수를 print 하였을 때 계속 null값이 나와서 당황하였으나, 이후 알고 보니 변수 선언을 해줘서 발생했던 문제이다.

아래는 잘못된 표현이다.

value_1 = value_2 = ....... value_19 = '' => 잘못된 선언
for i in range(0,20):
    globals()['value_{}'.format(i)] = i

print(value_1)
print(value_19)

 

위 잘못된 선언을 하고자 한다면

globals() 대신 locals()를 사용하면된다.

value_1 = value_2 = ....... value_19 = ''
for i in range(0,20):
    locals()['value_{}'.format(i)] = i

print(value_1)

print(value_19)
반응형

'Programming > python' 카테고리의 다른 글

bz2  (0) 2022.07.20
반응형

#!/bin/sh

today=`date +%Y%m%d`

before=~date +%Y%m%d -d "-1 year"`

connect='/mysql/local/mysql/bin/mysql -uroot -p123456 DBNAME -S /tmp/mysql.sock -N '

$connect -e "select * from dept where reg_date > ${before} " > /data/dept_${today}.txt

 

반응형

'Programming > MySQL' 카테고리의 다른 글

my.cnf  (0) 2022.09.28
1406, Data too long for column 과 STRICT_TRANS_TABLES  (0) 2022.09.28
transaction이 완벽하지 않은듯하다?  (0) 2022.09.28
시스템 환경설정 확인 방법의 차이?  (0) 2022.09.28
root 패스워드 변경  (0) 2017.08.21
반응형

>> import bz2
>> str = b"sqlplus scott/tiger"

 

# compress

>> compress_str = bz2.compress(str)

>> print(compress_str)

b'BZh91AY&SYY\xf9\xdb\xc5\x00\x00\x07\x11\x80@\x00\x8a\xa4\xfe\x00 \x001\x00\x00\x08@d\xf0\xa1X\xedh\x9b\x14\x18~N\xfe.\xe4\x8ap\xa1 \xb3\xf3\xb7\x8a'

 

# decompress

>> decompress_str = bz2.decompress(compress_str)

>> print(d)

b"sqlplus scott/tiger"

 

>> print(d.decode())
sqlplus scott/tiger

 

 

# 오라클 접속 예시

>> import os

>> os.system(bz2.decompress(compress_str))

 

https://docs.python.org/3/library/bz2.html

 

bz2 — Support for bzip2 compression — Python 3.10.5 documentation

bz2 — Support for bzip2 compression Source code: Lib/bz2.py This module provides a comprehensive interface for compressing and decompressing data using the bzip2 compression algorithm. The bz2 module contains: (De)compression of files bz2.open(filename,

docs.python.org

 

반응형

'Programming > python' 카테고리의 다른 글

동적변수  (0) 2022.07.28
반응형

# 터미널에서 git으로 github 경로를 clone 했을 때 아래와 같이 에러가 발생

$ git clone git@github.com:goodgods/docker-images.git

Cloning into 'docker-images'...
The authenticity of host 'github.com (52.78.231.108)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWrVc98/R1BUu3/LiyUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,52.78.231.108' (ECDSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

# 해결

$ ssh-keygen -t rsa -C "email "

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/goodgods/.ssh/id_rsa): => ssh가 설치되는 경로,  [Enter] 누른다.
Enter passphrase (empty for no passphrase): => 암호 설정, 암호를 설정하지 않으려면 그냥 [Enter] 누른다.
Enter same passphrase again: => 암호 again
Your identification has been saved in /Users/goodgods/.ssh/id_rsa.
Your public key has been saved in /Users/goodgods/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/QA7YAfSjN/wTo+N58yLsPeQdHcubHG7A *****@gmail.com
The key's randomart image is:
+---[RSA 3072]----+
|  .o.=o  .o...   |
|   .+o+o.. o.    |
|    .++.     |
|     +.@S + o    |
|    . o* o  .    |
|     o.o=        |
|    ....o.       |
+----[SHA256]-----+

 

## id_rsa.pub 내용 복사

$ vi /Users/goodgods/.ssh/id_rsa.pub

 

## github 접속 및 로그인

Key값에 ./ssh/id_rsa.pub 파일 내용을 가져온다.

 

## 설치 되었는지 확인 작업

$ ssh -T git@github.com

Hi goodgods! You've successfully authenticated, but GitHub does not provide shell access.

반응형
반응형

iOS 15에서 네비게이션 바가  검정색으로 변화되는 현상을 발견하였다.

시뮬레이터에 돌려서 보았을 때는 그런 증상이 있었고,

이 증상을 보자마자 단말기에서도 동일 증상이 있는지 확인 하였으나 발생되지 않았다.

뭐지 하면서 우선 관련되 내용을 찾아보았다.

https://developer.apple.com/forums/thread/683590

 

iOS 15 B2 UINavigationBar Appearan… | Apple Developer Forums

Hey All! When transitioning my app to use the nav bar appearance (introduce in ios13, but required to make navigation bar colors / backgrounds in io15) i believe i had everything all changed over and working ! in iOS 15 b2 it seems when changing navbar bac

developer.apple.com

 

해당 내용을 보고 추가해주었더니 정상 작동을 하였다.

if #available(iOS 15, *) {
    let barAppearance = UINavigationBarAppearance()
    barAppearance.backgroundColor = .white
    navigationItem.standardAppearance = barAppearance
    navigationItem.scrollEdgeAppearance = barAppearance
}

 

반응형
반응형

ituncesconnect 에 빌드된 파일을 업로드 할 때

수출규정 관련 문서가 누락되었다고 느낌표가 뜨는 경우가 있다.

 

이것은 어플에 암호화 기능이 있으면 반드시 추가를 해줘야하는 문서 인것같다.

필자는 암호화 기능을 써본적이 없다.

그래서 항상 무시를 했었다. 무시를 해도 암호화 기능만 없다면 정상적으로 처리가 되었다.

 

느낌표가 나오는 게 찝찝하다면, 아래와 같이 해도 될 것 같다.

xcode에서 info.plist에서 추가한다.

<key>ITSAppUsesNonExemptEncryption</key> <No>

 

 

추가 했을 경우 메세지가 사라졌다.

반응형
반응형

https://github.com/ADVTOOLS/ADVTrustStore

 

ADVTOOLS/ADVTrustStore

ADVTrustStore is a simple management script to import/list/remove CA certificates to the iOS simulator. It is working for iOS 5 and iOS 6. - ADVTOOLS/ADVTrustStore

github.com

보안 관련하여 인증서를 회사에서 받았다. 이후 Xcode 시뮬레이터에서 인터넷이 되지 않았다.

결론은 시뮬레이터에도 동일한 인증서를 넣어주어야 한다.

 

위 사이트를 들어가보면 해결 방안이 잘 나와있다. 

참고로 필자도 위 사이트를 보고 해결하였다.

항상 그랬듯 찾는 시간이 오래 걸리지 해결은 쉬웠다.

 

iosCerTrustManager.py 를 다운 받는다.

$ ./iosCertTrustManager.py --help

$ ./iosCertTrustManager.py -a fileName.pem

subject= CN = goodgods.tistory.com <- 인증서

 

Import certificate to iPhone 11 Pro Max v13.3 [y/N] y

Importing to /Users/comms/Library/Developer/CoreSimulator/Devices/70B8D234-8CD5-43F7-8915-80378BB7116C/data/Library/Keychains/TrustStore.sqlite3

  Certificate added

Import certificate to iPhone 11 v13.3 [y/N] y

Importing to /Users/comms/Library/Developer/CoreSimulator/Devices/8BE1EF1C-42D4-4C17-BC25-685EBB0726C2/data/Library/Keychains/TrustStore.sqlite3

  Certificate added 

 

 

xcode 12에서 안된다면...

1. 파일경로에 한글이 포함된 폴더가 존재하면 안되는 것 같다.

2. 원하는 시뮬레이터를 실행시킨 후에 해보자.

반응형
반응형

실행 오류
상세오류

 

singing 이 맞지 않아서 생긴 문제라고 한다.

signing 부분을 수동으로 관리하고 있었는데, 이부분을 auto로 했더니 잘된다.

 

다만 이렇게 되면 실배포할때는 또 안될 것 같다는 생각이든다.

그럴땐 다시 수동으로 해줘야할 것같은데, Target을 복사해서 singing 부분만 바꿔서 사용해야할지 고민을 해봐야할 것 같다.

 

 

반응형
반응형

let message = "abcdefg\n1234567\n가나다라마바사\nABCDEFG"

let line = message.reduce(into: 0) { (count,letter) in

    if letter == "\n" {

        count += 1

    }

}

 

print(line)

 

https://stackoverflow.com/questions/46490920/count-the-number-of-lines-in-a-swift-string

반응형

'Programming > Swift' 카테고리의 다른 글

[swift5] 시뮬레이터에 인증서 넣기  (0) 2020.02.25
[Swift5] 아이폰 연결시 에러  (0) 2020.02.03
xcode git 연동 문제  (0) 2020.01.16
[swift] slide animation  (0) 2019.11.21
[cocoaPods] 프로젝트 만들어 보기  (0) 2019.10.22
반응형

pc를 재설치하고 Xcode에 git 셋팅 후 작업을 해보았다.

그러나 아래와 같은 메세지를 보여주며 작동이 되지 않는다.

 

이런 경우 Fix 버튼을 눌러서 Author Name, Author Email 값을 넣어준다.

끝.

반응형
반응형

case 1.

let transition = CATransition()

transition.type = CATransitionType.push

transition.subtype = CATransitionSubtype.fromLeft

memoView.layer.add(transition, forKey: nil)

memoView.addSubview(countChartView)

memoView.addSubview(closeMemoButton)

case 2.

UIView.transition(with: self.memoView, duration: 1.0, options: [.transitionFlipFromRight], animations: {

      memoView.addSubview(countChartView)

//       self.memoView.removeFromSuperview()

}, completion: nil)

 

 

반응형

'Programming > Swift' 카테고리의 다른 글

[Swift5] 문자열에 대한 라인수 구하기  (0) 2020.01.29
xcode git 연동 문제  (0) 2020.01.16
[cocoaPods] 프로젝트 만들어 보기  (0) 2019.10.22
[iOS13] 당황스럽게 변경된 점  (0) 2019.10.22
[Swift] opacity  (0) 2019.03.22
반응형

본 내용은 2019년 2월 28일에 메모장에 작성된 것을 복붙한 것이다.

기억이 잘 안나지만, 이게 작동이 되었는지는 알 수 없다.

다만 했다는 기억만으로 이렇게 남겨 놓는다.

 

 

1. Github repository 만들기

 

2. cocoaPods 사이트에서 동일한 이름이 있는지 확인하자.

    ex. https://cocoapods.org/pods/mySamplePods 접속하던가, 사이트내에서 검색을 해보아라.

 

3. cocoaPods 프로젝트 만들기

$ pod lib create demoPods

/Users/sk/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/executable.rb:89: warning: Insecure world writable dir /Users/sk/Documents/2016/hadoop/hadoop-1.2.1/sbin in PATH, mode 040777

Cloning `https://github.com/CocoaPods/pod-template.git` into `demoPods`.

Configuring demoPods template.

/Users/sk/Documents/2016/Development/cocoaPods/demoPods/setup/TemplateConfigurator.rb:207: warning: Insecure world writable dir /Users/sk/Documents/2016/hadoop/hadoop-1.2.1/sbin in PATH, mode 040777

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

 

-----------------------------------------------------------------------------------------------------------------------------

 

To get you started we need to ask a few questions, this should only take a minute.

 

If this is your first time we recommend running through with the guide: 

 - https://guides.cocoapods.org/making/using-pod-lib-create.html

 ( hold cmd and double click links to open in a browser. )

 

 

What platform do you want to use?? [ iOS / macOS ]

 > iOS

 

What language do you want to use?? [ Swift / ObjC ]

 > Swift

 

Would you like to include a demo application with your library? [ Yes / No ]

 > Yes

 

Which testing frameworks will you use? [ Quick / None ]

 > None

 

Would you like to do view based testing? [ Yes / No ]

 > No

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

 

Running pod install on your new library.

 

/Users/sk/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/executable.rb:89: warning: Insecure world writable dir /Users/sk/Documents/2016/hadoop/hadoop-1.2.1/sbin in PATH, mode 040777

Analyzing dependencies

Fetching podspec for `demoPods` from `../`

Downloading dependencies

Installing demoPods (0.1.0)

Generating Pods project

Integrating client project

 

[!] Please close any current Xcode sessions and use `demoPods.xcworkspace` for this project from now on.

Sending stats

Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

 

[!] Automatically assigning platform `ios` with version `9.3` on target `demoPods_Example` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

 

 Ace! you're ready to go!

 We will start you off by opening your project in Xcode

  open 'demoPods/Example/demoPods.xcworkspace'

 

To learn more about the template see `https://github.com/CocoaPods/pod-template.git`.

To learn more about creating a new pod, see `http://guides.cocoapods.org/making/making-a-cocoapod`. 

 - 위 keycahin 찾을수없다는 메세지가 나오는데 모르겠음. 

 - 명령어를 실행시킨 위치에서 하위 폴더가 생성 것이다.

 - Xcode 자동 실행된다.

 

4. mySamplePods.podspec 수정

 - 수정할 대상은 s.name, s.version, s.homepage 등이 있다.
 - 하지만 주어진 포맷대로 수정을 해보았지만 오류가 많다.
 - 나의 방법은 그동안 평소 쓰던 다른 사람들이 만들어 놓은 cocoapods GitHub 라이브러리 들어가서 podspec 파일을 가져와서 그대로 수정해주면 된다.

 

5. 파일을 생성하고 스위프트 버전을 넣어준다.

$ vi .swift-version

4.2 <- 버전

6. pod lib lint

 - .podspec 파일을 맞게 작성했는지 체크를 한다.

 

7. Error 체크

 - 에러가 것이다. 여러가지 에러가 나온다. 정말 울화가 치밀어 오른다. 너무 많은 에러를 접했는데 그나마 자주 등장하는 에러만 적어 보았다.

## 1 ##

WARN  | [iOS] swift: The validator used Swift 3.2 by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_version` attribute in your podspec. Note that usage of the `--swift-version` parameter or a `.swift-version` file is now deprecated.
.swift-version 파일을 생성하였지만, 그래도 위와 같은 에러가 발생한다. 이유모름
“pod lib lint —swift-version=4.2” 같이 실행하라.
—swift-version=4.2 옵션은 아래에서도 동일하게 사용된다.

 

## 2 ##
ERROR | [iOS] file patterns: The `resources` pattern did not match any file.
resources 폴더 또는 파일이 존재않는 것이다. 혹은 경로를 잘못 입력하였거나

 

## 3 ##
WARN  | url: The URL (https://github.com/Name/mySamplePods) is not reachable.
유효한 웹페이지를 입력해야한다. 일단 접속되는 아무 URL 입력해도 되는 같음.

 

## 4 ##
demoPods passed validation.
문구가 나오면 성공한 것이다.

 

8. git push

## $ git init  => 존재한다고 하면 그냥 무시.
Reinitialized existing Git repository in /cocoaPods/mySamplePods/.git/


## $ git add -all
## $ git commit -m “Initial commit”
## $ git tag 0.1.0 => 동일 버전을 입력
## $ git remote add origin https://github.com/developer/mySamplePods.git

## $ git push -u origin master —tags => 에러!! ~ 짱나
error: failed to push some refs to 'https://github.com/developer/mySamplePods.git'
=> 이럴 경우 찾아보니 해결 방법은 많은 같더라. 한개 해봤는데 안돼!
## $ git pull --rebase origin master
## $ git push origin master
=> 강제적으로 넣는게 있다고 해서 그냥 이걸로 했음. $ git push origin +master
## github 사이트에가서 제대로 업로드가 되었는지 확인 해보자. 

 

9. CocoaPods 등록 : 인증작업

$ pod trunk register myEamilAddress@gmail.com mySamplePodsTrunk --description=“mySamplePods.PG"

명령어가 실행이 된 후 메일 내용 확인

 

위 메일 내용의 링크를 클릭하면 이와 같은 페이지가 나타난다.

 

10. CocoaPods 등록 : 업로드

$ pod trunk push demoPods.podspec --swift-version=4.2

에러가 나서 확인을 했더니, .podspec 파일의 값이 리셋되어 있는 것이 아닌가 ㅠㅠ
다시 수정하여 재실행 하였다. 결국에는 아래와 같이 나왔다. 성공이다.

수정이 되었는지 알수없다. 다만 git push 할때 강제로 해서 그럴 같다는 생각이 든다.
https://cocoapods.org/pods/mySamplePods 접속을 해보면 접속이된다.

그러나 이 작업이 성공하지 못하면, 잘못된 페이지라고 나올 것이다.

완료된 메세지

11. 이제 사용 해볼까?

현재버전

Xcode 보면 Pods 프로젝트에서 Development Pods 에서 작업을 하면 되는 같다.
Development Pods > mySamplePods > Pod > Classes > *.swift  —> Classes 없으면 만들어 주면 된다.
수정을 했다고 가정하고, .podspec 파일 버전업을 시켜준다.

그리고 위에서 했던 처럼 git 올리고 cocoapods 올리면 된다.
cocoapods 사이트가서 확인해보면 버전이 올라간 것을 확인 있다.

 

버전업

12. 테스트로 임시적으로 프로젝트를 만들어서 pod install 해보자.

반응형

'Programming > Swift' 카테고리의 다른 글

xcode git 연동 문제  (0) 2020.01.16
[swift] slide animation  (0) 2019.11.21
[iOS13] 당황스럽게 변경된 점  (0) 2019.10.22
[Swift] opacity  (0) 2019.03.22
[Swift] UserDefaults.standard int형식으로 불러오기  (0) 2019.02.18
반응형

1. present(_:animated:completion:)

화면전환 시 사용되는 present의 기존 iOS13 이전까지만 해도 default가 fullScreen 이였다.

하지만 iOS13 부터 formsheet가 되었다. 설정을 위해서는 automatic으로 지정해야한다.

그래서 기존 처럼 fullScreen 을 하기 위해서는 아래와 같이 지정한다.

cell.modalPresentationStyle = .fullScreen

self.present(cell, animated: true, completion: nil)

//자세한 내용

https://zeddios.tistory.com/828

https://stackoverflow.com/questions/56435510/presenting-modal-in-ios-13-fullscreen

https://zonneveld.dev/ios-13-viewcontroller-presentation-style-modalpresentationstyle/

 

2. adMob 전면 광고

잘 되던 전면광고가 formSheet처럼 보여지게 되었고, 광고가 전부 보여지지 않고, 반쪽만 보여지게 되었다.

Google-Mobile-Ads-SDK 를 최신버전으로 설치하자.

필자 같은 경우 7.3 버전이였고 7.5로 업데이트를 하였더니, 아무문제 없었다.

 

2-1. adMob 광고

info.Plist에 이것도 추가를 해줘야한다. 앱이 실행되자마자 크래쉬가 된다.

# Error

Google Ad Manager publishers, follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist

위 문구를 찾아보았다.

//https://stackoverflow.com/questions/55577811/xcode-error-when-added-admob-plugin-to-ionic-project

 

info.Plist 에 GADIsAdManagerApp 를 추가하고 Boolean 값으로 YES로 설정해주면 된다.

 

반응형
반응형

UIView를 반투명하려면 opacity를 사용한다.

let background = UIView()

background.layer.backgroundColor = UIColor.black.cgColor

background.layer.opacity = 0.5 


하지만 이 뷰안에 다른 레이블이 포함되었을 경우, 포함된 레이블도 같이 투명하게 되는 경우가 있다.

let background = UIView()

background.layer.backgroundColor = UIColor.black.cgColor

background.layer.opacity = 0.5

let title = UILabel()

backgroud.addSubview(title)


이럴 경우 이렇게 해보자

let background = UIView()

background.layer.backgroundColor = (UIColor.black.cgColor).copy(alpha: 0.5)

let title = UILabel()

background.addSubview(title)


반응형
반응형

        // 저장할때는 동일하다.

        UserDefaults.standard.set(5, forKey:"num")

        

        // 불러올 때

        UserDefaults.standard.integer(forKey: "num")


반응형
반응형

        let taskText = "All Tasks (task)"

        let attributed = NSMutableAttributedString(string: taskText)

        let strokeTextAttributes = [

//            NSAttributedString.Key.strokeColor : UIColor.black,

            NSAttributedString.Key.foregroundColor : UIColor.black,

//            NSAttributedString.Key.strokeWidth : 2.0,

            NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 18)

            ] as [NSAttributedString.Key : Any]

        

        attributed.addAttributes(strokeTextAttributes, range: (taskText as NSString).range(of: "(task)"))

        titleLabel.attributedText = attributed



반응형
반응형

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // Override point for customization after application launch.

        UINavigationBar.appearance().barTintColor = UIColor.white//.init(red: 23.0/255, green: 197.0/255, blue: 157.0/255, alpha: 1.0)

        

        // To change colour of tappable items.

        UINavigationBar.appearance().tintColor = .black

        

        // To apply textAttributes to title i.e. colour, font etc.

        UINavigationBar.appearance().titleTextAttributes = [.foregroundColor : UIColor.black, .font : UIFont.init(name: "AvenirNext-DemiBold", size: 22.0)!]

        

        // To control navigation bar's translucency.

        UINavigationBar.appearance().isTranslucent = false


        return true

    }


반응형
반응형

override func viewDidLoad() {

        super.viewDidLoad()

        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)

        self.navigationController?.navigationBar.shadowImage = UIImage()

}


반응형
반응형

사실 이게 무엇인지 모른다.

다만 추측하건데, 이미지의 색상을 지원하는 포맷이랄까?

RGB 또는 256 컬러 이런게 업그레이드 되어 색상을 얼마나 지원줄 수있는지의 설정값 같다.



1. 어떻게 알았는가?


collectinView 에 저장된 이미지를 보여주기 위해 구현 하였다.

ipad 시뮬레이터에서만 이미지가 부분적으로 보여지고 있었다.

iphone 에서는 잘되는 것이 pad 에서만 안되고 있으니, 미치고 팔짝 뛸 노릇이였다.


보여지는 이미지와 보여지지 않는 이미지를 비교를 해보았다.

Xcode에서 아래와 같이 보여졌다.


- 보여지는 이미지


- 보여지지 않는 이미지



위 두 개의 이미지를 비교했을 때  Color Space가 유독 눈에 들어온다.

sRGB  와 Apple Wide Color

Apple Wide Color는 무엇인가? ㅠㅠ

아무튼 해결 방법은 Apple Wide Color를 sRGB로 바꿔주면 되는 거 아닌가



2.해결

1.기본 사진 어플리케이션에 이미지를 넣어준다.

2.해당 이미지를 선택하고 command + shift + E 를 누르면 아래와 같이 나온다.



3. 색상프로파일을 선택하고, sRGB로 선택하고 내보내기를 누르면 바뀐형식의 이미지 파일 생성된다.

4. 생성된 파일을 올리고 컴파일을 해보면 정상적으로 작동된다.



3.결론

그리고 왠지 모르게 sRGB보다 apple wide color 가 더 색을 많이 지원해 줄 것 같다는 생각이들었다.

그런데 apple wide color 인데 apple꺼인 xcode에서 지원이 안된다는 것은 좀 이상하지 않은가


구글링을 해본 결과, xcode 버그 일것 같다는 의견들이 많았다.

나도 그냥 이렇게 생각하고 싶다.

반응형
반응형


키보드가 활성화 될 때 하단 부분은 가려지게 될 것이다.

반드시 보여져야 하는 레이어들이라면 키보드 위로 올려서 보여질 수 있게 해보자.

let inputTyping = UITextView()

let buttonExecution = UIButton()

override func viewDidLoad() {

    super.viewDidLoad()

    let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard))

    self.view.addGestureRecognizer(tap)

    NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)

    NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)

}

@objc func dismissKeyboard() {

    self.view.endEditing(true)

}

@objc func keyboardShow(notification: NSNotification) {

        if let keyboardSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {

            if self.view.frame.origin.y == 0 {

                self.view.frame.origin.y -= keyboardSize.height

                self. inputTyping.frame.origin.y -= keyboardSize.height

                self. buttonExecution.frame.origin.y -= keyboardSize.height

        }

    }

}

@objc func keyboardHide(notification: NSNotification) {

    if let keyboardSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {

        if self.view.frame.origin.y != 0 {

            self.view.frame.origin.y += keyboardSize.height

             self. inputTyping.frame.origin.y += keyboardSize.height

            self. buttonExecution.frame.origin.y += keyboardSize.height

        }

    }



나의 삽질은 어디까지 인 것인가?


화면의 반을 차지하는 imageView, 그 아래 textView, 그 아래 button 이 위치하도록 구현을 하였다.

여기서 내가 원하던 것은 키보드가 활성화 될 때 일부로 버튼이 보여지지 않게 하고 imageView 와 textView 창만 올라가게 끔 하려고 했다.

물론 위 소스와 동일하게 했을 시 잘 올라간다.

여기서 더 욕심을 내서 textView를 키보드 바로 위로 맞춰서 하는게 나의 목표였다.

이해가 되질 않는다면 아래 그림을 보면 될 것이다.



그런데....

키보드 바로 위로 textView를 맞춰지지 않는 것이다.

키보드에 가려져 보이지 않거나, 반만 보이거나, 너무 위로 올라가서 키보드와의 간격이 넓어지거나

온갖(?) 방법을 다 해보았다.

온갖 방법이란 내 머리속의 수학 아닌 산수를 동원하여, 위치값까지 하나하나 찾아가고,

"일단 키보드가 바라보는 디바이스의 위치값과 뷰안에 존재하는 위치값은 다를 수 있지!!" 라며

말이 되는 가설과 말도 안되는 가정들을 노트에 수십번을 적어가며

계산하고 계산하였다.


이렇게 구구절절 얘기하는 것은 그만큼 삽질을 많이 했다는 얘기이다.

결국에는 내가 세운 계산법으로는 해내지 못하였다.


포기하고 버튼도 위로 올려버렸다.

위 소스에서 한줄만 더 추가하면 된다.

소스의 파란색 글씨가 그것이다.

1. keyboardShow => self. buttonExecution.frame.origin.y -= keyboardSize.height

2. keyboardHide => self. buttonExecution.frame.origin.y += keyboardSize.height  


허무하게 이 한줄을 넣고 시뮬레이션을 돌리는 순간.

유레카!!!!


이 한줄 추가하면서 모든게 제대로 잘 보여지는데,

아래 버튼 사이즈만 내려볼까?

라는 생각이 들어버렸다.


되면 당연히 좋지만, 한편으로는 엄청 허무할 것 같다는 생각이 들었다.

성공

@objc func keyboardShow(notification: NSNotification) {

        if let keyboardSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {

            let keyboardResize = keyboardSize.height - createButton.frame.height

            if self.view.frame.origin.y == 0 {

                self.view.frame.origin.y -= keyboardResize

                self. textView.frame.origin.y -= keyboardResize

        }

    }

}


성공은 했지만, 버튼을 위로 올리는 것이 나을 것 같아서 적용은 하지 않았다.

추후에 적용할 일이 생기면 참고하기 위해서 이렇게 글로 남겨 놓는다.

매번 느끼는 것이지만 항상 허무한 결론이다.


참고 URL

https://stackoverflow.com/questions/26070242/move-view-with-keyboard-using-swift


반응형
반응형

1. 이미지 사이즈

https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/custom-icons/

필자는 25사이즈로 한다.

참고로 이미지는 png 확장자를 사용하며, 투명바탕에 흰색 이미지를 사용하는 것이 좋은 것 같다.


2. 탭바 선택하였을 때 이미지가 변화되도록 하려면



반응형
반응형

언제부터인지 몰라도 갑자기 크롬 브라우저에서 jqplot 차트를 이미지화 시켜 엑셀파일에 저장해 놓은 소스가 작동이 안되고 메모리가 부족하다는 이미지만 계속 내뿜고 있었다.


처음에는 몰랐다. 그래서 원인을 찾는데도 한참 걸렸다.

파폭, IE에서는 무난하게 잘되고 있었고 유독 크롬만 이런 것이다.


브라우저 문제라고 판단하였지만, 쉽게 해결 되지는 않았다.


쿼리가 문제가 있나 싶어서 온갖 튜닝을 해봤지만, 결과는 똑같았고

결국에 jqplot이 문제라는 것을 알았다.


이 중에서 출력된 jqplot 차트를 이미지화 시키는 부분이 문제라는 것도 나중에 알게되었다.


이제 이것을 해결 하기 위해 많은 것을 파헤치기 시작했다.


결론은 아래 파일을 추가해주고, head 에 jqplot과 관련 된 곳에 추가적으로 지정해 두었다. 해결하였다.

jqplot.toImage.js


<head>

        <script src="./jqplot/plugins/jqplot........"></script>

<script src="./jqplot/plugins/jqplot.toImage.js"></script>

</head>



아래 URL은 확실하게 참고한 URL이다.

https://stackoverflow.com/questions/12182598/jqplot-as-image

https://bitbucket.org/ef4/jqplot/src/a59e7e7a5e97ea721a7b8571612b334e8c025b36/src/jqplot.toImage.js?at=default&fileviewer=file-view-default








반응형

'Programming > JavaScript' 카테고리의 다른 글

브라우저 창 크기에 따른 변화  (0) 2017.08.08
특정 태그 제외  (0) 2017.06.14
javascript 에서 replaceAll  (0) 2015.10.23
반응형

시뮬레이터를 하는 아래와 같은 메세지로 인해 다운이 되었다.


libsystem_kernel.dylib`__abort_with_payload: 


내가 사용할 것은 UIImagePicker이다.

엄청 난 삽질 끝에 알아낸 사실은 Info.plist에 추가해 줘야한다는 것을 깜빡 잊고 있었다.

Privacy - Photo Library Usage Description 


반응형
반응형

import UIKit


var totalCount = 18

var gemCard = 1

var ranArray = [1,2,3,4,5,6,7,8,9,10,11,12,13]


while(totalCount>0) {

    

    let randomIndex = Int(arc4random_uniform(UInt32(ranArray.count)))

    print(ranArray[randomIndex])

    

    ranArray.remove(at: randomIndex)

    

    totalCount-=2

} 


반응형

+ Recent posts