What's the correct way to add Clip target in an existing old cocoapods project?

Our App was created in 2018 mid using Swift 4.2, 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 errors:

dyld: Library not loaded: @rpath/<3rd party name>.framework/<3rd party name>

  Referenced from: /private/var/containers/Bundle/Application/xxxx/xxxx/Clip
  Reason: image not found
dyld: launch, loading dependent libraries
DYLDLIBRARYPATH=/usr/lib/system/introspection
DYLDINSERTLIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/GPUTools.framework/libglInterpose.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

Accepted Reply

Remove all flags from:
Clip Target -> Build Settings -> Linking --> Other Linker Flags

Replies

Hard to say without your Pod file. But something like this should work:

Code Block podspec
project 'example.xcodeproj'
platform :ios, '10.0'
abstract_target 'ExampleApp' do
use_frameworks!
pod 'Alamofire', '~> 4.9.1'
target 'Main App' do
end
target 'App Clip' do
end
end


The targets should match the target names in Xcode. You can of course just include a pod in one of the individual targets if needed.
Thank you jords,unfortunately dosen't work 😂
Here is my podfile:

Code Block platform :ios, '10.0'
inhibit_all_warnings!
target '<Main App>' do
use_frameworks!
pod 'Alamofire' , '4.7.3'
.......
target '<Main App>Tests' do
inherit! :search_paths
end
swift_41_pod_targets = ['Spring', '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



I think the issue is in the targets 'Build Phases' settings. If you check your main apps target you will find an 'Embed Pods Frameworks' entry. This one is missing in the App Clip Target. So the frameworks will not be included.

Unfortunately I haven't found a solution either. But maybe someone else has an idea and this hint is useful...
Remove all flags from:
Clip Target -> Build Settings -> Linking --> Other Linker Flags
In Clip target if we what to use 3rd party, here are 2 steps:

step1.
Modify Podfile --> usemodularheaders! not use_frameworks!
Like this:

Code Block
platform :ios, '10.0'
inhibit_all_warnings!
use_modular_headers!
def commonPods
pod '3rd name'
......
end
target 'kt_iOS_Clip' do
inherit! :complete
use_modular_headers!
commonPods
end
target 'kt_iOS' do
commonPods
......
# if 'modular' are not supported, use 'use_frameworks!' ......
# use_frameworks!
# pod 'xxxxxx'
end

step2.
Remove all flags from:
Clip Target -> Build Settings -> Linking --> Other Linker Flags
then add -l"SnapKit-library"

Agree with Spriter. Yesterday I meet the same problem too, because of NO 'Embed Pods Frameworks' in Build Phases, I manually added the 'Embed Pods Frameworks' and the problem has been fixed.
I'm having exactly the same issue. I haven't been able to fix it, however, I think it will be fixed as soon as there is a new stable Cocoapods version including this https://github.com/CocoaPods/CocoaPods/pull/9882
Adding 'Embed Pods Frameworks' manually works for me too.
We are still seeing this error after clearing the linker flags and using modular headers instead of frameworks for the target in the podfile.

Code Block
dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
 Referenced from: /Users/userName/Library/Developer/CoreSimulator/Devices/94E2B344-C3E5-4215-9ED6-CB16A4549108/data/Containers/Bundle/Application/2908495C-D3DA-4043-83AD-25A103B69827/myTestClip.app/myTestClip
 Reason: image not found
dyld: launch, loading dependent libraries


Including the framework under 'Target' -> 'General' -> 'Frameworks, Libraries, and Embedded Content' doesn't help either. Any help would be appreciated.