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

后端 未结 11 2001
一生所求
一生所求 2021-01-11 10:10

I am getting this error:

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

** ARCHIVE FAILED **

The following build co

相关标签:
11条回答
  • 2021-01-11 11:01

    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.

    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".

    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!

    0 讨论(0)
  • 2021-01-11 11:06

    I solved this by reducing the hierarchy of groups in Xcode.

    e.g. original files at project_name/project_name/About/Model/Text I removed the groups "Model", "Text" and moved files under project_name/project_name/About/

    0 讨论(0)
  • 2021-01-11 11:13

    xcode11

    -build setting

    -user-defined

    -add setting: USE_SWIFT_RESPONSE_FILE

    -setValue: YES

    Doing this you enable xcode to have more files than is allowed. But im not sure if this always solve the problem.

    0 讨论(0)
  • 2021-01-11 11:13

    If you faced this issue on your Flutter project while building in Release mode (or Archive) check out my this answer: https://stackoverflow.com/a/61446892/5502121 Long story short:

    • set your build system to New Build System in File > Project Settings…
    • remove ios and build_ios folders
    • run flutter create . to init new ios module
    • run pod install
    • run flutter pub get
    • check your Xcode build config (it should be Release mode and General iOS Device)

    and you're good to go

    0 讨论(0)
  • 2021-01-11 11:14

    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 above inclusion,
    2. make them explicitly set in the Project -> Info -> Configuration, as follows:

    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.

    0 讨论(0)
提交回复
热议问题