CocoaPods / CocoaPods

The Cocoa Dependency Manager.
https://cocoapods.org/
Other
14.53k stars 2.62k forks source link

"Multiple commands produce" error in "[CP] Copy dSYMs" phase #10373

Closed acecilia closed 3 years ago

acecilia commented 3 years ago

Report

What did you do?

Make a podspec with more than one binary framework, and try to build the resulting target

What did you expect to happen?

The target builds without issues

What happened instead?

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-aherercskthrkyduwuqzcfkuhrig/Build/Products/Debug-maccatalyst/Binaries/1A3DADB5-A46D-3DB6-B372-9EC26653046F.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-aherercskthrkyduwuqzcfkuhrig/Build/Products/Debug-maccatalyst/Binaries/79247F36-4886-3FFB-BAF9-89BCDCFC553F.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-aherercskthrkyduwuqzcfkuhrig/Build/Products/Debug-maccatalyst/Binaries/77A04A36-9A16-39FD-B9C0-94FC2AFB0E41.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-aherercskthrkyduwuqzcfkuhrig/Build/Products/Debug-maccatalyst/Binaries/E29C8425-1A22-3071-9B0A-170C895E6D7B.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

** BUILD FAILED **

CocoaPods Environment

Cocoapods 1.10.0 Catalina 10.15.7

Project that demonstrates the issue

Run make build from the root of https://github.com/acecilia/cocoapods_bcsymbolmap

The issue explained:

When a pod contains multiple vendored frameworks, the bcsymbolmap files are duplicated once per vendored framework, which leads to the "Multiple commands produce" error. You can see this by looking at the files Binaries-copy-dsyms-input-files.xcfilelist, Binaries-copy-dsyms-output-files.xcfilelist and Binaries-copy-dsyms.sh. For example, see Binaries-copy-dsyms.sh: note how the four last lines are duplicated:

...
install_dsym "${PODS_ROOT}/../Carthage/Build/iOS/DifferenceKit.framework.dSYM"
install_dsym "${PODS_ROOT}/../Carthage/Build/iOS/DiffableDataSources.framework.dSYM"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/E6648ED0-2334-3AEB-9EE4-687A0F254871.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/77A04A36-9A16-39FD-B9C0-94FC2AFB0E41.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/79247F36-4886-3FFB-BAF9-89BCDCFC553F.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/95FF4DFC-505C-3812-A9F7-9A981B576312.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/E6648ED0-2334-3AEB-9EE4-687A0F254871.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/77A04A36-9A16-39FD-B9C0-94FC2AFB0E41.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/79247F36-4886-3FFB-BAF9-89BCDCFC553F.bcsymbolmap"
install_bcsymbolmap "${PODS_ROOT}/../Carthage/Build/iOS/95FF4DFC-505C-3812-A9F7-9A981B576312.bcsymbolmap"

Temporary workaround:

Add a post install step that removes the duplicates:

def adjust_copy_dsyms_phase(installer)
  installer.development_pod_targets.each do |pod_target|
    [
      pod_target.copy_dsyms_script_input_files_path, 
      pod_target.copy_dsyms_script_output_files_path, 
      pod_target.copy_dsyms_script_path
    ].each { |file| 
      remove_duplicated_bcsymbolmap_lines(file) if File.exist?(file) 
    }
  end
end

def remove_duplicated_bcsymbolmap_lines(path)
  top_lines = []
  bcsymbolmap_lines = []
  for line in File.readlines(path).map { |line| line.strip }
    if line.include? ".bcsymbolmap"
      bcsymbolmap_lines.append(line)
    else
      top_lines.append(line)
    end
  end

  final_lines = top_lines + bcsymbolmap_lines.uniq
  File.open(path, "w+") do |f|
    f.puts(final_lines)
  end
end

post_install do |installer|
  adjust_copy_dsyms_phase(installer)
end

Related issues:

alouanemed commented 3 years ago

I have the same issue when updated to 1.10.1.

for the row around, where do you call the post function ? Thanks.

-- EDIT well I was able to callit post install but it seem that is array is empty

installer.development_pod_targets.each do |pod_target|

ayoubkhayatti commented 3 years ago

I've the same issue, I tried other installations result https://rubydoc.info/gems/cocoapods/Pod/Installer/ but still not working. I'm also using cocoapods-binary.

acecilia commented 3 years ago

@alouanemed In case you are finding the issues on pods that are not development pods, see here other options: https://rubydoc.info/gems/cocoapods/Pod/Installer/

ayoubkhayatti commented 3 years ago

https://github.com/CocoaPods/CocoaPods/issues/10373#issuecomment-779852756 ☝ development_pod_targets returns an empty array. So I tried pod_targets with returns an array of PodTarget but the methods (copy_dsyms_script_input_files_path...) are returning nothing. I'm really not sure if I'm going the right way.

alouanemed commented 3 years ago

