my code is simple like this:
#include <stdio.h>
int main(int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!n");
printf(" sizeof int = %lun", sizeof(int));
return 0;
}
run on xcode and got error:
Message from debugger: Error 1
Program ended with exit code: -1
run Terminal :
4
Answers
The code that you’ve posted runs fine for me in an Xcode 12 project configured as a command line tool. Here’s the output:
Try pasting the same code into a new project, and again, set it up as a command line tool. You shouldn’t need to make any changes to the project default settings. If it works, compare that to your original project; the reason for the failure is somewhere in the original project’s configuration.
I have the same problem, which is very disturbing.
screenshot-img
These settings solve my problem. You can have a try.
Tap PROJECT settings Signing & Capabilities, in Signing – Signing Certificate, if your selected is "Development", you can change it to "Sign to Run Locally" to have a try.
If you don’t have a development certification, you can not be coding with that certificate mode.
From: https://developer.apple.com/library/archive/qa/qa1884/_index.html
Q: When I run my Mac app, it crashes immediately, and the crash log says Exception Type: EXC_CRASH (Code Signature Invalid). What is going on here?
A: The crash log indicates that your app is signed with your Mac App Store distribution identity, with the certificate’s Subject Common Name starting with “3rd Party Mac Developer Application.” Mac apps signed this way can no longer be run directly. Here’s the background on this.
Over time, more Mac App Store technologies have been added that require entitlements that come from a provisioning profile. This started with push notifications and iCloud. Later, Game Center and Maps were added to the list.
Recently, the
com.apple.developer.team-identifier
entitlement was added to all new Mac provisioning profiles. This means that, going forward, distribution builds of Mac apps cannot be run directly; they are for submitting to iTunes Connect for app review onlyInstead, developers should adopt the Archive Build Workflow in QA1778: How to reproduce bugs reported against Mac App Store submissions for testing the builds that they plan to submit for the Mac App Store. On Xcode 6, select
Export as a Mac Application
. You won’t see any chance to select your development signing identity, but Xcode will export the app from the archive as it was signed at build time. So the result will be the same.You can create an installer package containing your development-signed app by hand with the
productbuild
tool, like this:Then install the package as documented in Testing the Mac Installer Package:
This workflow means that you will need to add your beta testers’ test systems to your Mac Developer Program account so they will be able to run your app.
Another possibility is to use
Xcode Organizer > Export > Export a Developer ID-signed Application
. Developer ID-signed apps can be run by anyone. However, code that uses technologies only available to Mac App Store apps, such as receipt validation, iCloud, and push notifications, will not work if your app is Developer ID-signed. You might need to temporarily disable those parts of your app if you opt for the Developer ID testing approach.