Code sign Error -Command /usr/bin/codesign failed with exit code 1

Hi Guys,
I am newbie to Appium. I am trying to setup appium IOS automation for real device. I did all the steps mentioned in the appium docs.
i get the following error
CodeSign /Users/cappexit/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphoneos/WebDriverAgentLib.framework/Frameworks/RoutingHTTPServer.framework
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

/usr/bin/codesign --force --sign 7358F373BB34254DD4E0C7098DA6789912F05940 --preserve-metadata=identifier,entitlements,flags --timestamp=none /Users/cappexit/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphoneos/WebDriverAgentLib.framework/Frameworks/RoutingHTTPServer.framework

/Users/cappexit/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphoneos/WebDriverAgentLib.framework/Frameworks/RoutingHTTPServer.framework: unknown error -1=ffffffffffffffff
Command /usr/bin/codesign failed with exit code 1

Config:
MacOS High Sierra
xcode 9.1
appium 1.7.1

story behind this error…
I installed all the dependencies and then when i did Build the project. i got a popup saying “Codesign wants to access key “access” in your keychain”. It wanted me to enter my “login” keychain password. i entered the password and clicked “Allow”.but it was popping up again and again so i didn’t know how to close that popup. so i clicked “Deny” option. After that whenever i try to build the project it fails with the above error.

I tried uninstalling appium it didn’t work.

I am really stuck with this… it would be really helpful if someone can help me. Thanks in advance.

log:

11:22:52.904 xcodebuild[15103:868504] Beginning test session WebDriverAgentRunner-B5CB1CE1-D992-4C54-B293-F1B67A49E036 at 2017-11-02 11:22:52.903 with Xcode 9B55 on target <DVTiOSDevice: 0x7fa1776fabb0> {
deviceSerialNumber:
identifier:
deviceClass: iPhone
deviceName: Jose’s iPhone
deviceIdentifier: xxxxxxxxxxxxxxxxxxxx
productVersion: 11.1
buildVersion: 15B93
deviceSoftwareVersion: 11.1 (15B93)
deviceArchitecture: arm64
deviceTotalCapacity: 12678873088
deviceAvailableCapacity: 10118348800
deviceIsTransient: NO
ignored: NO
deviceIsBusy: NO
deviceIsActivated: YES
deviceActivationState: Activated
isPasscodeLocked: NO
deviceType: <DVTDeviceType:0x7fa179daf2a0 Xcode.DeviceType.iPhone>
supportedDeviceFamilies: (
1
)
applications: (null)
provisioningProfiles: (null)
hasInternalSupport: NO
isSupportedOS: YES
developerDiskMountError: (null)
(null)
bootArgs:
connected: yes
isWirelessEnabled: no
connectionType: direct
} (11.1 (15B93))
11:22:52.905 xcodebuild[15103:868504] /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
-project
WebDriverAgent.xcodeproj
-scheme
WebDriverAgentRunner
-destination
id=xxxxxxxxxxxxxxxxxx
test
11:22:52.905 xcodebuild[15103:868504] Launching with Xcode.IDEFoundation.Launcher.PosixSpawn
11:22:52.908 xcodebuild[15103:868504] Test standard output and standard error is at /var/folders/q2/vsf3z4693vs39j6krk7grhgc0000gp/T/com.apple.dt.XCTest/IDETestRunSession-1492C7A6-9277-44A0-A492-5B7C8DBA0FDD/WebDriverAgentRunner-7C9895B0-1215-4C9F-81A4-6603233A0DF0/StandardOutputAndStandardError.txt
11:22:53.577 xcodebuild[15103:868504] Test operation failure: Test operation was canceled.
11:22:53.577 xcodebuild[15103:868504] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=14 “Test operation was canceled.” UserInfo={NSLocalizedDescription=Test operation was canceled.}

I hope the steps mentioned in this post may helps you to resolve your issue

https://stackoverflow.com/questions/2017756/command-usr-bin-codesign-failed-with-exit-code-1