XCTest unit test don't work because of framework signature - xcode

I've a dynamic framework that doesn't have signature
CODE_SIGNING_ALLOWED = NO
CODE_SIGNING_REQUIRED = NO
EXPANDED_CODE_SIGN_IDENTITY =
Main application that this framework is linked works fine, while tests are failing with code signature requirement.
2016-10-05 17:40:40.034 xctest[46026:374452] The bundle “CoreUnitTests.xctest” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-10-05 17:40:40.035 xctest[46026:374452] (dlopen_preflight(/Users/user/Library/Developer/Xcode/DerivedData/Application-cafxiqfcbbczvkezpwscftqdsllz/Build/Products/Debug-iphonesimulator/CoreUnitTests.xctest/CoreUnitTests): Library not loaded: #rpath/Core.framework/Core
Referenced from: /Users/user/Library/Developer/Xcode/DerivedData/Application-cafxiqfcbbczvkezpwscftqdsllz/Build/Products/Debug-iphonesimulator/CoreUnitTests.xctest/CoreUnitTests
Reason: no suitable image found. Did find:
/Users/user/Library/Developer/Xcode/DerivedData/Application-cafxiqfcbbczvkezpwscftqdsllz/Build/Products/Debug-iphonesimulator/Core.framework/Core: required code signature missing for '/Users/user/Library/Developer/Xcode/DerivedData/Application-cafxiqfcbbczvkezpwscftqdsllz/Build/Products/Debug-iphonesimulator/Core.framework/Core'
/Users/user/Library/Developer/Xcode/DerivedData/Application-cafxiqfcbbczvkezpwscftqdsllz/Build/Products/Debug-iphonesimulator/Core.framework/Core: required code signature missing for '/Users/user/Library/Developer/Xcode/DerivedData/Application-cafxiqfcbbczvkezpwscftqdsllz/Build/Products/Debug-iphonesimulator/Core.framework/Core'
)
Program ended with exit code: 82
Is there a way to disable code signature requirement in test bundle?

Related

SynCrypto.pas and Lazarus compile problem

I'm trying to use SynCrypto.pas (part of Synopse mORMot ORM/SOA/MVC framework) in my Lazarus project to decrypt AES-128 stream. My project not compiling with errors in SynFPCTypInfo at this code:
PFPCInterfaceData = TypInfo.PInterfaceData;
PFPCVmtMethodParam = TypInfo.PVmtMethodParam;
PFPCIntfMethodTable = TypInfo.PIntfMethodTable;
PFPCIntfMethodEntry = TypInfo.PIntfMethodEntry;
SynFPCTypInfo.pas(91,31) Error: Identifier not found "PInterfaceData"
SynFPCTypInfo.pas(91,45) Error: Error in type definition
SynFPCTypInfo.pas(92,32) Error: Identifier not found "PVmtMethodParam"
SynFPCTypInfo.pas(92,47) Error: Error in type definition
SynFPCTypInfo.pas(93,33) Error: Identifier not found "PIntfMethodTable"
SynFPCTypInfo.pas(93,49) Error: Error in type definition
SynFPCTypInfo.pas(94,33) Error: Identifier not found "PIntfMethodEntry"
SynFPCTypInfo.pas(94,49) Error: Error in type definition
I think that it's incompatibility with Delphi TypInfo module. How can I fix it?
So ... I suggest you to install the new pascal: https://github.com/newpascal/newpascal/releases/tag/np-v1.0.56, download the zip and unzip it in some folder, for example (D: \ lazarus \ newpascal), and configure the paths according to the mORMot site: For proper FPC compilation, ensure you have the following settings to your project:
Other unit files (-Fu):
D:\lazarus\newpascal\ccr\mORMot;D:\lazarus\newpascal\ccr\mORMot\SQLite3;D:\lazarus\newpascal\ccr\mORMot\SQLite3\DDD\infra\
Include files (-Fi):
$(ProjOutDir);D:\lazarus\newpascal\ccr\mORMot;D:\lazarus\newpascal\ccr\mORMot\SQLite3\
Libraries (-fFl):
D:\lazarus\newpascal\ccr\mORMot\static$(TargetCPU)-$(TargetOS)\
site: https: //synopse.info/files/html/Synopse%20mORMot%20Framework%20SAD%201.18.html#TITL_113, then you will have at least how to test your app.

Relative framework paths, the Hardened Runtime and Notarization

