Xcode 10 build fails with 'Command CompileSwif

2020-01-29 07:57发布

I updated Xcode to version 10 recently and started to receive a strange error when trying to build my project. I'm currently on Swift 4.0 and I did try to upgrade to swift Version 4.2. But when I did I received this same error in many of my frameworks.

Command Compile Swift failed with a nonzero exit code

So far I've deleted the derived folder. Updated all pods, also deleted all pods and reinstalled them using the terminal commands below.

sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod clean
pod install

This didn't work to fix my issue. However, I found something that could work which was adding arm64 architecture in Build Setting -> valid architectures and enabling automatic code But, when I checked it was already there and code signing was enabled already.

Additionally, I do have a few other build errors that have to do with frameworks.

SwiftMessages

Value of type 'SwiftMessages.Config' has no member 'presentationContext'

WhatsNewKit

Missing argument for parameter 'backgroundColor' in call`

I opened issues with the developers of each of these frameworks to seek help with these issues.

Issue On SwiftMessage GitHub Issue On WhatsNewKit GitHub

When I click presentationContext it brings me to the struct within the SwiftMessages Framework. Usually, when I've had the "has no member" warning I cannot click to see the original place where it exists.

I assume this has something to do with cocoa pods, but haven't been able to find a solution yet. What can I do to correct this issue? If anyone could help would be deeply appreciated been stuck on this for a day now.

Update: The two frameworks latest builds were for swift 4.2. When I changed the version of each framework to one that was built in swift 4.0 I got the project to build.

14条回答
一纸荒年 Trace。
2楼-- · 2020-01-29 08:22

All of the answers were helpful to me. In my case, I only install frameworks manually but this kind of problem also happens. I tried all of the answers and was still getting this issue during the build. Curiously, while coding, I could cmd-click and resolve all of the "missing" components. I also cleaned and deleted derived data, restarted Xcode, etc.

I eventually got it working by inducing these additional steps:

On each of the framework project/targets (including my own):

  • Verify consistent Swift version (4.2 in my case)
  • Set Build for Active Architecture Only to No
  • Set Valid Architecture to arm64, armv7 (to match with base project)
  • Set Optimization Level to None (for Debug)
  • Set Compilation Mode to Whole
查看更多
三岁会撩人
3楼-- · 2020-01-29 08:25

In my case it was a code error:

self.myDto.map{ (dto)} in 
      var stringValue = (dto.value(forKey: "name") as! String)
      stringValue.append("c")
      return stringValue
}

Just removed that stringValue variable fixed the problem.

查看更多
登录 后发表回答