Xcode 9.3升级后项目编译失败,报Abort trap:6错误求助
Hey there, sorry to hear you're stuck with this weird compile error after upgrading to Xcode 9.3—this usually ties into changes in the LLVM compiler that comes with the new Xcode version. Let's go through the most common fixes that have worked for others:
1. Dial Back Compiler Optimization
Xcode 9.3's default optimization settings might be triggering an LLVM bug. Here's how to adjust it:
- Open your project target, go to Build Settings
- Search for
Optimization Level - For the failing configuration (usually Debug), change the value from
Fastest, Smallest [-Os]toNone [-O0] - After changing, clean your project (
Cmd + Shift + K) and delete your Derived Data to be safe. Run this command in Terminal to wipe Derived Data:rm -rf ~/Library/Developer/Xcode/DerivedData
2. Hunt for Suspect Code Patterns
Sometimes non-standard code that worked in older Xcode versions breaks with the new compiler. Check these areas:
- Objective-C/Swift Interop: If you're mixing languages, look for
@objcmethods with conflicting signatures, or improper use of__bridge/__bridge_transferin pointer conversions. - Block Syntax: Make sure you're not having accidental retain cycles or malformed block definitions (like missing semicolons or incorrect variable captures).
- Outdated C/Obj-C Syntax: Avoid deprecated constructs like manual
@synthesizefor auto-synthesizable properties, or non-standard type casts.
3. Update or Recompile Third-Party Libraries
Older third-party binaries might not be compatible with Xcode 9.3's compiler. Try these steps:
- If you're using CocoaPods, run
pod updateto pull the latest versions of your dependencies. - For static libraries you compile manually, recompile them using Xcode 9.3 to ensure compatibility.
- If a specific library is causing the issue, check its repo to see if other users have reported the same problem and if there's a fix available.
4. Reset Xcode's State
Sometimes Xcode's cached state gets corrupted after an upgrade:
- Quit Xcode completely, then restart it.
- Clean your build folder (
Cmd + Option + Shift + K). - If that doesn't work, reset Xcode's preferences by deleting the plist file:
(You'll need to reconfigure some Xcode settings after doing this.)rm ~/Library/Preferences/com.apple.dt.Xcode.plist
If none of these work, try creating a brand new Xcode project and migrating your files one by one—this will help you pinpoint exactly which file or module is triggering the error.
内容的提问来源于stack exchange,提问作者the monk

