Code signing: initial steps

I start from an OSX App that is not code signed. This is in XCode 8.3.2


I'm trying to sign it :

- in Project / Build settings, in code signing identity, I declare :

Mac Developer

I declare the development team


If in Target Code SIgning Identity, I leave "No signing", app compiles OK. But is not code signed


If in Target, I define

code signing identity : MacDeveloper

I declare the development team

No provisionning profile


I now get a code sign error.


I checked in Target / General that signing is defined for debug and release.


If in Targets / general, I ask for automatic signing, I'm requested to provide a development team, which I do.

I get the same code sign error


What do I miss here ?

Answered by Claude31 in 241276022

The solution was found.


Need to clear extended attributes of several files.


This can be done through Terminal : xattr -c <file path>

Edited.

The question in fact is how to clear the finder detritus that were created by previous versions of the system.

I've tried to clear from terminal, using xattr -lc command ; extended attributes seem to have been clerad, but strill get the same message and build error :


/Users/Me/Library/Developer/Xcode/DerivedData/myApp-hknqslligudgdhdhpwvfhpbtcilk/Build/Products/Debug/myApp.app: resource fork, Finder information, or similar detritus not allowed


Are there other attributes to clear ?


I read in doc :

A: This is a security hardening change that was introduced with iOS 10, macOS Sierra, watchOS 3, and tvOS 10.

Code signing no longer allows any file in an app bundle to have an extended attribute containing a resource fork or Finder info.

To see which files are causing this error, run this command in Terminal:

$ xattr -lr <path_to_app_bundle>

replacing

<path_to_app_bundle>
with the path to your actual app bundle.

Here's an example of this command in action:

$ xattr -lr Foo.app

/Applications/Foo.app: com.apple.FinderInfo:

00000000 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 |................|

You can also remove all extended attributes from your app bundle with the xattr command:

$ xattr -cr <path_to_app_bundle>

Note that browsing files within a bundle with Finder's Show Package Contents command can cause Finder info to be added to those files.


I performed the $ xattr -cr, without any change : all finder info seems to be cleared, but same codesign error

Question: which is the path to specify ?

- Is it the one in derivedData ? : /Users/ME/Library/Developer/Xcode/DerivedData/P_T-hknqslligudgdhdhpwvfhpbtcilk/Build/Products/Debug/P\ T.app

- the second one ? /Users/ME/Developpements XCode/P T/StartPT

- the third, with no escape in the file name ? /Users/ME/Library/Developer/Xcode/DerivedData/P_T-hknqslligudgdhdhpwvfhpbtcilk/Build/Products/Debug/P T.app

- I did also a clean on the project root path as defined in Identity and Type of the project.


here is the codesign error I get:

CodeSign /Users/ME/Library/Developer/Xcode/DerivedData/P_T-hknqslligudgdhdhpwvfhpbtcilk/Build/Products/Debug/P\ T.app

cd "/Users/ME/Developpements XCode/P T/StartPT"

export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate


Signing Identity: "Mac Developer: ME (XXXXXXXXXX)"

/usr/bin/codesign --force --sign ZZZZZZZZZZZZZZZZZZZZZZ --entitlements /Users/me/Library/Developer/Xcode/DerivedData/P_T-hknqslligudgdhdhpwvfhpbtcilk/Build/Intermediates/P\ T.build/Debug/P\ T.build/P\ T.app.xcent --timestamp=none /Users/ME/Library/Developer/Xcode/DerivedData/P_T-hknqslligudgdhdhpwvfhpbtcilk/Build/Products/Debug/P\ T.app

/Users/ME/Library/Developer/Xcode/DerivedData/P_T-hknqslligudgdhdhpwvfhpbtcilk/Build/Products/Debug/P T.app: resource fork, Finder information, or similar detritus not allowed

Command /usr/bin/codesign failed with exit code 1

Accepted Answer

The solution was found.


Need to clear extended attributes of several files.


This can be done through Terminal : xattr -c <file path>

In some cases, there is a much easier solution.


In my case, I had just added an image file that was .png. Deleting that file made the error go away! Much faster.


In this particular case, opening the image file in an editor, and exporting it as a .jpg, then 'file:add' eliminated the issue.


My suggestion is to consider any recently added files as a possible problem source.

Code signing: initial steps
 
 
Q