Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: unable to spawn process (Argument list too long) in Xcode Build

I am getting this error:

"error: unable to spawn process (Argument list too long)

** ARCHIVE FAILED **

The following build commands failed: CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (1 failure)

Exitcode =65 "

I went through this link: Xcode export localization throws error "Argument list too long"

This article provides a good temporary solution of the problem stating to reduce the path hierarchy. But this does not seem to be an appropriate approach. Can anyone provide me with a different approach to the solution for this problem?

Screenshot added

like image 813
Falguni Avatar asked Nov 09 '18 12:11

Falguni


3 Answers

In my case, it was about custom configurations in .xcconfig files. My config files were including Pods configurations like:

// Development.xcconfig

#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.debug (development).xcconfig"

#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.release (development).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.release (development).xcconfig"
// Production.xcconfig

#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.debug (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.debug (production).xcconfig"

#include "Pods/Target Support Files/Pods-MyProject/Pods-MyProject.release (production).xcconfig"
#include "Pods/Target Support Files/Pods-MyProjectTests/Pods-MyProjectTests.release (production).xcconfig"

This produced the error you mentioned, when I added Firebase pods into my Podfile.

So to make this compile again I had to:

  1. remove all inclusion (#include ...),
  2. set them explicitly in the Project -> Info -> Configuration, as follows:

Solution

Quick tip:

If you don't want manually setting up corresponding target configurations (those with red icon), mark them as None and run pod install. This will automatically change it for you. Quick tip

like image 51
blaszku Avatar answered Oct 17 '22 17:10

blaszku


A few days ago I faced a similar challenge. I want to provide details and share my research with SO community.

First of all I found this thread and I followed the link in the asked question.
And yes, thats right, the answer marked in the link is correct, but the solutions to this problem did not suit me.

Problem

In my case, I had this problem when I changed the folder hierarchy in my project to be more convenient and suitable for me.
@oOEric option did not suit me, because according to the rules, the hierarchy of groups in Xcode should coincide with the hierarchy of folders in the system.
But I've already had about 1680 swift files to compiling.

The problem was that I had too long path to the compiled files and their number was too large.

Research

Then I start research and found swift jira with the same bug. Here some links:

  1. Main
  2. Linked Issue 1
  3. Linked Issue 2
  4. Linked Issue 3
  5. Bug on Open Radar

But here I didn't find some solutions for me.

Most of all I was pleased with this response of the swift developers.

Again, this is an Xcode-side issue, not a Swift-side issue. Commenting here won't make the Xcode engineers work any faster! (We're not all the same people at Apple.)

Okey, after this answer, I was finally convinced that if it is an Xcode bug, then the solution should be sought in Xcode.

Solutions

  1. Temporary solution

You need to move your project higher in the hierarchy of your system.

I choose this one, because I have really big project and the use of other solutions will require more than one day from me.

In my case, I conducted an experiment and calculated that the length of the path to the project should be no more than 50 characters.

But this is a temporary solution. If your project grows further, you will have to shorten the path or use other solutions.

  1. Cocoa Touch Framework target

This solution is suitable for files that do not use dependencies.

First of all you need to add Cocoa Touch Framework as a target to you main project.

enter image description here

This target should be added automatically to Embedded Binaries and Linked Framework and Libraries.

After this you need to find some files without dependencies and change target membership to your "TestTarget".

enter image description here

Don't forget classes, properties, methods, enums, protocols from cocoa touch framework should have open or public access.

And don't forget clean your DerivedData folder.

  1. Modular iOS

This solution has a more integrated approach.

If you want to use any dependencies in your Cocoa Touch Frameworks you should go to this guide and make more complex refactoring for your big project!

Link to solution

I think this is the best solution.

I hope this big answer will help someone!

like image 28
Vlad Krupenko Avatar answered Oct 17 '22 17:10

Vlad Krupenko


I solved this by setting build system to Legacy build system in file-> workspace setting -> select workspace setting

like image 4
user3257307 Avatar answered Oct 17 '22 16:10

user3257307