d00dle d00dle - 1 month ago 27
Swift Question

Code signing is failing after running unit tests

I recently updated to Xcode 8 and converted my code to Swift 3. Now my unit testing are failing, probably as they should, but then code signing are failing when trying to run again.

I use several CocoaPods, but they have worked previously. Everything work outside of UnitTesting.

The only fix I found so far is to clear CMD+ALT+K and rebuild solution.

Does anyone have a permanent fix for this?

Error

/Users/***/Library/Developer/Xcode/DerivedData/***-bbpdbvqjecpwzvfliyyqcnarjvua/Build/Products/Pro Debug/***.app: replacing existing signature
/Users/***/Library/Developer/Xcode/DerivedData/***-bbpdbvqjecpwzvfliyyqcnarjvua/Build/Products/Pro Debug/***.app: code object is not signed at all
In subcomponent: /Users/***/Library/Developer/Xcode/DerivedData/***-bbpdbvqjecpwzvfliyyqcnarjvua/Build/Products/Pro Debug/***.app/Contents/PlugIns/***Tests.xctest
Command /usr/bin/codesign failed with exit code 1


Edit: When running UnitTests which are all successful the code signing still fails on second run. Basically I have to clean the build before each test run.

Answer

The solution for me was to go to the Pods project in the workspace, and turn on code signing on the pod targets.

This either turned on some missing setting from the Swift 3 migration or this is the actual solution.