After successfully notarizing my app around a dozen times and it working just fine, it now goes through notarization without a hitch and then crashes on launch with:
Dyld Error Message:
Library not loaded: #loader_path/../Frameworks/ShortcutRecorder.framework/Versions/A/ShortcutRecorder
Referenced from: /Applications/Vitamin-R 3.app/Contents/MacOS/Vitamin-R 3
Reason: no suitable image found. Did find:
/Applications/Vitamin-R 3.app/Contents/MacOS/../Frameworks/ShortcutRecorder.framework/Versions/A/ShortcutRecorder: code signing blocked mmap() of '/Applications/Vitamin-R 3.app/Contents/MacOS/../Frameworks/ShortcutRecorder.framework/Versions/A/ShortcutRecorder'
/Applications/Vitamin-R 3.app/Contents/MacOS/../Frameworks/ShortcutRecorder.framework/Versions/A/ShortcutRecorder: code signing blocked mmap() of '/Applications/Vitamin-R 3.app/Contents/MacOS/../Frameworks/ShortcutRecorder.framework/Versions/A/ShortcutRecorder'
/Applications/Vitamin-R 3.app/Contents/MacOS/../Frameworks/ShortcutRecorder.framework/Versions/A/ShortcutRecorder: stat() failed with errno=1
file system relative paths not allowed in hardened programs
Thing is I'm not sure where exactly the runtime path for a framework is determined.. I keep the framework in ~/Libary/Frameworks/ on my development machine, but then it's copied into the app bundle and I'm not quite sure what determines the path at runtime..
Any help would be appreciated.
This could be a codesign certificate issue... Fix it by:
Open Keychain Access: My Certificates > "Right Click" Certificate > get info > Trust > When using this certificates > Use System Defaults
I had exactly the same issue. The solution was to add the framework to the 'Copy Files' build step as well. There you can define the destination to 'Frameworks'.

How to troubleshoot when Safari App Extension not appear in Safari Preferences?

I'm developing a Safari App Extension. Previously it worked fine. When I run the project in Xcode, and enable Allow Unsigned Extensions in Safari, I can see my extension in Safari Preferences -> Extensions page.
After I merged code with one of my team member, suddenly the Extension cannot get installed.
I have tried:
Clean the build folder in Xcode, and run again. But no luck.
Restart Xcode doesn't help either.
Use command pluginkit -mAvvv -p com.apple.Safari.extension to check installed Safari extensions list. My extension is not in the list.
There are some errors in Xcode output, but I can't link them with the issue I'm facing:
objc[49476]: Class AMSupportURLConnectionDelegate is implemented in both /System/Library/PrivateFrameworks/EmbeddedOSInstall.framework/Versions/A/EmbeddedOSInstall (0x7fff9a2aa748) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108db2600). One of the two will be used. Which one is undefined.
objc[49476]: Class AMSupportURLSession is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff9b5d49f0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108db2650). One of the two will be used. Which one is undefined.
2018-12-13 16:25:46.003099+0800 Safari[49476:1264277] Could not connect action, target class SecurityPreferences does not respond to -toggleJavaScriptCanOpenWindows:
2018-12-13 16:25:46.163130+0800 Safari[49476:1264277] AssertMacros: 0 (value = 0x0), file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKitXPCClient.m, line: 75
2018-12-13 16:25:46.163219+0800 Safari[49476:1264277] AssertMacros: 0 (value = 0x0), file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKitXPCClient.m, line: 396
2018-12-13 16:25:46.163465+0800 Safari[49476:1264277] [Framework-Internal-Legacy] AssertMacros: _xpcClient (value = 0x0), file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKit.m, line: 137
2018-12-13 16:25:47.060959+0800 Safari[49476:1264368] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
2018-12-13 16:25:47.128105+0800 Safari[49476:1264277] Scheduling the NSURLConnection loader is no longer supported.
2018-12-13 16:25:47.491811+0800 Safari[49476:1264370] NSURLConnection finished with error - code -1100
2018-12-13 16:25:47.799590+0800 Safari[49476:1264514] [CloudBookmarks] Error fetching remote migration state: Error Domain=com.apple.SafariBookmarksSync.CloudBookmarksErrorDomain Code=0 "(null)"
2018-12-13 16:25:47.953259+0800 Safari[49476:1264277] [WebKit2Callbacks] Page (pid: 0) did become unresponsive
2018-12-13 16:25:47.970927+0800 Safari[49476:1264512] NSURLConnection finished with error - code -1100
2018-12-13 16:25:48.032647+0800 Safari[49476:1264425] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
2018-12-13 16:25:48.125530+0800 Safari[49476:1264426] Calling IOPPFGetProperty simulator_utility_clamp!
2018-12-13 16:25:48.840769+0800 Safari[49476:1264277] [WebKit2Callbacks] Page (pid: 49481) did become responsive
Now I'm running out of options. It lacks official documentation in Apple Developer site.
Is there regular steps to troubleshoot this kind of issue? Is there any kind of system logs which can help me address the error? Any suggestion is appreciated.
Make sure that the extension .appex is listed as embedded content for your App Extension target. Otherwise it doesn't get bundled when you build from Xcode. Look in the project editor under Target_Name > General > Frameworks, Libraries and Embedded Content. The extension should be listed there.
Also check under the Build Phases tab > Dependencies that your extension is added there as well.
Check to see if the code signature of your app is valid. Safari will refuse to list your extension otherwise. Run codesign on your built app as follows:
codesign -d --verify --verbose=3 ~/Library/Developer/Xcode/DerivedData/OnePassword-epeydspviethpabprcrsqenrkiin/Build/Products/Debug_WebStore/1Password\ 7.app
It should show valid on disk and satisfies its Designated Requirement. If it doesn't, Safari will ignore your extension completely, even when Allow Unsigned Extensions is enabled.
I had a similar problem more recently after updating to Xcode 13.2.1 and a I think a MacOS update. My Safari web extensions I was developing stopped showing up in Safari (even with unsigned extensions enabled).
In a Terminal/CLI shell, I ended up running:
PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH"
lsregister -f /Applications/Safari.app
And suddenly my extensions started showing up again in Safari. Something screwy happened with Safari and LaunchServices.

