Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can App Clip be used in an iOS Cocoapods project?

Our App was created in 2018 mid using Swift 4, and other 3rd party depended with Cocoapods. I add one Clip target, the project structure is different from that given by the download link under session. Run this target, here are the crash errors:

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

Here is 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
like image 497
Eason Avatar asked Dec 02 '22 09:12

Eason


1 Answers

As other answers mentioned, separate app clip target and use_modular_headers! worked for me

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

like image 50
Thein Avatar answered Dec 04 '22 22:12

Thein