@ayoubkhayatti same here

carlosmellado commented 3 years ago

@ayoubkhayatti same here too

dnkoutso commented 3 years ago

@acecilia do you happen to have a sample app so i can diagnose and fix? i think the fix is relatively easy.

acecilia commented 3 years ago

@dnkoutso yes I do, it’s linked in the description if this issue:

Run make build from the root of https://github.com/acecilia/cocoapods_bcsymbolmap

dnkoutso commented 3 years ago

ah thanks! sorry i missed that!

dnkoutso commented 3 years ago

On Xcode 13 I am getting:

Create build description
Build description signature: dcd58b78c29caedaa5a03ca10c52c829
Build description path: /Users/dimitris/Library/Developer/Xcode/DerivedData/TestProject-batvsuuezakmcmfanseecdxlnhvv/Build/Intermediates.noindex/XCBuildData/dcd58b78c29caedaa5a03ca10c52c829-desc.xcbuild

note: Build preparation complete
note: Building targets in parallel
** BUILD SUCCEEDED ** [0.117 sec]
dnkoutso commented 3 years ago

And on Xcode 12.1

xcodebuild -workspace TestProject.xcworkspace -scheme SharedScheme build
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace TestProject.xcworkspace -scheme SharedScheme build

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

** BUILD SUCCEEDED ** [0.109 sec]

I am afraid I cannot reproduce so far by running make build.

acecilia commented 3 years ago

@dnkoutso weird. I just did:

git clone https://github.com/acecilia/cocoapods_bcsymbolmap
cd cocoapods_bcsymbolmap
make build

And got:

...
xcodebuild -workspace TestProject.xcworkspace -scheme SharedScheme build
Command line invocation:
    /Applications/Xcode_12.3.app/Contents/Developer/usr/bin/xcodebuild -workspace TestProject.xcworkspace -scheme SharedScheme build

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-bcxlgxqqiqdynlelmdzrtwwbwzhz/Build/Products/Debug-maccatalyst/Binaries/79247F36-4886-3FFB-BAF9-89BCDCFC553F.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-bcxlgxqqiqdynlelmdzrtwwbwzhz/Build/Products/Debug-maccatalyst/Binaries/0E38C1F5-D8B5-3D48-A040-46DBCA607CEB.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-bcxlgxqqiqdynlelmdzrtwwbwzhz/Build/Products/Debug-maccatalyst/Binaries/77A04A36-9A16-39FD-B9C0-94FC2AFB0E41.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

Build system information
error: Multiple commands produce '/Users/andres.luque/Library/Developer/Xcode/DerivedData/TestProject-bcxlgxqqiqdynlelmdzrtwwbwzhz/Build/Products/Debug-maccatalyst/Binaries/C6D14AB8-CEF7-3F9C-B998-448B0DEA0AFC.bcsymbolmap':
1) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”
2) That command depends on command in Target 'Binaries' (project 'Pods'): script phase “[CP] Copy dSYMs”

** BUILD FAILED **

Here some info about my machine:

$ xcodebuild -version 
Xcode 12.3
Build version 12C33

$ carthage version 
0.38.0

$ xcodegen --version
Version: 2.20.0

Let me know if you need any more info from me. Thanks for looking into it! 🙌

EDIT: I tested running it with Xcode 12.5.1 (12E507) and got a similar result. I am running MacOS 11.4 (big sur). I did a small change in the https://github.com/acecilia/cocoapods_bcsymbolmap repository, to make sure that the carthage step runs every time. Please try again 🙏

dnkoutso commented 3 years ago

will do thanks!

dnkoutso commented 3 years ago

thanks @acecilia i was able to reproduce. I think I know the issue and will have a PR up hopefully today.

dnkoutso commented 3 years ago

@acecilia one work around you can do is place the pre-built frameworks into another sub-folder.

For example:

./Carthage/Build/iOS/DifferenceKit.framework
./Carthage/Build/iOS/DiffableDataSources.framework

can be

./Carthage/Build/iOS/DifferenceKit/DifferenceKit.framework
./Carthage/Build/iOS/DiffableDataSources/DiffableDataSources.framework

Should fix this issue.

dnkoutso commented 3 years ago

Fix here https://github.com/CocoaPods/CocoaPods/pull/10800

PoissonBallon commented 2 years ago

It does not seem to be fixed on 1.11.1 with cocoapods-binary :/

dnkoutso commented 2 years ago

Please file an issue to the cocoapods-binary plugin. Otherwise, if you believe this is a bug with cocoapods itself, please open a new issue and provide instructions as well as a sample app without cocoapods-binary for us to diagnose and assist you!

acecilia commented 2 years ago

@PoissonBallon I can confirm that the sample project at https://github.com/acecilia/cocoapods_bcsymbolmap works well with cocoapods 1.11.0. Happy to take a PR from you if you manage to change it in a way that the failure is reproducible