Adicionar vários pods aumenta o tempo de inicialização do aplicativo iOS em mais de 10 segundos

Estou fazendo um projeto de aplicativo iOS no Swift 1.2, usando Cocoapods 0.37.2, Xcode 6.3.2. Depois de adicionar cerca de 8 pods no meu projeto, o tempo de inicialização do aplicativo aumenta bastante (cerca de 10 segundos a mais) no dispositivo (iPhone 5). (Nota: hora de iniciar significa a hora em que você toca no ícone do aplicativo para abri-lo)

É tão lento que o iOS o encerra porque não é iniciado a tempo. A parte superior do log de falha é a seguinte ...

Application Specific Information: com.tryslowappswift failed to launch in time

Elapsed total CPU time (seconds): 27.720 (user 27.720, system 0.000), 68% CPU 
Elapsed application CPU time (seconds): 0.074, 0% CPU

Thread 0:
0   dyld                            0x1ff0f4c8 ImageLoaderMachOCompressed::rebase(ImageLoader::LinkContext const&) + 456
1   dyld                            0x1ff087be ImageLoader::recursiveRebase(ImageLoader::LinkContext const&) + 174
2   dyld                            0x1ff07dca ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&) + 186
3   dyld                            0x1ff012fc dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&) + 204
4   dyld                            0x1ff022d6 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2362
5   dyld                            0x1fefe222 dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) + 394
6   dyld                            0x1fefe03c _dyld_start + 60

No thread state (register information) available
...

Você pode testar isso:

Nota: Criei um exemplo de projeto Swift com todas as configurações de podsno meu repositório github. Você pode apenas clonar e executá-lo no seu dispositivo e ver o atraso por si mesmo.

Crie um novo projeto em branco, nada noapplication:didFinishLaunchingWithOptions: métodoExecute o aplicativo no dispositivo e veja o lançamento do aplicativo muito rápido.Pare. Agora tente adicionar umPodfile com cerca de 8 pods (não importa se são grandes ou pequenos), façapod install.Apenas para maior clareza, este é oPodfile Eu usei...

Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks! # required for Swift pods

pod 'Alamofire', '~> 1.2.1'
pod 'NPReachability', '~> 0.2.0'
pod 'ActionSheetPicker-3.0', '~> 1.6.1'
pod 'SDWebImage', '~> 3.7.2'
pod 'KVNProgress', '~> 2.2.1'
pod 'KeychainAccess'
pod 'JazzHands', '~> 0.2.1'
pod 'DGActivityIndicatorView'
Em seguida, execute o dispositivo novamente. Desta vez, você notará oAtraso de mais de 10 segundos, mesmo antesapplication:didFinishLaunchingWithOptions: método é chamado. Nãoimport, sem arquivos de cabeçalho de ponte, basta instalar o pod no projeto e diminuir a velocidade do lançamento(- meme da raiva cara !!! ---)

