CodeSign failed with a nonzero exit code - xcode

I was facing code singing issue while generating IPA using fastlane or xcodebuild command that was showing log like
log
From xcode I keep getting prompted to unlock "Local Items" keychain on my Mac, how do I fix that?
I tried to lock and unlock key-store but that not worked
I tried to unlock keychain using below command also
security unlock-keychain ~/Library/Keychains/login.keychain
90% will work.In my case that not worked

I tried to Delete keychain 'login
That worked for me there might be some issue with my keychain access password
Follow these steps to prevent prompts to unlock the Local Items keychain.
In Finder Select Go > Go to folder (⇧⌘G)
In the window that appears, type the following:
~/Library/Keychains/
Click OK.
Look for a folder with a name similar to this "A8F5E7B8-CEC1-4479-A7DF-F23CB076C8B8". Note: Each folder has a unique number.
Move this folder to the Trash.
Empty Trash.
Immediately choose Apple Menu () > Restart… to restart your Mac.
After restarting the computer, a new folder is created in the Keychains folder with a name similar to "4B29A0BB-599D-47FC-A2D1-42B5592B130B". This corrects the issue.
For more info: https://help.queens.edu/hc/en-us/articles/205937040-How-to-Resolve-Mac-OS-X-Keychain-Problems

Related

Failed to create IPA archive after upgrade to Xcode 11.4.1, VS for Mac 8.5.4, and Xamarin.iOS 13.16

After upgrading to the latest versions of Visual Studio for Mac, Xamarin, and Xcode, I am unable to create a signed IPA archive. Everything runs on the simulator, everything builds fine in my release configuration. I can even create the archive just fine. But after I click "Sign and Distribute", regardless of whether I try to publish to the App Store or simply save the IPA to disk, I get the extremely generic "Failed to create IPA archive" message with no other detail about what failed.
As always with these types of problems, this worked the last time I tried to publish (2 months ago). Even trying to use "Sign and Distribute" on an archive I previously published successfully to the App Store fails with the same message. Are there any logs for this where I can see exactly what is failing? The Archive output window at the bottom of the screen doesn't show activity for this stage of the process.
UPDATE:
After finding the logs, was able to see the following error that shows that for some reason after upgrading the apps, permissions were somehow lost for creating the zip archive:
zip -r -y "/Applications/Xcode.app/MyApp.ipa" Payload
zip I/O error: Permission denied
zip error: Could not create output file (/Applications/Xcode.app/MyApp.ipa)
zip exited with code 15
ERROR:Failed to create IPA archive.
Finshed
So now the question becomes why, and what steps need to be taken to fix this the proper way (i.e., not just brute-forcing broad permissions)?
Are there any logs for this where I can see exactly what is failing?
To find Mac logs through:
You can select the Go > Go to Folder menu item in Finder, and then copy and paste any of these paths into the dialog.
Visual Studio for Mac
~/Library/Logs/VisualStudio/7.0 (this number may change depending on
the version you are using)
This folder can also be opened via "Help -> Open Log Directory".
If you meet the Permission denied error in the log, this may be due to saving the IPA in the XCode.App folder. You can try a different location.
If you still meet problem, you can send a feed back inside visual studio for more help.
It's very likely due to permission issue while zipping the archive.
To check if it's your case:
Open the log folder at ~/Library/Logs/VisualStudio/7.0 or in Visual Studio for Mac Help > Open Log Directory
Find and open the last log file for publishing (like Publishing.yyyy-mm-dd__hh-mm-ss.log)
Scroll to the last rows of that file. If it contains something like this (see the block below) so it's your case
zip I/O error: Permission denied
zip error: Could not create output file (/Applications/Xcode.app/YourApp.ipa)
zip exited with code 15
ERROR:Failed to create IPA archive.
Finished
In this case, once you see Output IPA file popup, just choose other save location (Desktop for example)

Error connecting to mac from visual studio

I have the right IP address although when I go to connect to my mac I get this error message:
An error occurred while generating the SSH keys. Please check that the environment is properly configured. Details: cat: /Users/cbcb/Library/Caches/Xamarin/XMA/Keys/---------------------: No such file or directory
I have tried creating a new admin user, I have remote login enabled, and when I go to the following location above the folder is blanked.
I fixed this problem by manually importing the public ssh key in MonoTouch folder into the authorized_keys on mac.
To do so :
1- Copy the content of 'id_rsa.pub' located in "%localAppData%/Xamarin/Monotouch"
2- In your MAC (assuming that it is running on a VM), go to "/Users//.ssh/Authorized_keys" Open the file, paste the key in a new line, save then close.
3- Now go back to your Visual Studio and try again, you'll be able to pair your macOS
Enjoy
Close Visual Studio
Delete C:\Users\UserName\AppData\Local\Xamarin\MonoTouch
Start Visual Studio
If you try and delete the directory:
Delete C:\Users\UserName\AppData\Local\Xamarin\MonoTouch
When you relaunch visual studio and it prompts for your Apple login info you need to use the login information for the user who is currently logged in on the Mac. If you use a different account then the current user it will fail.
Sounds like you may need to redirect that to your default .ssh key location. Mine on my Mac is ~/.ssh/known_hosts. Also blank out your SSH keys please, just for security.

Unknown error when trying to archive for publishing Xamarin.Forms.iOS

