특정 조건일떄 ios 앱을 강제 종료하여야 되어 방법을 찾고있었는데 너무 쉬웠다...


exit(0)


이렇게 하면 앱이 강제로 종료된다..


나는 이런식으로 사용하였다.



check후 알럿 확인을 누른 후 5초뒤 강제종료

if(!check){ let viewController = self.window!.rootViewController as? MainViewController let alert = UIAlertController(title: "warning", message: "detected", preferredStyle: UIAlertControllerStyle.alert) let done = UIAlertAction(title: "확인", style: UIAlertActionStyle.destructive, handler: { result in DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5), execute: { exit(0) }) }) alert.addAction(done) viewController?.present(alert, animated: true, completion: nil) }


버튼에 뱃지를 달아주는 swift 라이브러리를 추가하려고 pod file에 

pod 'PPBadgeViewSwift','~> 1.1.2' 를 추가하고 


pod install을 하였는데



이런 문구와 함께 인스톨되지 않았다.

분명히 PPBadgeViewSwift는 있는 라이브러리고 버전도 과거버전이긴 하지만 릴리즈 되었었던 버전이라

문제가 없을텐데 되지 않아 당황스러웠다.


특이점은 해당 mac에 cocoapads 버전이 1.1.1 이여서 최신버전으로  업데이트를 한지 별로 안됬었고

기존 사용중인 라이브러리는 또 잘 되었다.


구글링하니 아래와 같이 하라하여서 하였더니

pod repo update

잘 되었다.


https://github.com/CocoaPods/Specs 의 master repository 를 pull 하는것이라고 하는데

새롭게 등록, 업데이트된 라이브러리 정보를 갱신하는 것이라고 한다.


그러니까 기존 cocoapods의 repository에 PPBadgeViewSwift의 1.1.2 버전이 없어서 찾지 못해 install 안된 것이다(repository를 갱신 하지 않아서)

'공부 > IOS swift' 카테고리의 다른 글

앱 강제종료 app Force quit  (0) 2018.08.26
xcode simulator screenshot size  (0) 2018.05.18
(IOS) UIWebview clear cache  (0) 2017.12.24
(IOS) 공유하기 기능 ipad 적용  (0) 2017.12.24
(IOS) launchscreen cache  (2) 2017.12.24

xcode 완전 옛날버전꺼를 쓰다가 최근에 9.3버전으로 업데이트 하였는데

command + 1, 2, 3, 4 단축키로 simulator 화면키가 조정되던 기능이 없어진거 같다?


12.9 inches형 ipad 스크린샷을 찍어야되는데

해당 스키린샷에 적정 사이즈는 2048X2732 인데 그냥 화면 저장을하게 되면 그것보다 못미치는 크기의

이미지가 저장된다.


열심히 찾다가 드디어 방법을 찾았는데


1. window -> show device bezels 를 눌러 베젤을 없애고


2. 시뮬레이터 모서리를 클릭하여 잡고 최대한 크기를 늘린다 (mac 화면에서 넘어갈때 까지)


3. 늘리다 보면 갑자기 현재mac 화면에 딱맞게 크기가 리사이징되는 현상이 일어난다.



이 상태에서 캡쳐를 찍으면 해당 시뮬레이터 정사이즈 스크린샷 이미지가 캡쳐되게된다.



안드로이드 webview에서 클리어 캐시를 만들고난 후

ios에서도 적용하기 위해 코들 보았는데



URLCache.shared.removeAllCachedResponses()
URLCache.shared.diskCapacity = 0
URLCache.shared.memoryCapacity = 0


이런식으로 이미 캐시를 날리고 있었다.

하지만 마찬가지로 캐시가 덜 날라가는 느낌이라


캐시 디렉토리도 날려버리기로 하고 코드를 작성하였다.



func clearCache(){
    let cacheURL =  FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
    let fileManager = FileManager.default
    do {
        // Get the directory contents urls (including subfolders urls)
        let directoryContents = try FileManager.default.contentsOfDirectory( at: cacheURL, includingPropertiesForKeys: nil, options: [])
        for file in directoryContents {
            do {
                try fileManager.removeItem(at: file)
            }
            catch let error as NSError {
                debugPrint("Ooops! Something went wrong: \(error)")
            }
        }
    } catch let error as NSError {
        print(error.localizedDescription)
    }
}


이렇게 만든후 특정버튼을 누를시 clearCache() 를 날려주니
확실히 눈에띄게 앱 메모리가 줄어드는것을 확인 할 수 있었다.