A sealed resource is missing or invalid

I'm trying to deploy my game made with Unity on Mac Store, but got this error during the validation process. I don't know how to correct. Do you have any ideas please ?
Invalid Signature - The main app bundle Kissoro at path Kissoro.app
has following signing error(s):
--prepared:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/libcrypto.dylib
--validated:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/libcrypto.dylib
--prepared:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/libssl.dylib
--validated:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/libssl.dylib
--prepared:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/Mono/MonoEmbedRuntime/osx/libmono.0.dylib
--validated:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/Mono/MonoEmbedRuntime/osx/libmono.0.dylib
--prepared:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/Mono/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib
--validated:/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app/Contents/Frameworks/Mono/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib
/Volumes/data01/app_data/dstr/mz_8224354388357841556dir/mz_8662652241696651587dir/com.masseka.game.studio.Kissoro.pkg/Payload/Kissoro.app:
a sealed resource is missing or invalid . Refer to the Code Signing
and Application Sandboxing Guide at
http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/AboutCS/AboutCS.html
and Technical Note 2206 at
https://developer.apple.com/library/mac/technotes/tn2206/_index.html
for more information.
All you have to do is to manually codesign every file in Contents/Frameworks and Contents/Plugins directories inside .app file and to delete all .meta files inside your plugin. After U do these steps, You codesigned once more the whole .app file and create a package which You can uploaded on iTunes Connect without warning mentioned above.
More info: https://forum.unity.com/threads/signing-mac-app-on-os-x-mavericks.206762/

SIMBL plugin fails to load framework

On console, I am getting these errors:
27.08.11 20:56:06,371 sandboxd: ([83008]) TextEdit(83008) deny file-read-data /Users/az/Library/Frameworks/FScript.framework/Versions/A/FScript
27.08.11 20:56:06,372 TextEdit: Error loading /Users/az/Library/Containers/com.apple.TextEdit/Data/Library/Application Support/SIMBL/Plugins/FScriptAnywhere.bundle/Contents/MacOS/FScriptAnywhere: dlopen(/Users/az/Library/Containers/com.apple.TextEdit/Data/Library/Application Support/SIMBL/Plugins/FScriptAnywhere.bundle/Contents/MacOS/FScriptAnywhere, 265): Library not loaded: #executable_path/../Frameworks/FScript.framework/Versions/A/FScript
Referenced from: /Users/az/Library/Containers/com.apple.TextEdit/Data/Library/Application Support/SIMBL/Plugins/FScriptAnywhere.bundle/Contents/MacOS/FScriptAnywhere
Reason: no suitable image found. Did find:
/Users/az/Library/Frameworks/FScript.framework/Versions/A/FScript: open() failed with errno=1
The file FScriptAnywhere.bundle/Contents/Frameworks/FScript.framework/Versions/A/FScript exists. Thus, I don't understand the error / the problem.
Any idea?
Found the problem:
#executable_path is relative to the app, not the bundle, i.e. in this case TextEdit. Of course it doesn't find the framework there.
It also cannot load the framework from ~/Library/Frameworks because of the sandboxing of TextEdit.
Copying the framework over to /Library/Frameworks solved the problem.

Resources