I am currently releasing an update for an app and i can successfully debug the project. Now when i try to archive for publishing to create the .ipa file I recieve the following error:
I have tried to delete the obj + bin folders in my iOS folder and then clean/rebuild + try again but the error still remains.
Has anyone come across this problem before? The errormessage isn't giving me much information to work with.
try to delete your current certificate in keychain and add it again.
I also faced to this same exact problem when I'm going to debug the xamarin.iOS app using Visual Studio 2015. To solve this issue, steps are as below,
Open Terminal in your Mac and type this command:
security set-key-partition-list -S apple-tool:,apple:,codesign: -s /Users /YOUR_USERNAME/Library/Keychains/login.keychain-db
Then it will prompt for your Keychain access password.
(If it repeatedly promopt that your keychain access password is incorrect, go to "Keychain Access", select and deselect the lock. Then enter your password when asked for it.
Re-enter the above command in the Terminal. Give the password.
Clean and build your project and Run it.
Now it will work definetly.

How do you reset the stored credentials in 'git credential-osxkeychain'?

I've followed the GitHub instructions for setting up my account, and I'm able to clone, but I'm unable to push remotely.
When I do a "git push" I get the 403 error. It has the correct URL. I tried a "git credential-osxkeychain get" to see what it was giving, and this prints out the wrong credentials.
I believe what happened is the first time it asked for the credentials, I thought it was another application asking, and it put the wrong ones in.
I just need to reset it so that it uses the correct keychain item for my GitHub account.
I've tried:
git credential-osxkeychain erase
git credential-osxkeychain set
The program never gives any prompts. Set will say "bad input" if I don't do the right thing. I tried putting in "password=password", etc., but then when I do a "get" I still get the old ones.
I can't figure out where these are being stored, as they are not in .gitconfigure. Further there are no recent keychain items that could be it. (I have several GitHub accounts in my keychain and it is not using any of them.)
From Terminal:
(You need to enter the following three lines)
$ git credential-osxkeychain erase ⏎
host=github.com ⏎
protocol=https ⏎
⏎
⏎
NOTE: after you enter “protocol=https” above you need to press ~~RETURN~~ TWICE (Each '⏎' is equivalent to a 'press enter/return' )
I'm not sure how to erase through the command line, but it's fairly easily to do it through the Keychain Access app. Just go to Applications -> Utilties -> Keychain Access, then enter "github.com". You can either delete the invalid item or update the password from with the app.
The solution turned out to be this:
The command git credential-osxkeychain was using the first GitHub account entry in my keychain. This one was not the one that had access to the projects in question.
I resolved the problem by touching the account in Keychain Access so that its date changed (I think I just changed the comment) and now that it became the most recent GitHub account it became the first one returned to credential-osxkeychain, and thus everything worked.
A better form of support for multiple GitHub accounts would be nice, but it is likely that most people only have one primary account and don't run into this problem.
Try this in your command line.
git config --local credential.helper ""
It works for me every time when I have multiple GitHub accounts in OSX keychain
On Mac, use the command git credential-osxkeychain erase.
OR remove manually from keychain from Applications → Utilities → Keychain Access. Then remove the github.com keychain. Then use push; it will ask for the keychain access; then deny.
It will ask for the new username and password, add it then pushes a file for that.
After git push I found this error. Then I use the upper case-
issue:
remote: Permission to user1/file.git denied to user2(previously exist
user ). fatal: unable to access 'https://github.com/xxxxxxxxxxxx/':
The requested URL returned error: 403
git-credential-osxkeychain stores passwords in the Apple Keychain, as noted above.
By default, gitcredentials only considers the domain name. If you want Git to consider the full path (e.g. if you have multiple GitHub accounts), set the useHttpPath variable to true, as described at http://git-scm.com/docs/gitcredentials.html. Note that changing this setting will ask your credentials again for each URL.
You can delete existing credentials and add new ones via "Keychain Access"
Ref. https://docs.github.com/en/github/getting-started-with-github/updating-credentials-from-the-macos-keychain
GitHub help page for this issue:
https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
Try running /Applications/Utilities/Keychain Access.

myProject is locked for editing and you may not be able to save your changes?

I get the following error messages when I moved my code from my laptop to my Mac Mini and opened it over there:
myProject is locked for editing and you may not be able to save your changes?
myProject is currently locked because you are not the owner of the file and do not have write permission.
The file "xxx.xcuserdatad" could not be unlocked.
Could not add write permission to the file because you do not own it. Try modifying the permission of the file in the Finder or Terminal.
I did a search with Finder: What came up was a file called UserInterfaceState.xcuserstate inside of xxx.xcuserdatad... GetInfo showed the file not to be locked.
However looking at the path(from GetInfo) showed the file to be within "xxx.xcodeproj" and further within "project.xcworkspace/xcuserdata/xxx.xcuserdatad"
I can't find this anywhere, and I don't know how to use my project on another computer.
Go to the Folder in Finder where the xcode project is and right click -> Get info. The permissions and the bottom should be set to read/write and in my case they were. The trick is to click the settings icon at the bottom and select "Apply to enclosed items". The chmod method shown above doesn't change the permissions of the contents within the folder.
go to the folder in finder
right click on folder and click the "Get info"
go down to the bottom and click the lock and write administrator password
now click on the settings icon and press "Apply to enclosed items..."
Please note that I had to add the recursive command flag and sudo to get it to work for me:
$ sudo chown -R Roger my_app_folder/*
And:
$ sudo chmod -R 774 my_app_folder/*
Because I was getting this error:
chmod: Unable to change file mode on my_app_folder: Operation not
permitted
Have you tried copying the contents like suggested in this answer?:
Unable to unlock file for editing in Xcode 4?
Alternatively you could use the console to set yourself a writing permission on all the files for your xcode project:
http://www.mac-terminal.com/files-and-folders/permissions/chmod/

Resources