Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carthage fails to start when running from Xcode 10 Build pre-action

I have simple ksh script which runs carthage update --platform iOS as a Build pre-action and it started to fail after updating to Xcode 10. Running the command in Terminal generates Carthage folder successfully.

To reproduce this issue, quit Xcode and delete DerivedData and Carthage folder. Then open Xcode 10 and try to build.

The error I get:

<unknown>:0: error: unable to load standard library for target 'arm64-apple-ios8.0-simulator'

** ARCHIVE FAILED **


The following build commands failed:
    CompileSwift normal armv7
    CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
    CompileSwift normal arm64
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(4 failures)
Build Failed

Setup

  • Carthage 0.31.1 - 0.33.0
  • Cartfile points to Alamofire 4.7.3

Things I have tried

  • Using carthage bootstrap, didn't work
  • Raising Alamofire dependency target to iOS 8.4 and 10 (from local fork), didn't work
  • All answers from this SO question., didn't work
  • Use env -i as advised in open Carthage ticket, didn't work

Solutions

  • Select "Generic iOS Device" when building first time.
  • Passing SDK parameter directly to xcodebuild, found in this answer. This forces you to write your own carthage update, composed of checkout and build. Only this option worked as Xcode Build pre-action step. The solution was tested.

Some links

Non answered thread on Apples forums.

Closed Alamofire ticket

like image 770
Boris Y. Avatar asked Oct 25 '18 11:10

Boris Y.


3 Answers

In my case, restarting macOS fixed the problem.

like image 197
mishimay Avatar answered Nov 07 '22 05:11

mishimay


The solution that worked for me was to unset one of the env variables coming from XCode 10 just before executing carthage update:

unset LLVM_TARGET_TRIPLE_SUFFIX

carthage update

like image 36
Tomasz Zabłocki Avatar answered Nov 07 '22 04:11

Tomasz Zabłocki


I found a way that actually does the trick and its:

write one valid command write after carthage update command

So follow this checklist:

  • Ensure that your command line tools are configured to use Xcode 10.1. Run the following command from Terminal:

    sudo xcode-select -s <path to Xcode 10.1>/Contents/Developer

  • Ensure that script file has required permissions:

    chmod 777 <path-to-script-file>

  • Write one valid command write after carthage update command, For example echo succeed (This actually do the trick):

    Example

Tested environment:

  • Carthage 0.31.2
  • Xcode 10.1

Working Demo

https://github.com/MojtabaHs/Carthage-WorkingDemo

- THE MOST IMPORTANT STEP

  • DON'T FORGET to write one valid command write after carthage update command

Note that this is just a hack around the issue explained in question, not all carthage issues.

like image 40
Mojtaba Hosseini Avatar answered Nov 07 '22 06:11

Mojtaba Hosseini