2020 Monthly I Learned - kirseia/study GitHub Wiki
-
- 핵심은 mixer.volume = 0으로 입력단에서의 소음 제거(녹음기 소리만 뽑기),
- engine.connect(mixerNode, to: engine.mainMixerNode, format: mixerFormat) 으로 mainMixerNode 로 연결하는 것 (engine.outputNode 가 아니라)
- outputNode로 연결하면 마이크 입력값이 스피커로 출력되어 다시 마이크로 입력되는 현상이 발생할 수 있음
-
- 로컬 푸시에 이미지를 추가할때는 move 되기 때문에 사용할 이미지를 복사해서 url을 넘겨줘야 함
- (but, main bundle 이미지는 복사됨)
- 사진 에서 공유 시 phasset 이 아니라 image url이 들어옴
- image orientation 이 살아있는 상태 -> 사용 방식에 따라 UIImage.Orientation.up 으로 보정 필요.
- Extension 과 Host app 사이에 데이터 주고 받기가 안되기 때문에 image url 을 파일로 저장해도 Host app 에서 로드가 안됨, App groups를 활용해야 함
- Host app 이 multi targets 이고, Share Extension 은 하나일때는 Host app에서 빌드할때 embed 이후에 re-signing 과정이 필요함
- Ref. https://stackoverflow.com/questions/25398636/ios-extensions-with-multiple-targets
- Ref. https://gist.github.com/damian-rzeszot/0b23ad87e5ab5d52aa15c095cbf43c59
- 시스템에 있는 폰트 불러오기
UIFont.systemFont(...) 으로는 기본 폰트만 로드 가능
for familyName in UIFont.familyNames {
for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) {
// 이렇게 하면 로드가 안됨. 시스템 폰트만 로드됨
let font_x = UIFont.font(with: fontName, fontSize: 10)
// 이렇게 해야 됨, 이유는 모름.;
let description = UIFontDescriptor(name: fontName, size: 10)
let font_o = UIFont(descriptor: description, size: 10)
}
}
- 각 플랫폼 공유 기능 정리
- 인스타 - > 필수 - 최소 3초, 최대 10분, 최소 640x640
- "instagram://library?LocalIdentifier=\(assetIdentifier)&InstagramCaption=\(tagString)")
- 위 스킴으로 피드/스토리 업로드 페이지로 바로 이동 가능 - 비공개 스팀
- https://developers.facebook.com/docs/instagram/sharing-to-feed
- 인스타 스토리 - 필수 - 최대 20초, 옵션 - 1080p , 50메가 미만
- "instagram-stories://share?source_application=\(bundleIdentifier)"
- scheme + pastebox 활용해서 공유 가능
- https://developers.facebook.com/docs/instagram/sharing-to-stories/
- 유튜브 - api 로 업로드 해야 함, 최대 128기가
- youtube://upload scheme (비공개 스팀) 으로 생성 페이지로 바로 접근 가능
- https://developers.google.com/youtube/v3/docs/videos/insert
- 틱톡 - sdk 필요,
- 2초 ~ 60초 사이, 워터마크 있으면 삭제 될 수 있음. 500메가 제한, 1080p 여야 함.
- https://boosted.lightricks.com/tiktok-video-length-video-formatting-guide/
- 페북 - sdk 필요 (들어있음, 사용 가능)
- 동영상, 50메가 미만
- https://developers.facebook.com/docs/sharing/sharing-to-stories/ios-developers/
- 라인 sdk 필요
- 300메가, 1.5분이 제한
- wechat sdk 필요
- 100메가 제한
- https://developers.facebook.com/docs/whatsapp/api/media/
- qq 메신져 sdk 필요
- 와츠앱
- https://faq.whatsapp.com/iphone/how-to-link-to-whatsapp-from-a-different-app/?lang=kr
-
swift 에서 a == false 가 !a 보다 빌드 속도가 느리다?
- 대충 코멘트들 보니 == 연산자 오버라이드가 많은 타입에서(약 70개) 이용되고 있어서 타입체킹하는데 오래 걸리는것 같음
- Bool(false) 처럼 false 의 타입을 명확히 명시해주면 해결되는 것 같음
- 코드 가독성을 위해서는 특별히 == false 를 포기할 필요는 없을것 같지만, 함수 컴파일 타임 검사해서 오래걸리면 타입 명시를 해주는게 좋을 듯
- iOS 13 이후로 XCode12 에서 svg 벡터 이미지 지원
- 고정폭숫자 사용하기
- SwiftUI 치트시트
- iOS 14 대응 목록
- SKOverlay - 앱 설치 추천
- iOS 14 새 기능들
- SwiftUI+AVPlayer
- SwiftUI 텍스트 필드 responder 동작시 키보드 위치에 맞게 위치 이동처리
- Apple true type font manual
- vertical glyph : true 했을 때 label 사이즈 계산
- if let b = a as? Int 보다 if case let b as Int = a 가 빠르다고 함
let a: Any = 120
if let b = a as? Int {
// 0.011 s
}
보다
let a: Any = 120
if case let b as Int = a {
// 0.001 s
}
- 텍스트 세로 쓰기 참고 할 것 추가 라이브러리
- 세로 쓰기 관련 w3.org 문서 1
- 세로 쓰기 관련 w3.org 문서 2
- 앱스토어 등록시 필요한 자료
- 언어 필터링용 RegEx
- 이모지 필터링 RegEx
- symbolicate 안되어있는 크래시 로그 변환하기
- 날짜, 리스트, 숫자 다국어 처리
- 비디오 다운로드 디스크 캐시
- ios14 에서 기본 브라우저를 바꿨을때 canOpenUrl 동작 오류
-
램 디스크를 활용한 빌드 속도 개선
- 는 내가 사용하는 프로젝트에서는 효과 없었음, 다만 ssd 수명 향상에는 도움이 될 것 같음, 디스크 용량 줄이는거랑
- 텍스트 세로 쓰기 뷰 샘플 - 1, 2, 3
- 중국에서 사이트 접속되는지 테스트하기
- 언어 필터링 Regular expression
- Debug 빌드 속도 향상 팁 - sha256 -> sha1, code signing speed up
-
sourcetree git invalid name or password 대응
- ssh 방식이면 이런일이 없겠지만 커맨드라인에서 업데이트해도 sourcetree 에서 문제 생길때 system git 을 쓰면 됨.
- Custom scheme 테스트하기 (시뮬레이터)
- 빌드속도 개선하기
- URLComponent
- 이미지 리사이즈/생성할 로직 개선으로 메모리 절약하기
- WWDC 2020 세션들
- iOS 14 디자인 바뀐점
-
iOS 14 - App Clip 살펴보기
- App clip - 전체를 다운로드하지 않고 작은 기능 조각을 제공하는 것, 제약이 많음
- iOS 14 - Widget 만들기
- os.log 사용해보기
- 앱 상태기억하기 - NSUserActivity
- Launch Screen by info.plist
- CIFilter with LUT
- App Extension 과 자료 공유 - UserDefaults 사용
- WidgetKit - https://zeddios.tistory.com/1077 / https://eunjin3786.tistory.com/210
-
Launch Screen
- launchscreen:// 을 이용한 딥링크로 개별 런치스크린을 제공할 수도 있음
- 글 중에 RocketSim 앱을 통해 시뮬레이터에서 레코딩/스킴테스트/딥링크 테스트를 가능하게 해줌
- 스플래시 이미지 업데이트 안될때 강제로 삭제하고 테스트 하는 방법
- iOS memory warning 관련
- 메모리 부족시 3가지 방법으로 알 수 있음
AppDelegate.applicationDidReceiveMemoryWarning(_:) <- 이게 가장 먼저 호출됨
UIApplicationDidReceiveMemoryWarningNotification
UIViewController.didReceiveMemoryWarning() <- 마지막 호출 됨
- iOS CVPixelBuffer resize using Accelerate
- iOS 디바이스 사용 메모리/전체 메모리 확인 함수
static var totalMemorySpace: UInt64 {
ProcessInfo.processInfo.physicalMemory / UInt64(1024 * 1024)
}
static var usedMemorySpace: UInt64 {
// The `TASK_VM_INFO_COUNT` and `TASK_VM_INFO_REV1_COUNT` macros are too
// complex for the Swift C importer, so we have to define them ourselves.
let TASK_VM_INFO_COUNT = mach_msg_type_number_t(MemoryLayout<task_vm_info_data_t>.size / MemoryLayout<integer_t>.size)
guard let memoryLayout = MemoryLayout.offset(of: \task_vm_info_data_t.min_address) else {
return 0
}
let TASK_VM_INFO_REV1_COUNT = mach_msg_type_number_t(memoryLayout / MemoryLayout<integer_t>.size)
var info = task_vm_info_data_t()
var count = TASK_VM_INFO_COUNT
let kr = withUnsafeMutablePointer(to: &info) { infoPtr in
infoPtr.withMemoryRebound(to: integer_t.self, capacity: Int(count)) { intPtr in
task_info(mach_task_self_, task_flavor_t(TASK_VM_INFO), intPtr, &count)
}
}
guard kr == KERN_SUCCESS, count >= TASK_VM_INFO_REV1_COUNT else {
return 0
}
return info.phys_footprint / UInt64(1024 * 1024)
}
- 유용한 iOS 개발 도움 프로그램들
- XCLogParser
- vDSP max 구하기
- 빌드 속도 분석/개선 팁
- class 에 추가하는 protocol 은 class 대신 AnyObject 를 구현하자
- xib/storyboard 뷰가 업데이트가 안될때
- 컴파일 속도를 느리게하는 코드들 1
- 컴파일 속도를 느리게하는 코드들 2
- 컴파일 속도 최적화 팁 - 한글
- Array init 속도 비교
// average: 0.315 seconds (macOS Sierra 10.12.5)
func testInitializedArrayPerformance() {
self.measure {
var array = [Float](repeating: 1, count: 2048 * 2048)
for i in 0..<array.count {
array[(i+1)%array.count] = Float(i)
}
}
}
// average: 0.043 seconds (macOS Sierra 10.12.5)
func testUninitializedArrayPerformance() {
self.measure {
var array : [Float] = []
array.reserveCapacity(2048 * 2048) <- 젤 빠름
array.append(0)
for i in 0..<(2048 * 2048) {
array.append(Float(i))
}
array[0] = Float(2048 * 2048-1)
}
}
// average: 0.077 seconds (macOS Sierra 10.12.5)
func testNativeArrayPerformance() {
self.measure {
let count = 2048 * 2048
let array = UnsafeMutablePointer<Float>.allocate(capacity: count)
for i in 0..<count {
array[(i+1)%count] = Float(i)
}
array.deallocate(capacity: count)
}
}
- switch case 한방에 다 입력하기
- Memory Warning 일으키기
- 시뮬레이터에서 옵션으로 실행 (Simulate Memory Warning menu item.)
- Private api 를 사용
[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
-
destructuring tuple - https://medium.com/flawless-app-stories/tuples-in-swift-f55d64c55cf4
func testTuple() {
let (a, b) = makeTuple()
print(a)
print(b)
}
func makeTuple() -> (Int, Int) {
return (1, 1)
}
-
앱스토어 업로드 후 Too many symbol files 메시지 처리 - 참조
- 결과적으로는 pod 라이브러리의 dsym 이 문제인듯
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
config.build_settings['VALID_ARCHS'] = 'arm64'
end
end
end
+ carthage 쪽은 빌드 할 때 '--no-use-binaries' 옵션을 준다
In Xcode, look in Build Settings for “Strip Debug Symbols During Copy” (COPY_PHASE_STRIP). When enabled, debug symbols are omitted from your .app and placed into a .dSYM file. Otherwise your .app contains these symbols. (By default, debug symbols are stripped from release builds for reasons of obfuscation. You probably shouldn’t change this setting for the release configuration.)
- AVAudioMixParameters 에서 audioPitchAlgorithm 을 영상 배속이 빠를 경우 timeDomain / spectral 이 계산량이 varispeed 보다 높거나 낮음에도 불구하고 비정상 동작을 함, varispeed의 경우 계산량은 중간이지만 pitch correction 이 빠져서인지, 이유는 모르겠지만 정상동작 함. (composition 구성시에 재생은 잘되나, export 가 안되는 현상이 있었음)
- 기기에서 H.265 지원하는지 확인하기
let isHEVC = AVOutputSettingsAssistant.availableOutputSettingsPresets().contains(.hevc3840x2160)
- Print Unescaped String
- 비개발 - 스타트업에서 임원으로 보수를 받을 때 - 주총을 거치지 않으면 반환해야 할지도
- Xcode Build Process
- URLSession 으로 파일 받은 후 파일 삭제되는 현상
/* Sent when a download task that has completed a download. The delegate should
* copy or move the file at the given location to a new location as it will be
* removed when the delegate message returns. URLSession:task:didCompleteWithError:
* will still be called. */
URLSession 으로 파일을 받고 결과 delegate 내에서 파일을 복사하거나 이동시켜야지, 해당 delegate가 종료되면 파일이 사라져버린다.
main.queue 에서 해당 작업을 하려고 했더니 가끔 다운받은 파일이 사라지는 현상이 있어서 수정했었다.;;;