spotify / XCRemoteCache

Other
830 stars 53 forks source link

Multiple commands produce error after adding Cocoapods pluging #53

Closed rudrankriyam closed 2 years ago

rudrankriyam commented 2 years ago

I've been trying to build the cache on CI/CD in producer mode, and it works fine on a normal project.

After adding the cocoapods plugin in an empty project, I'm getting the following error:

error: Multiple commands produce '/Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Products/Debug-iphoneos/XCRemoteCacheExample.app/Modules/XCRemoteCacheExample.swiftmodule/arm64.swiftmodule.md5':
1) That command depends on command in Target 'XCRemoteCacheExample' (project 'XCRemoteCacheExample'): script phase “[RC] RemoteCache_postbuild”
2) That command depends on command in Target 'XCRemoteCacheExample' (project 'XCRemoteCacheExample'): script phase “[XCRC] Postbuild”

error: Multiple commands produce '/Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Products/Debug-iphoneos/XCRemoteCacheExample.app/Modules/XCRemoteCacheExample.swiftmodule/arm64-apple-ios.swiftmodule.md5':
1) That command depends on command in Target 'XCRemoteCacheExample' (project 'XCRemoteCacheExample'): script phase “[RC] RemoteCache_postbuild”
2) That command depends on command in Target 'XCRemoteCacheExample' (project 'XCRemoteCacheExample'): script phase “[XCRC] Postbuild”

error: Multiple commands produce '/Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex/XCRemoteCacheExample.build/Debug-iphoneos/XCRemoteCacheExample.build/postbuild.d':
1) That command depends on command in Target 'XCRemoteCacheExample' (project 'XCRemoteCacheExample'): script phase “[RC] RemoteCache_postbuild”
2) That command depends on command in Target 'XCRemoteCacheExample' (project 'XCRemoteCacheExample'): script phase “[XCRC] Postbuild”

CreateBuildDirectory /Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex
    cd /Users/builder/clone
    builtin-create-build-directory /Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex

warning: duplicate output file '/Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Products/Debug-iphoneos/XCRemoteCacheExample.app/Modules/XCRemoteCacheExample.swiftmodule/arm64.swiftmodule.md5' on task: PhaseScriptExecution [XCRC] Postbuild /Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex/XCRemoteCacheExample.build/Debug-iphoneos/XCRemoteCacheExample.build/Script-FE9F3EEF32EDC6845D218273.sh (in target 'XCRemoteCacheExample' from project 'XCRemoteCacheExample')
warning: duplicate output file '/Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Products/Debug-iphoneos/XCRemoteCacheExample.app/Modules/XCRemoteCacheExample.swiftmodule/arm64-apple-ios.swiftmodule.md5' on task: PhaseScriptExecution [XCRC] Postbuild /Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex/XCRemoteCacheExample.build/Debug-iphoneos/XCRemoteCacheExample.build/Script-FE9F3EEF32EDC6845D218273.sh (in target 'XCRemoteCacheExample' from project 'XCRemoteCacheExample')
warning: duplicate output file '/Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex/XCRemoteCacheExample.build/Debug-iphoneos/XCRemoteCacheExample.build/postbuild.d' on task: PhaseScriptExecution [XCRC] Postbuild /Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex/XCRemoteCacheExample.build/Debug-iphoneos/XCRemoteCacheExample.build/Script-FE9F3EEF32EDC6845D218273.sh (in target 'XCRemoteCacheExample' from project 'XCRemoteCacheExample')

rcinfo file:

---
primary_repo: https://github.com/redacted/XCRemoteCacheExample.git
primary_branch: main
cache_addresses:
 - https://redacted.amazonaws.com/
aws_secret_key: redacted
aws_access_key: redacted
aws_region: ap-south-1
aws_service: s3
mode: producer

Podfile:

platform :ios, '14.0'

plugin 'cocoapods-xcremotecache'

xcremotecache({
    'cache_addresses' => ['https://redacted.amazonaws.com/'], 
    'primary_repo' => 'https://git@github.com/redacted/XCRemoteCacheExample.git',
    'mode' => 'producer',
    'final_target' => 'XCRemoteCacheExample',
    'primary_branch' => 'main',
})

target 'XCRemoteCacheExample' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Add the Firebase pod for Google Analytics
pod 'Kingfisher', '~> 7.0'
end

Command to build project:

xcremotecache/xcprepare integrate --input XCRemoteCacheExample.xcodeproj --mode producer --final-producer-target XCRemoteCacheExample

Any help on what I'm doing wrong is appreciated.

polac24 commented 2 years ago

Seems that you integrate your project twice: once manually (xcprepate integrate) and with a CocoaPods plugin. If you use a CocoaPods plugin, calling xcprepare integrate is redundant.

rudrankriyam commented 2 years ago

Ah. That makes sense.

Running another build after removing xcprepare integrate gives:

error: Postbuild step failed unsuccessfulResponse(status: 403)

** BUILD FAILED **

The following build commands failed:
    PhaseScriptExecution [XCRC]\ Postbuild /Users/builder/Library/Developer/Xcode/DerivedData/XCRemoteCacheExample-hhatcayujzjpinbwisqztfyoxjld/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/Kingfisher.build/Script-46EB2E00000B90.sh (in target 'Kingfisher' from project 'Pods')

After pod install, I do get XCRemoteCache enabled, though. Looks like it is related to the pod?

polac24 commented 2 years ago

I assume you are running a producer build. The 403 response may mean that you are not authorized to make PUT requests to upload files. For more logs, have a look on https://github.com/spotify/XCRemoteCache/blob/master/docs/FAQ.md#how-can-i-find-xcremotecache-logs

rudrankriyam commented 2 years ago

Running a project in producer mode without the cocoapods plugin works fine, so I know that the AWS server is working. On building on a local machine, I saw that after doing pod install, XCRemoteCache removes the following values from the rcInfo file:

aws_secret_key: redacted
aws_access_key: redacted
aws_region: ap-south-1
aws_service: s3

And hence, I end up getting the 403 response. Do you know what's the issue?

Update: Manually adding the above four values in rcInfo in both the project and in the pods directory after pod install works.

Is it a bug or do I've set the values in the Podfile too?

Update: I had to set it in the Podfile too, my mistake. Closing this. Thanks for the help!