IOS앱 심사를 넣었는데 평소에 바로 통과되던게 거절되어 돌아왔다.

내용을보니


Apple의 메시지
2. 1 Performance: App Completeness
Guideline 2.1 - Performance - App Completeness
Your app crashed on iPad 9.7 running iOS 11.2 connected to an IPv6 network when we:
1. Launch the app
2. Clicked share button (4th button on bottom menu)
3. App crashes
This occurred when your app was used:
- On Wi-Fi
We have attached detailed crash logs to help troubleshoot this issue.
Next Steps
To resolve this issue, please revise your app and test it on a device to ensure that it runs as expected.
Resources
For information on how to symbolicate and read a crash log, please review Tech Note TN2151 Understanding and Analyzing Application Crash Reports.
Screenshot-1212-130039.png
Add Comment Collap


  였는데 첨부된 이미지에서는 [공유하기 버튼]에 체크표시를 해놓았더라
대략 내용은 ipad에서 정상작동을 안한다는 말같은데..
그래서 시뮬레이터로 ipad에서 공유하기를 눌러보았는데 iphone에서 잘되던 공유하기가 ipad에선 실행이 안되면서 앱이 강제종료되었다.
이전부터 안되던게 이번에야 걸린듯하다...

 원래소스는 이런데

let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)



ipad에도 공유하기를 제대로 띄우기위해
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)

activityViewController.popoverPresentationController?.sourceView = self.view
를 추가하니
ipad에서는 팝오버로 뜨면서 공유하기가 해결되었다.


업데이트하여 재출시된 ios 앱에서 이상한 현상을 발견되었다.

업데이트 이유가 애초에 런치스크린 이미지를 바꾸게 되어 교체후 업데이트한 것이었는데
앱을 새로 업데이트 받은 몇몇 고객들로 부터 런치스크린에 있는 이미지가 
이전버전의 이미지로 보인다는 이슈를 전달받았다.

앱을 삭제후 다시 설치하면 새로등록했던 이미지로 정상노출되지만

삭제하지않고 계속사용시에는 20일이 지나도 계속 이전버전 이미지만 노출되었고
한번더 앱 업데이트 릴리즈를 하여 재업데이트를 하여도 이전버전 이미지만 노출되었다ㅡㅡ


빌드된 프로젝트를 열어보아도 이전 이미지에 대한 파일은 전혀 보이지 않았고

테스트로 빌드했을때랑 내가 사용하는 폰에서 보았을때도 정상적으로 새로운 이미지가 보였는데

한두 고객도 아닌 많은 수의 고객으로부터 그런 이슈가 전달되어 우연히라고 넘기기에는 문제가 있었다.


처음에는 해당 고객들이 앱스토어 버그이든 기타 다른 이슈로인해 이전버전의 앱을 사용중이라 의심하였지만

모두 확인해보니 확실히 새로운 버전의 앱이 맞았다.


스택오버플로우에서 나와같은 현상의 글들이 있었는데


https://stackoverflow.com/questions/33002829/ios-keeping-old-launch-screen-and-app-icon-after-update
https://docs.nativescript.org/publishing/creating-launch-screens-ios


읽어보니 애플소스 자체의 이미지를 처리하는 매커니즘에 버그가 있는것 같다는 내용도 보였고

해결책은 앱삭제후 재설치뿐이라는 내용도 보이고

디바이스를 종료후 재시작하면 정상적으로 보인다는 내용도있었다.

시뮬레이터에서도 이러한 현상이 가끔 발생한다고하는데

검색능력이 부족해서인지 뚜렷한 해결방법을 찾을 수 없었다.

(고객들에게 일일이 앱 삭제후 재설치를 요구할 순 없기때문에)


현재는 Apple Developer Technical Support에 문의글을 남겨놓긴했는데

아직까지 답변이없다.


혹시 해결방법을 찾은사람이 있으면 댓글을 남겨주세용







swift로 앱만들기 예제를 따라하고 있는데


강의 내용에는 ++을 썼길래 나도 썻는데 나도 그대로 썼는데

에러는 아니지만 경고가 떴다.


이유를 찾아보니


swift 3.0 에서 ++ 과 -- (증감연산자)가 없어졌다고 한다.


i++ i += 1 요래 바꿔야 될 듯 싶다.


아래는 3.0에서 바뀐것들


