XCode always fails to create executable code when using Signing Certificates.

I get the following output when executing a basic Command Line Application in XCode, when I set the Signing & Capabilities -> Signing Certificate -> Apple Development.

The same thing happens if I use any of the following: Apple Development, Apple Distribution, Mac Developer, Mac App Distribution, Mac Installer Distribution, Developer ID Application, Developer ID Install

All Signing Certificates Fail the Same Way

//
//  main.swift
//  cmt
//
//  Created on 8/8/21.
//  Copyright © 2021 codename. All rights reserved.
//

import Foundation

print("Hello, World!")

When I hit the "play" button, I get the following message from the debugger:

Message from debugger: Error 1

Program ended with exit code: -1

When I run the executable from a command line window, I get the following:

[MBP:~] q% /Users/q/Library/Developer/Xcode/DerivedData/cmt-gyeervgusfoqtvgjjzncleiifops/Build/Products/Debug/cmt ; exit;

Killed

When I set the Signing & Capabilities -> Signing Certificate -> Sign to Run Locally

then the executable runs properly with the following output:

Hello, World!

Program ended with exit code: 0

I need to be able to run with the "Apple Development" Signing Certificate. Please help me get my MACOS "Hello World" program running. It cannot possibly be this difficult to get a basic program running.

When I run the executable from a command line window

That should generate a crash report. Please post the report here. Use the text attachment feature (click the paperclip icon and then choose Add File) to avoid clogging up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Eskimo, I found the solution:

Based on this thread:

https://developer.apple.com/forums/thread/660087

I downloaded the certificate from:

https://developer.apple.com/support/expiration/

I imported it into my Keychain Access tool and instantly my certificates became valid.

Cleaning the build folder, then compiling and debugging my application now works. YIKES!

Next problem: When I activate the sandbox, I run and get the following output:

Illegal Instruction

I have attached the crash log.

Eskimo, I also read your post here:

https://developer.apple.com/forums/thread/112800

If I manually set the entitlement:

com.apple.security.get-task-allow

to FALSE

I get the attached debug

If I disable "CODE_SIGN_INJECT_BASE_ENTITLEMENTS", I get the following debug:

Running the command:

codesign -d --entitlements :- cmt

gives me the following output:

Executable=/Users/q/Library/Developer/Xcode/DerivedData/cmt-gyeervgusfoqtvgjjzncleiifops/Build/Products/Debug/cmt

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

	<key>com.apple.security.app-sandbox</key>

	<true/>

</dict>

</plist>

My understanding is that you’re building a command-line tool. If so, there are two ways forward:

  • If you plan to ship the tool by itself, disable the sandbox. The App Sandbox is, as it says in the name, for apps, and you can’t enable it on standalone command-line tools.

  • If you plan to embed the tool within a sandboxed app — for example, you’re building an app for the App Store and you want to embed a helper tool within that app — follow the instructions in Embedding a Command-Line Tool in a Sandboxed App.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This is perfect, quinn, thanks. Let me give your second link a try.

I am going through all these gymnastics with the sandbox because I want to use the corebluetooth library in a command line tool - and apparently I have to use a sandbox to use corebluetooth?

apparently I have to use a sandbox to use corebluetooth?

Core Bluetooth is available to non-sandboxed apps. I suspect the problem here is that Core Bluetooth recently implement privacy support, and that tends to cause problems for command-line tools. You should be able to distinguish these two cases by a create a non-sandboxed test app and adding your Core Bluetooth code to that.

Still, Core Bluetooth is not really my area of expertise. I recommend that you start a new thread and tag it with Core Bluetooth to see if someone there can help out. If not, open a DTS tech support incident and talk to DTS’s Bluetooth specialist.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

XCode always fails to create executable code when using Signing Certificates.
 
 
Q