Command CompileSwiftSources failed with a nonzero exit code XCode 13
Asked Answered
S

7

52

I am trying to run a project on the Xcode13, after running a pod cache clean --all, deleting the derived data, and running a pod update. When I clean the project and build it the following error appears:

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'Alamofire' from project 'Pods')
    cd /Users/aimoresa/MyProject-iOS/Pods
    export DEVELOPER_DIR\=/Applications/Xcode.app/Contents/Developer
    export SDKROOT\=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name Alamofire -Onone -enable-batch-mode -enforce-exclusivity\=checked @/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire.SwiftFileList -DDEBUG -D COCOAPODS -suppress-warnings -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk -target x86_64-apple-ios10.0-simulator -g -module-cache-path /Users/aimoresa/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Index/DataStore -swift-version 5 -I /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Products/Debug-iphonesimulator/Alamofire -F /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Products/Debug-iphonesimulator/Alamofire -c -j4 -output-file-map /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire.swiftmodule -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Alamofire-generated-files.hmap -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Alamofire-own-target-headers.hmap -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Alamofire-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Alamofire-project-headers.hmap -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Products/Debug-iphonesimulator/Alamofire/include -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/DerivedSources-normal/x86_64 -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/DerivedSources/x86_64 -Xcc -I/Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/DerivedSources -Xcc -DPOD_CONFIGURATION_DEBUG\=1 -Xcc -DDEBUG\=1 -Xcc -DCOCOAPODS\=1 -emit-objc-header -emit-objc-header-path /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Alamofire-Swift.h -import-underlying-module -Xcc -ivfsoverlay -Xcc /Users/aimoresa/Library/Developer/Xcode/DerivedData/LinkProject-bwzldrnlucfenpavteypbjybxdky/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module-overlay.yaml -working-directory /Users/aimoresa/InvestorCentre-iOS/Pods

Command CompileSwiftSources failed with a nonzero exit code
Schonfeld answered 21/9, 2021 at 22:51 Comment(2)
same here unfortunatelyMisanthropy
same here, But I'm facing this issue while archiving the buildRubeola
D
35

I had this problem surface in Xcode 13.0.

Mohamed Tarek's solution worked for me, but…

I was using cocoapods, so I needed a solution not blown away by pod install; or more specifically fixed with pod install.

Adding the following to the bottom of the Podfile resolved it.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
    # some older pods don't support some architectures, anything over iOS 11 resolves that
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end
Dreibund answered 29/9, 2021 at 23:27 Comment(6)
I used the same approach as your answer it works fine Thanks :)Schonfeld
This worked well for me. Thanks.Tautog
How do you edit the pod file? Mine just opens in terminalPetta
@RossRawlins there are many ways to open it, i add it to my Xcode project (but not to a target) - shortest path: right click in Finder, Open With, Text Edit - right click, Get Info, Open with: Text Edit will set that as permanent.Dreibund
Actually I'm working in react-native plugin. Should I add these lines in outer ios podfile , or internal example/ios podfile ?Hysterectomy
@zaid add to the top level Podfile, the update will occur in each of the PodsDreibund
M
8

Edited: For people who use Cocoapods, this answer might be useful: https://mcmap.net/q/344096/-command-compileswiftsources-failed-with-a-nonzero-exit-code-xcode-13


I also faced this issue, and it seems that there is a known issue on Xcode 13 as mentioned in this document: https://developer.apple.com/documentation/Xcode-Release-Notes/xcode-13-release-notes

Swift libraries depending on Combine may fail to build for targets including armv7 and i386 architectures. (82183186, 82189214)

Workaround: Use an updated version of the library that isn’t impacted (if available) or remove armv7 and i386 support (for example, increase the deployment target of the library to iOS 11 or higher).

If your app is for iOS 11 or higher, one of the libraries should be modified to target iOS 11 or higher (e.g., my app is for iOS 12 or higher).

For example, I am using GRDB.swift, and its minimum iOS version is 10.0. There was a discussion as an issue of this repo, and I followed that comment to solve this issue as follows:

  1. Fork the repository
  2. Change Package.swift to modify the minimum iOS version like:
let package = Package(
name: "GRDB",
platforms: [
    .iOS("12.0"),   // changed here
    .macOS("10.10"),
    .tvOS("9.0"),
    .watchOS("2.0"),
],
...
  1. Modify Podfile or Swift Package Manager (SPM) config to use my forked repository

I am using five libraries via SPM in my Xcode project, but applying the above method to only one of those libraries solved this issue.

There is also a related thread in the Apple forum: https://developer.apple.com/forums/thread/682285

Martian answered 23/9, 2021 at 11:49 Comment(1)
Not a solution, if you have to support iOS <12Baltazar
T
5

Open xcworkspace>Pods>Build Settings>iOS Deployment Target.

Set every pod minimum to iOS 11 or above.

Tumpline answered 23/9, 2021 at 15:51 Comment(0)
A
4

I got three pods giving me this error after update to Xcode 13. Luckily simple pod update fixed it. Though I have deployment target iOS 11 or higher so that may have helped as well.

Aruwimi answered 1/10, 2021 at 9:11 Comment(0)
T
1

It took me two days to resolve this, in my case, the error when running the pod install command was this:

CompileSwift normal x86_64 (in target 'PurchasesHybridCommon' from project 'Pods')

SOLUTION:

  1. Update react-native-purchases in package.json from "^4.3.1" to "^4.6.1"
  2. rm -rf ios/Pods;
  3. rm -rf node_modules;
  4. npm install or cd ios && pod install
System:
    OS: macOS 12.4
    CPU: Apple M1 Pro
Binaries:
    Node: 16.15.1
    npm: 8.11.0
Managers:
    CocoaPods: 1.11.3
npmPackages:
    "react": "16.9.0",
    "react-native": "0.63.4",
Tyra answered 19/7, 2022 at 18:55 Comment(0)
H
0

My situation is using some frameworks generated by Carthage.

I changed the frameworks to XCFrameworks. Then all works as expected.

Houseleek answered 24/9, 2021 at 7:50 Comment(0)
M
0

I also faced this issue in Xcode Version 13.4.1. Able to resolve by unchecking Open using Rosetta.

enter image description here

Mccarthy answered 21/11, 2023 at 14:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.