17

I am trying to distribute an app for Enterprise, and keep getting this error (after selecting the Provisioning Profile):

enter image description here

Digging into the logs reveal this:

2018-09-21 04:14:07 +0000  /var/folders/xj/stm8l48s1nq9320sfh3ytw140000gn/T/XcodeDistPipeline.IsE/Root/Payload/Fleet UAT.app/Frameworks/AppAuth.framework: replacing existing signature
2018-09-21 04:14:07 +0000  /var/folders/xj/stm8l48s1nq9320sfh3ytw140000gn/T/XcodeDistPipeline.IsE/Root/Payload/Fleet UAT.app/Frameworks/AppAuth.framework: code object is not signed at all
2018-09-21 04:14:07 +0000  /usr/bin/codesign exited with 1

Similar issue happens to all frameworks used by the project. These frameworks were added using Carthage.

This started happening after I upgraded to Xcode 10 & Carthage 0.30.1 (I was using 0.16.x previously).

peterh
  • 11,875
  • 18
  • 85
  • 108
Khanh Nguyen
  • 11,112
  • 10
  • 52
  • 65
  • How `AppAuth.framework` is added into your project? Pods, Carthage, manually? – lobstah Sep 21 '18 at 06:14
  • @lobstah it was added using Carthage. This happens to all my frameworks, not just AppAuth. – Khanh Nguyen Sep 21 '18 at 06:38
  • I am on the verge of figuring it out; will post an answer soon – Khanh Nguyen Sep 21 '18 at 06:42
  • Make sure, that your carthage frameworks are `Linked` not `Embedded` and you have `/usr/local/bin/carthage copy-frameworks` script with the list of your frameworks which are added using Carthage. Will add an answer – lobstah Sep 21 '18 at 06:42

4 Answers4

25

When you are adding frameworks using Carthage you need to follow some steps in order to make it work properly. Here is a tutorial: https://www.raywenderlich.com/416-carthage-tutorial-getting-started

In your case make sure, that:

  1. You added your frameworks as Linked (not Embedded)

  2. You have Run script phase in your Build phases: enter image description here

  3. You added paths (Input Files) for all your Carthage frameworks

Community
  • 1
  • 1
lobstah
  • 871
  • 7
  • 12
  • 2
    One more thing: the Run Script phase must be the last one (after Embed Frameworks); I guess the Embed Frameworks phase copies the frameworks over and `carthage copy-frameworks` strips away simulator slices, so they need to be the right order – Khanh Nguyen Sep 21 '18 at 07:00
  • 1
    Instead of `carthage copy-frameworks`, where you have to specify input/output files, you can also use `strip-frameworks.sh` from [Realm](https://github.com/realm/realm-cocoa/blob/f07d1af226b67c0aefb150d12da3fd34c5d64087/scripts/strip-frameworks.sh) which scans the frameworks folder automatically – Khanh Nguyen Sep 21 '18 at 07:01
  • 1
    And [this](https://stackoverflow.com/questions/30963294/creating-ios-osx-frameworks-is-it-necessary-to-codesign-them-before-distributin) helps me greatly in understanding what the hell was happening – Khanh Nguyen Sep 21 '18 at 07:02
  • right, but it is better to remove carthage frameworks from `Embedded` section – lobstah Sep 21 '18 at 07:03
  • 2
    Yeah that never worked for me. I always get this error `dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire` (when the app runs) if I don't put them in the Embeded Binaries section – Khanh Nguyen Sep 21 '18 at 07:06
  • 1
    that's why you need step 2: Run script: `/usr/local/bin/carthage copy-frameworks` and add all your Carthage frameworks below (as input files) – lobstah Sep 21 '18 at 07:10
  • I SEE! I misunderstood how that `copy-frameworks` thing works this whole time! Thanks!!! – Khanh Nguyen Sep 21 '18 at 07:18
  • How to fix it if I am not using Carthage or Cocoapods and directly adding it to project? – anoop4real Sep 27 '18 at 10:09
  • @anoop4real try script from this article: http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/ it will strip unwanted architectures and as side effect - will remove code signing to avoid this warning – lobstah Sep 27 '18 at 10:44
  • @lobstah This issue is happening for me only with XCode 10. With XCode 9.x I am able to sign properly – anoop4real Sep 27 '18 at 11:00
  • @anoop4real so, have you tried to include Framework as 'Linked' and add script described in the article? – lobstah Sep 27 '18 at 12:56
  • @lobstah Instead of doing that, can we do what Carthage is doing....the copy framework?? Not sure what exactly the script is doing but speculating – anoop4real Sep 27 '18 at 14:37
  • Nice answer but Point 1 not needed on my side. – Pankaj Kainthla Nov 15 '18 at 08:41
1

I was able to fix this issue by changing the target's build setting "Build Active Architecture only" to "Yes" then romoving "i386" from the "Valid Architectures". I found my solution here: https://github.com/Carthage/Carthage/issues/1771

Matt W.
  • 956
  • 9
  • 21
0

remove carthage frameworks from "Link Binary With Libaries" section fix same issue on my project

codaman
  • 206
  • 4
  • 6
-1

I had such a problem a few days ago. the The problem is related to your framework,it may be damaged。 you can download or generate a new one。That solves my problem。

Xingou
  • 1,141
  • 1
  • 10
  • 20