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

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.

Related

Why Xcode can not attach to some programs?

i had to reinstall my MacBook Pro. I have installed the newest macOS & Xcode version so
macOS Monterey 12.0.1 (21A559)
and
Version 13.1 (13A1030d)
I'm programming Audio plugins so to test my plugins I'm normally running a DAW (Digital Audio Workstation) in my case I'm working the most of the time with Ableton or Bitwig.
So if I start the debuging process, I get the follow error:
Could not attach to pid XXXXXX
attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)
If I have an eye to the console.app the the following lines:
[LaunchAttach] (3277) about to task_for_pid(2930)
error: [LaunchAttach] MachTask::TaskPortForProcessID
task_for_pid(2930) failed: ::task_for_pid ( target_tport = 0x0203, pid
= 2930, &task ) => err = 0x00000005 ((os/kern) failure)
macOSTaskPolicy: (com.apple.debugserver) may not get the task control
port of (BitwigStudio) (pid: 2930): (BitwigStudio) is hardened,
(BitwigStudio) doesn't have get-task-allow, (com.apple.debugserver) is
a declared debugger(com.apple.debugserver) is not a declared read-only
debugger
1 +0.000000 sec [0ccd/0103]: error: ::task_for_pid ( target_tport =
0x0203, pid = 2930, &task ) => err = 0x00000005 ((os/kern) failure)
err = ::task_for_pid ( target_tport = 0x0203, pid = 2930, &task ) =>
err = 0x00000005 ((os/kern) failure) (0x00000005)
I have done some research and found this:
Stackoverflow link about What does get-task-allow do
get-task-allow, when signed into an application, allows other
processes (like the debugger) to attach to your app. Distribution
profiles require that this value be turned off, while development
profiles require this value to be turned on (otherwise Xcode would
never be able to launch and attach to your app).
So there is nothing I can do to debug my programs with that software. Is that correct? :(
You can debug but you have to set the "Code Signing Inject Base Entitlements" to "Yes" for debugging
And then you have to add a provisioning profile. Go to developer.apple.com then select "Certificates, IDs & Profiles" to create a provisioning profile for the bundle ID you are testing.
This solved it for me on terminal
sudo DevToolsSecurity -enable
When you don't have access to the original source code or don't want to rebuild it, such as when developing plug-ins for another app (a DAW in your case), you can easily change the entitlements of the application as follows to enable debugging:
Read the current entitlements as follows (replace daw.app with the actual app name):
codesign --display --xml --entitlements daw.entitlements daw.app
Note: Run this in the Terminal app. It will create a file named daw.entitlements in the current folder. Run the command only once or delete any previously created daw.entitlements; otherwise the command keeps appending to the same file.
Open daw.entitlements in any text editor and insert the following text just before </dict></plist> at the end of the file:
<key>com.apple.security.get-task-allow</key><true/>
Note: If there’s already an entry with the same name, change its value from false to true instead of adding a new one.
Apply the new entitlements as follows (replace daw.app with the actual app name):
codesign -s - --deep --force --options=runtime --entitlements daw.entitlements daw.app
This should do it. In the unlikely chance that you already have a file named daw.entitlements in the same folder, use a different file name in all steps.
I tried all of these and had no luck until I figured out that I also had to disable SIP (system integrity protection) to attach to the audio server plugin I am working on.
Hopefully this helps someone to not lose a whole day on it as I did.

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'.

Xcode 11 Beta 5 - Loading a plug-in failed

Opening a SwiftUI "Hello World" unaltered project in Xcode 11 beta 5 running on Catalina beta 4 produces a "Loading a plug-in failed" dialog warning.
Has anyone else experienced this or know how to solve it? I deleted Xcode, redownloaded it, reinstalled it and I'm still getting the same error.
No idea how to fix other than deleting the offending module, but that can't be right.
Error details:
Details
Loading a plug-in failed.
Domain: DVTPlugInErrorDomain
Code: 2
Failure Reason: The plug-in “com.apple.dt.UVKit” at path “/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework” could not be loaded. The plug-in or one of its prerequisite plug-ins may be missing or damaged.
Recovery Suggestion: The plug-in or one of its prerequisite plug-ins may be missing or damaged and may need to be reinstalled.
User Info: {
DVTPlugInDYLDErrorMessageErrorKey = "dlopen(/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit, 0): Symbol not found: _$s2IDs12IdentifiablePTl\n Referenced from: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit\n Expected in: /usr/lib/swift/libswiftCore.dylib\n in /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
DVTPlugInExecutablePathErrorKey = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
DVTPlugInIdentifierErrorKey = "com.apple.dt.UVKit";
NSFilePath = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework";
}
--
The bundle “UVKit” couldn’t be loaded.
Domain: NSCocoaErrorDomain
Code: 3588
Failure Reason: The bundle couldn’t be loaded.
Recovery Suggestion: Try reinstalling the bundle.
User Info: {
NSBundlePath = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework";
NSDebugDescription = "dlopen(/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit, 265): Symbol not found: _$s2IDs12IdentifiablePTl\n Referenced from: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit\n Expected in: /usr/lib/swift/libswiftCore.dylib\n in /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
NSFilePath = "/Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework/UVKit";
}
--
I was able to get my SwiftUI project running on Catalina beta 4 with Xcode beta 5. I too got the warning mentioned by OP.
And as mentioned in comments, the only negative impact I've seen is being unable to use the preview canvas. Other than that, everything else in my project is running well. Just using the simulator more ;)
Problem is gone on Catalina build 19A558d when installing Xcode 11 GM Seed (build 11A419c, released September 10, 2019)
this will get rid of the error message but will not bring canvas back.
based on:
https://forums.developer.apple.com/thread/120614
Please go to: /Applications/Xcode-beta.app/Contents/PlugIns/UVKit.framework and delete all the shortcut files in all folders of UVKit.framework (Be sure DONOT delete orginal files).

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/

XCode doesn't run or even install project on device

I'm working on an iOS project in Xcode 6.1 (which includes an app extension, in case that's relevant). When I try to run the project on Xcode, however, it doesn't actually run the project -- it just says its finished running seconds after "Running [My target]" appears in the Xcode window's toolbar. A (2) in a grey circle appears to the left of the running text before the app "finishes," on successful runs there is usually a (3).
If I delete the app from the device and try to build and run it again, Xcode claims that it finished running without ever installing it in the first place.
In the console of my computer, I can see the following messages:
10/23/14 9:56:33.045 AM Xcode[86586]: AMDeviceSecureInstallApplicationBundle (thread 0x11e05f000): no old package to delta against, falling back to old skool install
10/23/14 9:56:33.045 AM Xcode[86586]: AMDeviceSecureInstallApplicationBundle (thread 0x11e05f000): Blasting the bundle over to the device in an old skool way
10/23/14 9:56:37.949 AM Xcode[86586]: AMDErrorForMobileInstallationCallbackDict (thread 0x11c59e000): GOT AN ERROR 0xe800003a
10/23/14 9:56:37.956 AM Xcode[86586]: SZConduit: _MonitorResultDispatchFunction:140 (0x0x11c59e000): Got error from service: InstallationFailed
10/23/14 9:56:37.956 AM Xcode[86586]: _AMDeviceTransferAndInstall (thread 0x11e05f000): SZConduitSendPathWithPreflight failed: 0xe8008017
10/23/14 9:56:37.960 AM Xcode[86586]: writeDictToFile:1258 ==== Successfully wrote Manifest cache to /var/folders/yt/lbzml8ns3f5dfg7chpk14s2h0000gp/C/com.apple.DeveloperTools/6.1/Xcode/af8b53723f8db55690c776f7ae336036/2031be7d6eb56fd1d8e5c85034f9500facb31def/ManifestCache.plist
10/23/14 9:56:37.961 AM Xcode[86586]: AMDeviceSecureInstallApplicationBundle (thread 0x11e05f000): returning 0xe8008017
No one else working on this project has this issue. Occasionally I see an error message with something like "Can't run, a signed resource is missing or has been altered," but this is pretty rare.
I've tried reinstalling Xcode, this does nothing.
Deleting Derived data fixes the issue, but I have to delete it after every run or the problem reappears. This is pretty inconvenient, so I'm looking for a more permanent fix.

Resources