Dynamic frameworks aren't copied in the AppClips

I'm adding AppClip's target in our existing project. (Xcode version 12 beta 2).
Our project uses cocoapods dependencies, but the podfile's settings for each target is the same.

When I launch AppClip, I get an error like:

dyld: Library not loaded: @rpath/{pod's name}.framework/{pod's name}
Referenced from: ~/Library/Developer/CoreSimulator/Devices/54FBE668-8806-41F4-B7AC-8A9D5C3427BA/data/Containers/Bundle/Application/F8C1318E-FC26-4806-8FA3-1E36C240F036/AppClip.app/AppClip
Reason: image not found
dyld: launch, loading dependent libraries


I checked the paths in FrameWorkSearchPaths's property (build settings) and Runpath Search Path. They're correct for every target, including AppClip.

I compared two targets (App's target and AppClip's target) and found out that for some reason dynamic frameworks are not copied into the AppClip when AppClip target building, but copied into App's target.
I checked it in AppClip's and App's folder with frameworks, but it's missing at this address:

~/Library/Developer/CoreSimulator/Devices/54FBE668-8806-41F4-B7AC-8A9D5C3427BA/data/Containers/Bundle/Application/E0EAB11B-B2D1-44F4-AD95-58C9D5CB4793/AppClip.app/

The parameters in these build settings' targets are identical.
Answered by DanM123 in 622812022
I silver this issue by adding a build phase that copies cocoapods.

Check differences between your normal app scripts and the App Clip and you will notice that this step is missing
Accepted Answer
I silver this issue by adding a build phase that copies cocoapods.

Check differences between your normal app scripts and the App Clip and you will notice that this step is missing
It works, thanks!
I got one step closer to resolving issues for App Clips regarding embedding dynamic frameworks but I still get an unexpected error.

Code Block
objc[62067]: Class CSAudioRecorder is implemented in both /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SpeakerRecognition.framework/SpeakerRecognition (0x13b70b720) and /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/CoreSpeech.framework/CoreSpeech (0x13abb20d8). One of the two will be used. Which one is undefined.
objc[62067]: Class CSOSTransaction is implemented in both /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SpeakerRecognition.framework/SpeakerRecognition (0x13b70b540) and /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/CoreSpeech.framework/CoreSpeech (0x13abb22b8). One of the two will be used. Which one is undefined.
2020-07-24 15:23:53.426784-0700 MyAppClips[62067:380775] libMobileGestalt MobileGestaltCache.c:38: No persisted cache on this platform.


I'm not using CSAudioRecorder at all in my app project.

Having the same issue, the app is compiling and I just skipped this for now.
Usually when you include a framework into a project it is embedded only by a single target (e.g. the main app) and then is used by different extensions as well.

With app clips things are different, they are installed separately from other targets. Therefore, you need to have the “Embed & Sign” option to be enabled for all relevant 3rd party frameworks on the App Clip target settings page in Xcode.
I can't get this to work. Can someone guide me with individual steps here. I have wasted 2 days on this.. Please help. Thanks
You need to create a new build phase "Embed Pods Frameworks" and define the correct path to your app clip's shell script. See how it's done in your main app.

You can follow these for all dynamic framework attachment. i'm take example of Cocoa pods.


Step 1:

Attach only necessary pods framework to the app clips target.(we want 10 mb size)

Code Block
#MARK: - App Clips WallPaper extension
target 'Wallpaper Clips' do
  use_frameworks!
  pod 'ReachabilitySwift'
  pod 'Kingfisher'
  #Custom Pods
  pod "ViewAnimator"
end

Step 2:


Go to Clip Target > General > Frameworks, library Embedded
Check Pod embedded if not do it.

Step 3:


Go to Clips > Build Phases
Add New Run Script
Rename with "[CP] Embed Pods Frameworks"
Now check Run script with your Main App target Script

In my Case


Main Target

Shell Script
"${PODS_ROOT}/Target Support Files/Pods-Wallpaper/Pods-Wallpaper-frameworks.sh"

Input Files
${PODSROOT}/Target Support Files/Pods-Wallpaper/Pods-Wallpaper-frameworks.sh
${BUILT
PRODUCTSDIR}/Alamofire/Alamofire.framework
${BUILT
PRODUCTSDIR}/Bond/Bond.framework
${BUILT
PRODUCTSDIR}/Kingfisher/Kingfisher.framework
${BUILT
PRODUCTSDIR}/ViewAnimator/ViewAnimator.framework
${BUILT
PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework

Output Files
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/Alamofire.framework
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/Bond.framework
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/Kingfisher.framework
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/ViewAnimator.framework
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/Reachability.framework

App Clips Target

Shell Script
"${PODS_ROOT}/Target Support Files/Pods-Wallpaper Clips/Pods-Wallpaper Clips-frameworks.sh"

Input Files
${PODSROOT}/Target Support Files/Pods-Wallpaper Clips/Pods-Wallpaper Clips-frameworks.sh
${BUILT
PRODUCTSDIR}/Kingfisher/Kingfisher.framework
${BUILT
PRODUCTSDIR}/ViewAnimator/ViewAnimator.framework
${BUILT
PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework

Output Files
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/Kingfisher.framework
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/ViewAnimator.framework
${TARGETBUILDDIR}/${FRAMEWORKSFOLDERPATH}/Reachability.framework

Finally Clean, Build and Run.

Comment on this if you get an error again or haven't solved
I've solved this problem by upgrading the cocoapods version 1.10.0 beta2
Dynamic frameworks aren't copied in the AppClips
 
 
Q