Apple Mail.app Plugin Development

mail.app plugin development

I used to receive an emails about How to: Apple Mail.app plugin development? then responded with enough details to begin their journey.  Then I thought create an article around Apple Mail.app plugin development for community.

I believe this article would provide guidance for your plugin development. Have queries use Disqus thread at the end of article.

Attention: Apple doesn’t support officially plugin development for Mail.app. Hence no documentation & support around it. Okay let’s say the word ‘No warranties :)’

If I get an enough time, will do article for –

  • Custom menu & menu commands into the Mail.app
  • Utilizing Mail.app preferences file, so migration/upgrade is easy for users
  • Custom preferences panel & preferences file
  • Custom window

Steps to create a Mail.app plugin

Note: Following steps using Xcode 5.1.1, could be used with other version too. Ensure values are placed in appropriate places.

Step 1

Create a Xcode project type ‘Bundle‘ and Click ‘Next

  • Enter  Product Name
    • For example: SampleMailPlugin
  • Enter Company Identifier
    • For example: com.myjeeva
  • Click Next
  • Save dialog appears, save SampleMailPlugin Xcode project to hard drive

Step 2

Select a Project in the navigator, target is selected by default

  • Fill up following Key value as per need (All the values here goes to Info.plist)
    • Bundle name
    • Bundle identifier
    • Bundle version
  • Enter Class Prefix under ‘Project Document‘ Section
    • For example: SMP

Step 3

Select a Project

  • Go to ‘Info‘ Tab and pick OS X Deployment Target
  • Go to Build Settings Tab
    • Select  ‘Base SDK‘ per choice
    • set ‘Debug Information format‘ value to  DWARF
    • set ‘Installation Directory‘ value to $(HOME)/Library/Mail/Bundles
    • set ‘Info.plist‘ value to  SampleMailPlugin-Info.plist
    • set ‘ProductName‘ value to  SampleMailPlugin

Step 4

Select ‘SampleMailPlugin‘ group on Project Navigator

  • Create a Objective-C class
    • For example: create SampleMailPlugin class, prefix is pre-populated
  • Now SMPSampleMailPlugin.h & SMPSampleMailPlugin.m gets created

Step 5

Select project root ‘SampleMailPlugin‘ on the Project Navigator

  • Select ‘SampleMailPlugin‘ target from popup menu
  • Go to Info Tab (All the values here goes to Info.plist)
    • Add a Key Principle class and choose type as String enter value as ‘SMPSampleMailPlugin‘. This is entrypoint for  mailbundle
    • Add a Key SupportedPluginCompatibilityUUIDs and choose type as Array
      • Fill Mail.app UUID (mail version is 7.3) – D1EFE124-86FF-4751-BF00-80B2C0D6F2E4
      • Get your Mail.app UUID, use for development; this command might help you  defaults read /Applications/Mail.app/Contents/Info PluginCompatibilityUUID
  • Go to ‘Build Settings‘ Tab
    • set ‘Installation Directory‘ value to $(HOME)/Library/Mail/Bundles
    • set ‘Wrapper Extension‘ value to mailbundle
  • Go to ‘Build Phases‘ Tab
    • Add new ‘Build Phase‘ of type Copy Files
    • Double click ‘Copy Files‘ label and Update the heading to Local Deploy
    • Select ‘Destination‘ value as Absolute Path
    • set ‘Path‘ value to ~/Library/Mail/Bundles. It deploys the current build into mentioned local path
    • Click on ‘Plus‘ sign button then choose SampleMailPlugin.mailbundle or just drag a SampleMailPlugin.mailbundle form Project Navigator to here

Step 6

Select SMPSampleMailPlugin.m file on the Project Navigator

  • Create a class method called + (void)initialize { .... }
  • Add following Code Snippet into method initialize

  • Add following interface definition into  SMPSampleMailPlugin.m

Step 7

Let’s build the plugin and test.  Press Command + B  or go to Product menu click Build.

Step 8

Look at our new build mail plugin and  Console.app

  • Open up Finder hold Command + Shift key and press  G
  • Type ~/Library/Mail/Bundles hit the ‘Go‘ button, now SampleMailPlugin.mailbundle should be there
  • Open up Console.app
  • Type ‘Mail‘ in right upper Search text box in Console.app to limit message to Mail.app

Step 9

Final goal, open up Mail.app. Now you should similar message in console.app

Step 10 (Optional)

If you’re using or developing Mail.app plugin for a first time; Plugin support may not be enabled in Mail.app, so execute below command in the Terminal.app. Restart the Mail.app

I believe you’re Happy, spread the word of ReplyWithHeader Mail plugin and give some star on MacUpdate.com and GitHub.com :)


Download

If you have any queries, please leave a comment below!

  SampleMailPlugin Archive
  • Lars Häuser

    GREAT post! I’ve looked for many hours before I found your post. All the others were pretty old. Thumbs ip and thanks.

  • nbenm

    Hi,

    I’ve tried this with Xcode 6.1.1 on yosemite 10.10.1. Many things are different.
    Is it possible for you to update this, it would be great.

    Thanks in advance

    Regards

    nbenm

    • @nbenm:disqus – Thanks for reading! Can you please email me the changes you come across for v6.1.1? I will incorporate it.

      Cheers,
      Jeeva

  • antonigiske

    Thanks for this tutorial!

    But where can I read more on how to do stuff like creating a new folder etc.

    Can I pick your brain about an idea I have for a plugin?

    • @antonigiske:disqus thanks. Mail.app plugin development is a hidden space, you may not find details over internet. If you any questions, please shot it to [email protected]. Will try to answer at earliest.

      Cheers,
      Jeeva

  • Jan

    Thank you for this great tutorial!!
    I just had to change the SupportedPluginCompatibilityUUIDs to my 10.11’s Mail id and already the console reported success :-)
    Now a documentation is missing…

  • Dipang

    Thanks for this tutorial!,

    I want modify mail.app. Add some design for mail tracking functionality. Please guide me how can I do in Xcode 7.3.
    Is it possible with Swift or Objective C? Is their any document?

    Please give me some guideline because I am new here. I don’t know about process and stuff.

    Thanks.

    • @dipang:disqus Apple doesn’t provide any documentation for Mail.app plugin development. I put together my learning in this article; it uses the Objective-C. You can follow this article to create one. I haven’t tried myself using swift for mail.app plugin.

      Cheers,
      Jeeva