Xcode linker error: file too small for architecture x86_64

后端 未结 10 1364
深忆病人
深忆病人 2020-12-01 04:21

I\'m developing an application in Xcode.

When I try to build, this error comes up:

ld: in /Users/theodore/Library/Developer/Xcode/DerivedData/Tower-b         


        
相关标签:
10条回答
  • 2020-12-01 04:38

    Step 1. Go to: Project > Build Settings > Search Paths

    Step 2. Set "Always Search User Paths" to Yes

    Step 3. Build the project (You'll get a warning but the project will build.)

    Step 4. Set "Always Search User Paths" back to No and build again to eliminate the warning

    0 讨论(0)
  • 2020-12-01 04:42

    To automatically fix this issue Build Script Phase can be added. Goto Xcode -> Your Project -> Your Target -> Build Phases -> + -> New Run Script Phase

    Rename it to Xcode Link Fix and move it above Compile Sources phase. Paste this into script body:

    # Legacy build system
    legacy_dir=`dirname "${LD_DEPENDENCY_INFO_FILE}"`
    if [ -d "${legacy_dir}" ]; then
        find "${legacy_dir}" -size 0 | while read -d $'\n' file; do
            rm "$file"
        done
    fi
    
    # New build system
    if [ -d "${OBJECT_FILE_DIR_normal}" ]; then
        find "${OBJECT_FILE_DIR_normal}" -size 0 | while read -d $'\n' file; do
            rm "$file"
        done
    fi
    

    This script checks for object files with zero size and removes them so when compilation is done in next step it success.

    You need to add this script for every app target if you have many.

    This script takes ~0.1 second to run and saves you from full project rebuild.

    0 讨论(0)
  • 2020-12-01 04:49

    just remove this file by run cmd in your terminal app:

    rm /Users/theodore/Library/Developer/Xcode/DerivedData/Tower-bkpdifuqssebjdgurzmtirbxejnn/Build/Intermediates/Tower.build/Debug/Tower.build/Objects-normal/x86_64/TWRAppDelegate.o

    0 讨论(0)
  • 2020-12-01 04:54

    You can just delete the TWRAppDelegate.o file and continue your build. Copy the full path mentioned in the error message and paste it behind an 'rm' command in your terminal. There's no need to clean/rebuild, delete derived data, add/remove the file from the project, etc.

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