spotify / XCRemoteCache

Other
825 stars 50 forks source link

Prebuild step failed with error: unsuccessfulResponse(status: 404) #228

Closed amiit closed 8 months ago

amiit commented 8 months ago

My integration setup

[ ] CocoaPods cocoapods-xcremotecache plugin

Expected/desired behavior remote caching should work

Minimal reproduction of the problem with instructions Updated Podfile with below code:

plugin 'cocoapods-xcremotecache' xcremotecache({ 'cache_addresses' => ['https://PROJECT_NAME.s3.ap-south-1.amazonaws.com/'], 'primary_repo' => 'git@bitbucket.org/PROJECT_NAME.git', 'mode' => 'consumer', 'final_target' => 'PROJECT_NAME', 'primary_branch' => 'develop', 'aws_secret_key' => 'SECRET_KEY', 'aws_access_key' => 'ACCESS_KEY', 'aws_region' => 'ap-south-1', 'aws_service' => 's3' })

After this run 'pod install' which printed in the console: [XCRC] XCRemoteCache enabled

From same machine separately via Automatic integration option, I added producer mode and from the same branch(develop) updated the cache in the remote (can see file/marker/meta related to latest commit in the S3 bucket).

Now when I am running project for consumer mode as mentioned in the above podfile, Its not using cache data and for every pod including final_target project I can see the message in the Xcode build log: [RC] Disabled remote cache

I am using static libraries. I am not getting what is going wrong here. For producer mode everything is working fine (via automatic integration) but for consumer mode its not using cache. This consumer mode issue is coming for both automatic integration as well as for cocoapods plugin. Please help me in identifying what is going wrong here and how to fix this?

Producer Logs No issues here

Consumer Logs

 
 xcprebuild[57101:48ce29] (AFNetworking) Prebuild step failed with error: unsuccessfulResponse(status: 404)
 Df xcswiftc[57437:48d178] Fallbacking to compilation using swiftc.
 xcprebuild[5975:4b2bab] (PROJECT_NAME) Prebuild step failed with error: artifactLocationIsUnknown

Pods/Carthage file

 
plugin 'cocoapods-xcremotecache'
xcremotecache({
  'cache_addresses' => ['https://PROJECT_NAME.s3.ap-south-1.amazonaws.com/'],
  'primary_repo' => 'git@bitbucket.org/PROJECT_NAME.git',
  'mode' => 'consumer',
  'final_target' => 'PROJECT_NAME',
  'primary_branch' => 'develop',
  'aws_secret_key' => 'SECRET_KEY',
  'aws_access_key' => 'ACCESS_KEY',
  'aws_region' => 'ap-south-1',
  'aws_service' => 's3'
})

Environment

Post build stats Others

polac24 commented 8 months ago

Hi! If I understand correctly, you want to generate artifacts from the "automation integration" but use them in the cocoapods mode. That is not supported. You have to produce and consume artifacts with the same integration.

So you have to pass 'mode' => 'producer', in the Podfile to produce artifacts.

amiit commented 8 months ago

Hi @polac24 Thanks for quick response. I tried producer and consumer both via pod option only still getting same issue during consumer mode: xcprebuild(POD_NAME) Prebuild step failed with error: unsuccessfulResponse(status: 404)

and for every pod this line I can see in the Xcode build logs: [RC] Disabled remote cache for POD_NAME

During 'pod install' I am getting remote cache enabled log. All these are static pods I am using in my project.

Is there anything else I am missing?

polac24 commented 8 months ago

There are many possible reasons like different configurations (Debug/Release etc.) or some targets are not stored on the server. I recommend looking for your logs (docs) on the consumer side to see which file gets 404 and why it doesn't exist in s3:

log show --predicate 'sender BEGINSWITH "xc"' --style compact --info --debug -last 10m

and also this list might be helpful

amiit commented 8 months ago

Thanks @polac24 , it's working now :)