https://swifter.kr/2016/06/17/swift-3-0%EC%9D%98-%EB%B3%80%EA%B2%BD%EC%82%AC%ED%95%AD/

  • SE-0002 : Removing currying func declaration syntax (커리 함수 선언 구문 삭제)
  • SE-0003 : Removing var from Function Parameters (함수의 매개변수에서 var 삭제)
  • SE-0004 : Remove the ++ and — operators (++/– 연산자 삭제)
  • SE-0005 : Better Translation of Objective-C APIs Into Swift (Objective-C API를 Swift에 최적화)
  • SE-0006 : Apply API Guidelines to the Standard Library (표준 라이브러리로 API의 지침 적용)
  • SE-0007 : Remove C-style for-loops with conditions and incrementersx (C-Style의 for문 제거)
  • SE-0008 : Add a Lazy flatMap for Sequences of Optionals (선택적 배열을 위한 Lazy flatMap 추가)
  • SE-0016 : Adding initializers to Int and UInt to convert from UnsafePointer and UnsafeMutablePointer (UnsafePointer과 UnsafeMutablePointer에서 변환하는 Int uint로 초기화 추가)
  • SE-0019 : Swift Testing (Swift 테스트)
  • SE-0023 : API Design Guidelines (API의 설계 지침)
  • SE-0029 : Remove implicit tuple splat behavior from function applications (암시적 튜플 스플랫 함수 삭제)
  • SE-0031 : Adjusting inout Declarations for Type Decoration (형 장식을 위한 inout 선언 조정)
  • SE-0033 : Import Objective-C Constants as Swift Types (Objective-C의 상수를 Swift형으로 가져오기)
  • SE-0037 : Clarify interaction between comments & operators (코멘트 / 오퍼레이터 표기규칙 명확)
  • SE-0039 : Modernizing Playground Literals (현대적인 Playground 리터럴)
  • SE-0040 : Replacing Equal Signs with Colons For Attribute Arguments (속성에서 =가 아닌 :을 사용)
  • SE-0043 : Declare variables in ‘case’labels with multiple patterns (여러가지 패턴의 “case”레이블 변수)
  • SE-0044 : Import as Member (Member 가져오기)
  • SE-0046 : Establish consistent label behavior across all parameters including first labels (첫번째 레이블을 포함한 모든 매개변수에서 일관된 레이블 실행 확립)
  • SE-0049 : Move @noescape and @autoclosure to be type attributes (@noescape에서 @autoclosure으로 이동)
  • SE-0053 : Remove explicit use of let from Function Parameters Function 매개 변수에서 let의 명시적인 사용을 제거
  • SE-0054 : Abolish ImplicitlyUnwrappedOptional type (ImplicitlyUnwrappedOptional형 폐지)
  • SE-0055 : Make unsafe pointer nullability explicit using Optional (안전하지 않은 포인터 NULL 값을 허용할지 여부를 Optional사용을 명시적으로)
  • SE-0057 : Importing Objective-C Lightweight Generics (Objective-C 경량화된 제네릭 가져오기)
  • SE-0059 : Update API Naming Guidelines and Rewrite Set APIs Accordingly (API 네이밍 지침과 Set API의 업데이트)
  • SE-0061 : Add Generic Result and Error Handling to autoreleasepool() (Generic Result와 autoreleasepool() 오류 처리 추가)
  • SE-0064 : Referencing the Objective-C selector of property getters and setters (Objective-C selector의 getter / setter 참조)
  • SE-0065 : A New Model For Collections and Indices (컬렉션과 인덱스의 새로운 모델)
  • SE-0069 : Mutability and Foundation Value Types (Mutability와 Foundation의 Value Types)
  • SE-0070 : Make Optional Requirements Objective-C-only (Objective-C 전용 Optional 요구 사항 생성)
  • SE-0071 : Allow (most) keywords in member references ((대부분의) 멤버 참고 키워드 허용)
  • SE-0072 : Fully eliminate implicit bridging conversions from Swift (Swift에서 완전히 암시적 브릿지 변환 제거)


물어 물어서 찾은 

swift 코드를 웹에서 컴파일 해볼수 있는 사이트 입니다.


//////////////////////////////////////////



https://swiftlang.ng.bluemix.net/#/repl


playground에서 소스 튜토리얼을 쳐보고있는데 갑자기 execute가 안되었다


unable to create target for stub executable ....


이런 에러가 뜨면서 런이 안되었는데


/////////////////////////////////////////////////


xcode를 리스타트 하니까 제대로 작동되었다.ㅎ

+ Recent posts