how to make a finder sync extension load automatically? - cocoa

i create a cocoa application project, and add target "Finder sync extension". Then the "finderSync.appex" will be put to ".../Contens/Plugins/" folder. But when i launch the application, the extension is not loaded automatically, should i load it manually ? How can i load it ?
From the Apple developement guide, it says:
For OS X to recognize and automatically load the Finder Sync extension, the extension target’s info.plist file must contain the following entries:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict/>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.FinderSync</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).FinderSync</string>
</dict>
I already set as the above, but it doens't work.

You need to register your extension with Finder:
pluginkit -a <path you your appex>
You might also need to tell Finder to enable your extension:
pluginkit -e use -i <ID of you appex>

Related

Undefined dictionary in Info.plist

Sep 4 18:26:17 MacBook-Pro-77 com.apple.dt.Xcode[315] :
installApplication:withOptions:error:: Error
Domain=IXUserPresentableErrorDomain Code=1 "This app could not be
installed at this time." UserInfo={NSLocalizedDescription=This app
could not be installed at this time., NSUnderlyingError=0x7fd558a69980
{Error Domain=MIInstallerErrorDomain Code=39 "Appex bundle at
/Users/mrinmaykalita/Library/Developer/CoreSimulator/Devices/4E1C6B5B-2711-47ED-B8B6-27DA419E4609/data/Library/Caches/com.apple.mobile.installd.staging/temp.9nyJrs/extracted/Beam.app/Watch/Beam
Watch.app/PlugIns/Beam Watch Extension.appex with id
com.bpl.Beam.watchkitapp.watchkitextension does not define an
NSExtension dictionary in its Info.plist"
UserInfo={LegacyErrorString=AppexBundleMissingNSExtensionDict,
FunctionName=-[MIPluginKitPluginBundle overlaidInfoPlistWithError:],
SourceFileLine=213, NSLocalizedDescription=Appex bundle at
/Users/mrinmaykalita/Library/Developer/CoreSimulator/Devices/4E1C6B5B-2711-47ED-B8B6-27DA419E4609/data/Library/Caches/com.apple.mobile.installd.staging/temp.9nyJrs/extracted/Beam.app/Watch/Beam
Watch.app/PlugIns/Beam Watch Extension.appex with id
com.bpl.Beam.watchkitapp.watchkitextension does not define an
NSExtension dictionary in its Info.plist}}}
In the above output from CoreSimlutor.log; why is com.apple.mobile.installd.staging referred to when that folder does not exist or get created in running.
Any quick workouts kindly please?
I checked that the key exists in Info.plist for
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>WKAppBundleIdentifier</key>
<string>com.bpl.Beam.watchkitapp</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
</dict>
Thanks
I had this problem after changing location of Info.plist file for app/WatchKit extension or WatchKit app. Other reason may be just renamed folder for WatchKit app or extension.
You have to clean all targets including main application, extensions and WatchKit app. I had to perform clean using Cmd+Shift+K for each target once changing targets in drop down in Xcode one after another.

dispatch_once Error when running FacebookSDK

I don't know whats wrong, I installed FacebookSDK using Cocoapods (as always), and I am getting an error in this method:
_dispatch_once(dispatch_once_t *predicate, dispatch_block_t block)
{
if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
dispatch_once(predicate, block);
}
}
The red line of the error is on the line dispatch_once (predicate, block); . I am not doing anything different than other times using FacebookSDK.
Can anyone help?
Configure your info.plist (find it in the Supporting Files folder in your Xcode Project).
Right-click your .plist file and choose "Open As Source Code".
Copy & Paste the XML snippet into the body of your file (inside of the <dict>...</dict>):
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>FB + AP-ID</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string> AP-ID </string>
<key>FacebookDisplayName</key>
<string>App-Name</string>
If you use any of the Facebook dialogs (e.g., Login, Share, App Invites, etc.) that can perform an app switch to Facebook apps, your application's .plist also need to handle this.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
Source: Facebook SDK Documentation
My app kept crashing and producing the error message:
'The service configuration is `nil`
on the same line:
dispatch_once(predicate, block);
while trying to implement AWS Auth via the Mobile Hub into my iOS app.
I spent a lot of hours editing my info.plist, googling solutions, and re-downloading the awsconfiguration.json file only to discover that my "Target Membership" box in the right side bar of Xcode was unchecked. Once I checked it my app successfully built with AWS Auth working fine.
Hope this helps someone.
So I had the same issue, and fixed it by reinstalling all of my pod files by removing from Podfile, running "pod update" and then readding them and running "pod update" again. Worked like a charm.

