Skip to content

Instantly share code, notes, and snippets.

@T1T4N
Created July 12, 2022 14:38
Show Gist options
  • Save T1T4N/e016100e29881b45cf5f57dc4f24bbdd to your computer and use it in GitHub Desktop.
Save T1T4N/e016100e29881b45cf5f57dc4f24bbdd to your computer and use it in GitHub Desktop.
Creating an Xcode Source Extension

Build Settings

Depending on the project requirements, these are the necessary changes it running:

  • Set the correct ARCHS (standard or only x86_64)
  • Add XcodeKit.framework dependency (Embed and Sign) to the extension target
  • If Swift code needs to be parsed, Embed and Sign the following library:
    • $(DEVELOPER_DIR)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/lib_InternalSwiftSyntaxParser.dylib

Troubleshooting

Menu item is there but disabled

It's a state issue with how macOS automatically handles plugins.

  1. Make sure you have no other bundle with the same Bundle ID installed on the system
  2. Uncheck it from the Extensions list in System Preferences
  3. Clean rebuild the extension
  4. Run the debug build
  5. Command + Q Xcode
    • Make sure you actually quit Xcode so that it doesn't have a dot on the dock
  6. Check the extension entry in the Extensions page
  7. Run this command
    • /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f "/path/to/Extension.app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment