We are using new build system and Cocoapods 1.7.5 for our Xcode project. Our project (let's call it Y) is actually a development pod, but we also have written some codes to create an application demo (you know, to make builds faster and iterations quicker). These demo codes (AppDelegate.swift
, launch tasks etc.) are not included in the development pod. The remaining ~90 percent of the source codes and resource files (such as i18n strings and image resources) get packed into the development pod for another project (let's call it X) to use.
While developing, most of the changes occur to the dev pod part of Y, so we need to make sure that every slice of change is included when X does pod install
.
Recently we encountered a problem:
error: Multiple commands produce '/Users/x/Library/Developer/Xcode/DerivedData/Y-cawteybtitmeiafweribgqzkuhnr/Build/Products/Debug-iphoneos/Y.app/Assets.car':
1) Target 'Y' (project 'Y') has compile command with input '/Users/name/DEV/workspace/Y/SupportFiles/Assets.xcassets'
2) That command depends on command in Target 'Y' (project 'Y'): script phase “[CP] Copy Pods Resources”
After hours of searching multiple commands produce assets.car
on Google, we finally saw a plausible explanation:
*.xcassets of Copy Bundle Resources --> Assets.car
*.xcassets of [CP] Copy Pods Resource --> other Assets.car
The first one covers second in the New Build System,That's the reason.
When we manually remove the ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car
from output files of [CP] Copy Pods Resource
, the error is gone and everything works fine. However, whenever we git checkout
to another branch, or pod install
, or pod update
, there is a pretty high chance that the ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car
appears again in the output files of [CP] Copy Pods Resource
. We need to manually remove it again and again, which is tedious and frustrating.
Then we started to question: Who is behind all this? Who is responsible for adding ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Assets.car
to the output files of [CP] Copy Pods Resource
? We focused our sight onto Y.podspec
and found these lines:
s.resource_bundles = {
'Y' => ['Resources/*'], # assets, lottie etc.
'YAuto' => ['auto_resources/*'] # i18n strings etc.
}
We thought we were using resource_bundles
wrong, so we looked it up, again on Google. Surprisingly, using resource_bundles
over resources
is recommended by official documentation. Additionally, we couldn't find any inappropriate usage in terms of resource_bundles
, leaving us out of options.
Can somebody help? I was thinking maybe we could patch Y.xcworkspace
in the post_install
script in Podfile
, but I don't know how.