Why I can't Cmd-Tab to my application window on Mac OS X 10.9 after upgrading to XULRunner 33?

I have a standalone XULRunner application that was previously running XULRunner 1.9.2 (old, I know). I just upgraded to XULRunner 33.
Previously, When I was developing locally (MacBook Pro with Mac OS X 10.9.5), I would often Cmd+Tab between my IDE and my application.
After the upgrade, I can no longer do this. I still get a window on my desktop (as defined in main.xul), but it no longer appears in my Cmd+Tab list. I have to "find" it on the desktop.
Closing the window quits the application, etc., and the fact that I'm getting an application window at all implies that my main.xul is correct... but I don't know why this is.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://my-app-name/skin/css/main.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://my-app-name/locale/main.dtd">
<window id="main" title="&window-title;" width="750" height="530" persist="width,height,screenX,screenY,sizemode" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script><!-- MY APPLICATION CODE HERE --></script>
<keyset>
<key modifiers="accel" key="W" oncommand="window.close()"/>
<key modifiers="accel" key="Q" id="quit"/>
</keyset>
<toolbox>
<menubar>
<menu id="menu_file" label="File" hidden="true">
<menupopup>
<menuitem id="menu_FileQuitItem" key="quit" label="Quit" oncommand="goQuitApplication();"/>
</menupopup>
</menu>
</menubar>
</toolbox>
</window>
I've read through the Windows and menus in XULRunner tutorial:
The same code on XULRunner 1.9.2 runs fine and I can "activate" the window. With the new XULRunner, the window title appears greyed out in Mac OS X and is not selectable.
Any ideas of what to try?
I don't know if it's helpful, but I also used to get a menu bar in OS X as well, when the window was selected. Even now if I click on the window's title bar, the menu bar that OS X displays does not show my application's menu.
I don't know what was changed, or when they changed it, but this behavior is somewhat documented on MDN.
Excerpt from Getting started with XULRunner:
On the Mac, before you can run a XULRunner application with everything intact, you must install it using the --install-app xulrunner commandline flag. Installing the application creates an OS X application bundle:
The page goes on with some steps for how to do this, but I was never able to get them to work with modern XULRunner versions.
The only way I was ever able to get modern XULRunner versions to fully work is to create the application bundle manually.
In this example, I am going to use the "hello world" example referenced in the MDN docs.
Step 1:
Create the following directory structure.
hello.app/
Contents/
MacOS/
Resources/
Step 2:
Download the version of XULRunner runtime you want (I'm using 33), and extract the XUL.framework.
Step 3:
Copy all of the files inside XUL.framework/Versions/Current/ to hello.app/Contents/MacOS/.
Also copy the dependentlibs.list into hello.app/Contents/Resources/
Step 4:
Download the example files, and copy the following files and directories to hello.app/Contents/Resources/.
chrome/
defaults/
application.ini
chrome.manifest
Step 5:
Due to another issue, the xulrunner binary will not automatically find the application.ini like it's supposed to. To work around this, we will need a stub loader, like this one I wrote previously.
#!/bin/sh
runpath="`dirname "$0"`"
contentsdir="`cd "$runpath"/.. > /dev/null && pwd`"
exec "$runpath/xulrunner" --app "$contentsdir/Resources/application.ini"
Create a new file named hello at hello.app/Contents/MacOS/hello, put the code above inside, and give it executable permissions (chmod +x hello).
Step 6:
Now we need a Info.plist file. Here is one I created based on the Deploying XULRunner example. Note that the CFBundleExecutable must match the stub loader file name above.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>hello</string>
<key>CFBundleGetInfoString</key>
<string>1.0</string>
<key>CFBundleIconFile</key>
<string>app_icon.icns</string>
<key>CFBundleIdentifier</key>
<string>net.yourcompany.yourapplication</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>applicationName</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
Save this file under hello.app/Info.plist.
Step 7:
Create a new file named PkgInfo at hello.app/PkgInfo, and put this text inside.
APPL????
Step 8:
You should now be able to run your application with and menu and doc icon, and Cmd + Tab capabilities. You can open it by Finder, or the command line.
$ ./hello.app/Contents/MacOS/hello

Can the name of the bundle application be different of the name of the executable file?

I have a sandboxed login item whose executable file name is something like X174423.MyApp because it is prefixed with my developer ID. I'd like to set the bundle name for this helper application to MyApp.
In Xcode 5, I've tried to change the bundle display name but the name of the bundle does'nt change.
I've created a CFBundleDisplayName entry in the InfoPlist.strings but the name of the bundle reminds the same.
It seems that I've missed something but what ?
If I understand correctly, you'd like to have the bundle to be shown in Finder as MyApp. I don't know why exactly it has to be like this, but it's working for us the following way. In your Apps Info.plist:
<key>CFBundleDisplayName</key>
<string>X174423.MyApp</string>
<key>CFBundleName</key>
<string>X174423.MyApp</string>
and following in the InfoPlist.strings:
/* Localized versions of Info.plist keys */
CFBundleDisplayName = "MyApp";
CFBundleName = "MyApp";
Alternatively you could try this in Info.plist and don't use InfoPlist.strings:
<key>CFBundleExecutable</key>
<string>X174423.MyApp</string>
<key>CFBundleDisplayName</key>
<string>MyApp</string>
<key>CFBundleName</key>
<string>MyApp</string>

Changing the default header comment license in Xcode

Whenever I create a new .cpp/.h file in Xcode a comment is added to the top of the file. For example:
/*
* <file>.cpp
* <Name of project>
*
* Created by <My name> on <Date>.
* Copyright <Year and company>. All rights reserved.
*
*/
I want to change the default comment to be another license, like GPL/LGPL/ or something else. Is there somewhere I can change this behavior in Xcode?
With Xcode 9 there is a built-in option which you can find in the details below.
Create a property list file named IDETemplateMacros.plist
Add a FILEHEADER value to the Root and set its string value with your copyright text like Copyright © 2017 ...
Copy the file to one of the following locations
For a single project and user
<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
For all team members in a single project
<ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
For all projects in a workspace for a single user
<WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
For all projects in a workspace for all team members
<WorkspaceName>.xcworkspace/xcshareddata/IDETemplateMacros.plist
For everything you work on, regardless of project
~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
Create a new file - you should see the new copyright header
Sample IDETemplateMacros.plist for copy and paste:
<?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>FILEHEADER</key>
<string>
// Created by Your Name on 29.12.17.
// Copyright © 2017 Your Company. All rights reserved.
// </string>
</dict>
</plist>
First try changing your Name and Organization your contact card in Address Book.
If that doesn't work, open System Preferences > Users & Groups > Right click on your user (System Preferences must already be unlocked) > Advanced Options... > Change the name in the Full Name text box.
To change the organization name in Xcode click on the project file so it is selected (left sidebar of Xcode in the Project navigator) > In the File Inspector (right sidebar of Xcode) change the Organization text box.
This blog post has some good steps for modifying file templates in Xcode 4.3:
http://error-success.piku.org.uk/2012/04/27/how-to-make-xcode-4-3-2-templates/
The /Developer folder no longer exists, so you copy the templates from within the Xcode.app bundle located in /Applications:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/
And place your modified copy here, as before:
~/Library/Developer/Xcode/Templates/File\ Templates/
UPDATE: I decided to write a script that would extract the built in Xcode templates and replace the headers. Source and instructions can be found at the following url:
https://github.com/royclarkson/xcode-templates
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates
any update of your SDK will wipe changes here so keep your template backed up somewhere else
Don't edit anything in /Developer as Apple can overwrite this at any time.
The following works for Xcode 4, 5 and 6 except later source differs and is under /Applications
Instead copy the templates that you want to change from /Applications/Xcode<version>.app/Contents/Developer/Library/Xcode/Templates to ~/Library/Developer/Xcode/Templates/File Templates and then edit the files keeping the same directory structure but edit the directory name that is the template to not show up a a duplicate in Xcode.
e.g for a new category of C/C+ files in Xcode 5 copy /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/C and C++ to ~/Library/Developer/Xcode/Templates/File Templates/GPL C and C++
this process is copied from Red Glasses's blog
For Xcode 4 the source path is or for Xcode 4 /Developer/Library/Xcode/Templates/File Templates
– Press ⌘ 1 to display the File Navigator.
– Click on the name of your project at the top of the File Navigator.
– Press ⌘⌥⇧ ⏎ (that's Command Option Shift Return) to view the Version Editor.
– Make sure that the Comparison View is shown(View > Version Editor > Show Comparison View).
This lets you see the raw text of your project's project.pbxproj file.
– Press ⌘ f to search the project.pbxproj file, paste in ORGANIZATIONNAME and press Return.
This is where the name of the organization that follows the copyright text is defined.
Or open Xcode's plist at
~/Library/Preferences/com.apple.dt.Xcode.plist
And change the organizationName key's value.
Or select the project from the Navigator pane and display the File Inspector with ⌘⌥ 1.
Look at the Organization value under Project Document. Change the value there.
In Xcode 12.4
Using Xcode, create a plist file named IDETemplateMacros.
Save it to the Desktop initially while you configure it.
If you cannot see the file in the Project Navigator then from the Xcode menu, select View > Navigators > Project
Right click on the filename and select Open as > Source Code
The following is a template that works nicely for me so chances are it will for you too.
<?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>FILEHEADER</key>
<string>
//
// ___FILENAME___
// ___PACKAGENAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___
// Copyright © ___YEAR___ ___FULLUSERNAME___. All rights reserved.
//
</string>
</dict>
</plist>
Copy and paste the above overwriting the existing contents.
Save the file and close it.
In Finder navigate to the following folder:
~/Library/Developer/Xcode/UserdData/
Drag the file from your Desktop to this Folder and then test using Xcode to create a new project.
It's very simple:
Open up terminal
In one line, write the following:
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions -dict ORGANIZATIONNAME "Blah, Inc"
You don't have to worry about changing directories beforehand or anything else. It works instantly.
Change the details in your Address Book - add a company name. It will pick it up from there.
Try modifying this file:
/Developer/Library/Xcode/File\ Templates/C\ and\ C++/Header\ File.pbfiletemplate/header.h
Works with Xcode 14
Say you want to modify (or get rid of) the XCode Header comment.
First open XCode, Use File > New File... (⌘N) and choose Property List from the file templates.
Name it file IDETemplateMacros.plist
On the navigator, select the file as right-click Open as source code. Xcode will show us the property file as text. Property files are really just XML files.
Copy paste the following content:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>Created for ___PROJECTNAME___ in ___YEAR___
// Using Swift ___DEFAULTTOOLCHAINSWIFTVERSION___</string>
</dict>
</plist>
On the root dict we have added an entry with key FILEHEADER and a two-lines string as a value:
Created for ___PROJECTNAME___ in ___YEAR___
// Using Swift ___DEFAULTTOOLCHAINSWIFTVERSION___
Save the file IDETemplateMacros.plist on the folder:
~/Library/Developer/Xcode/UserData/
That's it, now when creating a new project called MyProject, the header will be:
//Created for MyProject in 2022
// Using Swift 5.0
Note1. There is a list of macros on https://help.apple.com/xcode/mac/9.0/index.html?localePath=en.lproj#/dev7fe737ce0
Note 2. As an example you can write:
Created ___DATE___
// ___COPYRIGHT___
Note that there is a leading space but you do not include the // for the comment on the first line.
Note 3. For a more list of options see:
https://useyourloaf.com/blog/changing-xcode-header-comment/
In Xcode 4.2, they're here:
/Developer/Library/Xcode/Templates/File Templates
I just changed the template of a SwiftUI file, you have to open Xcode's Contents and look for the template files you want to change.
To change the SwiftUI template the path is this:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/MultiPlatform/User\ Interface/SwiftUI\ View.xctemplate
You nedd open with sudo
For AppCode users:
Go to preferences (CMD + ,)
Editor-File and Code Templates
Change Scheme to Project
Modify Files and/or Includes as you need.
add to git .idea/fileTemplates if needed
You can override the text macros globally, or for an individual workspace or project. You can also decide to keep the macros for a single user or share it with all users.
The full list of locations that Xcode searches, in order of priority:
Project - single user
<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/
Project - shared by all users
<ProjectName>.xcodeproj/xcshareddata/
Workspace - single user
<WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/
Workspace - shared by all users
<WorkspaceName>.xcworkspace/xcshareddata/
Globally for Xcode
~/Library/Developer/Xcode/UserData/
I don't remember what was the default template but you can make a template in any way you like using textMacros:
// ___FILENAME___
// ___PACKAGENAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// ___COPYRIGHT___
//
There are some other textMacros if you like more customization, but these are enough for making something like the default one.
You can create the file yourself if no files found at the path

Resources