Search code examples
iosteamcityxcode8macos-sierracodesign

Xcode 8 Fastlane build with TeamCity codesign failed with exit code 1


I've got a weird serious problem with Xcode 8.3.2 on macOS Sierra. I could build the app locally on build machine with fastlane or manually executing commands. Both development and ad-hoc build can be created locally.

 $ fastlane <lane_name>

But when tried the same from TeamCity it throws following error.

 [exec]/usr/bin/codesign --force --sign 5609CEE02FBF256EDBF60DB28C1A2995A2153B5B --entitlements /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/IntermediateBuildFilesPath/<AppName>.build/Release-iphoneos/<AppName>.build/<AppName>.app.xcent --timestamp=none /Users/<username>/Library/Developer/Xcode/DerivedData/<AppName>-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app
 [exec] /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/SabaMeeting/InstallationBuildProductsLocation/Applications/<AppName>.app: unknown error -1=ffffffffffffffff
 [exec] Command /usr/bin/codesign failed with exit code 1
 [exec] 
 [exec] ** ARCHIVE FAILED **
 [exec] 
 [exec] 
 [exec] The following build commands failed:
 [exec]     CodeSign /Users/<username>/Library/Developer/Xcode/DerivedData/SabaMeeting-frpvxgdtafatrrgbjqbbepgfzvak/Build/Intermediates/ArchiveIntermediates/<AppName>/InstallationBuildProductsLocation/Applications/SabaMeeting.app
 [exec] (1 failure)

TeamCity pulls the code and even executes the commands but fails. Build Step: Command Line is set TeamCity with a custom script. Tried following ways but not working:

  1. Xcode Preferences ->Accounts->Delete already added account and add it again
  2. Generated new Distribution and Developer Certificate and installed in KeyChain. New Provisioning Profiles and installed in Xcode.
  3. Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.
  4. Reinstalled xcode 8.3.2, restarted the machine.
  5. Apple Worldwide Developer Relations Certificate Authority is installed.
  6. Verified resource fork, finder information, or similar detritus not allowed in the app and derived data directory. https://developer.apple.com/library/content/qa/qa1940/_index.html
  7. The project doesn't use CocoaPods.
  8. Tried clearing DerivedData.

Any many more r&d. Any help will be appreciated.


Solution

  • How does your lane look like on your fastfile? Please share it...

    My guess;

    3 Verified keychain access to private keys by "Allow all applications to access this item". Moved Certificates from login to System with access control to all.

    Teamcity is probably not accessing to your certificates and failing.

    Try this;

    1. Move certificates back to login from system.
    2. Add following before your gym or whatever fastlane command is building the .ipa. This will let teamcity unlock and access to keychain.

    lane :beta do |options|

      unlock_keychain(path:"login.keychain", password:"yoursystempassword") 
      sh "security set-keychain-settings -t 3600 -l ~/Library/Keychains/login.keychain"   
      gym(scheme: "yourapp", workspace:"probably you dont have a wokrspace so no need")   
    end