Eu suspeito que isso tem a ver com o Swift 1.2, então tentei um projeto Objective-C, mas ainda sinto o mesmo atraso. Parece acontecer logo após uma instalação normal do pod, não tenho idéia de como otimizar ou corrigir isso. :(

ATUALIZAÇÃO 1 (27 de julho de 2015):

Conforme apontado por Bryan Musial, tentei adicionar sinalizadores nas minhas configurações de esquema para registrar o tempo de carregamento de cada biblioteca. Eu corro isso no meu iPhone 5. Aqui está o resultado na janela 'Dispositivos' do Xcode:

Jul 27 13:56:02 Hlung SpringBoard[43] <Warning>: Installed apps did change.
  Added: {(
  )}
  Removed: {(
  )}
  Modified: {(
      "th.in.hlung.TrySlowAppSwift"
  )}
Jul 27 13:56:03 Hlung com.apple.debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
  [4964] <Warning>: debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
   for armv7.
Jul 27 13:56:03 Hlung com.apple.debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
  [4964] <Warning>: Connecting to com.apple.debugserver service...
Jul 27 13:56:03 Hlung com.apple.debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
  [4964] <Warning>: Got a connection, waiting for process information for launching or attaching.
Jul 27 13:56:03 Hlung com.apple.debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
  [4964] <Warning>: About to launch process for bundle ID: th.in.hlung.TrySlowAppSwift
Jul 27 13:56:03 Hlung com.apple.xpc.launchd[1] (UIKitApplication:th.in.hlung.TrySlowAppSwift[0x578b]) <Error>: The DisableASLR key is no longer respected. Please remove it.
Jul 27 13:56:03 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:04 Hlung kernel[0] <Notice>: xpcproxy[4965] Container: /private/var/mobile/Containers/Data/Application/6C097544-9C1E-4B73-ACF8-43701FDFC8C2 (sandbox)
Jul 27 13:56:04 Hlung com.apple.debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
  [4964] <Warning>: In completion handler, got pid for bundle id, pid: 4965.
Jul 27 13:56:04 Hlung com.apple.debugserver-@(#)PROGRAM:debugserver  PROJECT:debugserver-320.2.89
  [4964] <Warning>: Got a connection, launched process /private/var/mobile/Containers/Bundle/Application/9F233F77-63BC-479E-827A-F08C964DE38C/TrySlowAppSwift.app (pid = 4965).
Jul 27 13:56:04 Hlung SpringBoard[43] <Warning>: LICreateIconForImage passed NULL CGImageRef image
Jul 27 13:56:04 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:04 Hlung locationd[4692] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jul 27 13:56:05 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:05 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:06 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:07 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:08 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:08 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:09 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:10 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:10 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:11 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:12 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung MobileMail[139] <Warning>: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jul 27 13:56:12 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:13 Hlung assistant_service[4931] <Warning>: the local store doesn't allow tasks and we have no default calendar :(
Jul 27 13:56:13 Hlung assistant_service[4931] <Warning>: Error getting NanoAppRegistry workspace info: Error Domain=NSCocoaErrorDomain Code=4099 "The operation couldn’t be completed. (Cocoa error 4099.)" (The connection to service named com.apple.nanoappregistry.workspace was invalidated.) UserInfo=0x17ebf490 {NSDebugDescription=The connection to service named com.apple.nanoappregistry.workspace was invalidated.}
Jul 27 13:56:13 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:14 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:14 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:15 Hlung amfid[4918] <Error>:  SecTrustEvaluate  [leaf CriticalExtensions IssuerCommonName]
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: dyld: loaded: /usr/lib/libcupolicy.dylib
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: dyld: loaded: /usr/lib/libTelephonyUtilDynamic.dylib
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total time: 13.1 seconds (100.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total images loaded:  149 (128 from dyld shared cache)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total segments mapped: 60, into 1700 pages with 112 pages pre-fetched
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total images loading time: 12.8 seconds (97.9%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total dtrace DOF registration time: 0.17 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total rebase fixups:  32,622
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total rebase fixups time: 34.74 milliseconds (0.2%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total binding fixups: 121,320
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total binding fixups time: 116.36 milliseconds (0.8%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total weak binding fixups time: 5.10 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total bindings lazily fixed up: 0 of 0
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total initializer time: 118.97 milliseconds (0.9%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:     libSystem.B.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 37.57 milliseconds (0.2%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: libBacktraceRecording.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.77 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:        libc++.1.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.09 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:       libobjc.A.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.10 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:        CoreFoundation 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.88 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:                vImage 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.02 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:      libGLImage.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.12 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: libFosl_dynamic.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.04 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:             CoreImage 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 0.02 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>:    libswiftCore.dylib 
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: : 2.14 milliseconds (0.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total symbol trie searches:    43149
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total symbol table binary searches:    0
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total images defining weak symbols:  18
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total images using weak symbols:  44

A parte mais importante é provavelmente a seguinte:

Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total time: 13.1 seconds (100.0%)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total images loaded:  149 (128 from dyld shared cache)
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total segments mapped: 60, into 1700 pages with 112 pages pre-fetched
Jul 27 13:56:17 Hlung TrySlowAppSwift[4965] <Notice>: total images loading time: 12.8 seconds (97.9%)

É preciso um todo12,8 segundos (97,9%) para carregar as imagens. Mas este projeto vazio não possui nenhum arquivo de imagem. Examinei os pods e acho que eles também não possuem uma quantidade significativa de arquivos de imagem. Eu ainda estou preso aqui.

Comparando com o resultado de Bryan, o mesmo código, mas executado no iPhone 6. A porcentagem de tempo de carregamento das imagens também é alta.

Jul 22 16:44:02 iPhone-6 TrySlowAppSwift[939] <Notice>: total time: 1.9 seconds (100.0%)
Jul 22 16:44:02 iPhone-6 TrySlowAppSwift[939] <Notice>: total images loaded:  148 (127 from dyld shared cache)
Jul 22 16:44:02 iPhone-6 TrySlowAppSwift[939] <Notice>: total segments mapped: 60, into 1756 pages with 164 pages pre-fetched
Jul 22 16:44:02 iPhone-6 TrySlowAppSwift[939] <Notice>: total images loading time: 1.5 seconds (81.6%)

Além disso, há outra pista. Durante a tela inicial, existem várias linhas de log dizendo<Error>: SecTrustEvaluate [leaf CriticalExtensions IssuerCommonName]. Ao pesquisar no Google, apenas revelamos que há algum problema de aplicativo corporativo, o que não me ajuda muito.

No geral, eu ainda estou preso. T_T

questionAnswers(4)

yourAnswerToTheQuestion