首页 > 解决方案 > App Clip 可以在 iOS Cocoapods 项目中使用吗?

问题描述

我们的应用程序是在 2018 年中期使用 Swift 4 创建的,其他 3rd 方依赖于 Cocoapods。我添加了一个 Clip 目标,项目结构与 session 下的下载链接给出的不同。运行这个目标,这里是崩溃错误:

Reason: image not found

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /private/var/containers/Bundle/Application/57185773-B735-4EE5-BB51-790DF004A85B/kt_iOS_Clip.app/kt_iOS_Clip
  Reason: image not found
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/Developer/Library/PrivateFrameworks/GPUTools.framework/libglInterpose.dylib:/usr/lib/libMTLCapture.dylib

这是 Podfile:

platform :ios, '10.0'
inhibit_all_warnings!

target '<Main App>' do
    use_frameworks!
  
    pod 'SnapKit' , '4.2.0'                     
    pod 'Alamofire' , '4.7.3' 
    ......                  
    
  target '<Main App>Tests' do
    inherit! :search_paths
  end
  
  swift_41_pod_targets = ['Spring','PKHUD', 'FSPagerView', 'SQLite.swift','FaveButton']
  
  post_install do | installer |
      
      installer.pods_project.targets.each do |target|
          if target.name == 'Cache'
              target.build_configurations.each do |config|
                  level = '-Osize'
                  config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = level
                  puts "Set #{target.name} #{config.name} to Optimization Level #{level}"
              end
          end
          if swift_41_pod_targets.include?(target.name)
              
              target.build_configurations.each do |config|
                  
                  config.build_settings['SWIFT_VERSION'] = '4.1'
                  
              end
              
          end
          
      end
      
  end

  target '<Main App>UITests' do
    inherit! :search_paths
  end

end

标签: ioswwdcapple-appclips

解决方案


正如提到的其他答案,单独的应用程序剪辑目标并use_modular_headers!为我工作

platform :ios, '13.0'

target 'MainAppTarget' do
  
  use_frameworks!

  pod 'Firebase/Analytics'
  pod 'Firebase/RemoteConfig'

  target 'MainAppTargetTests' do
    inherit! :search_paths
  end

end

target 'AppClipTarget' do
  
  use_modular_headers!

  pod 'Firebase/Analytics'

  target 'AppClipTargetTests' do
    inherit! :search_paths
  end

  target 'AppClipTargetUITests' do
  end

end


推荐阅读