Last active
August 29, 2015 13:56
-
-
Save samdmarshall/9050864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// bundle.c | |
// Daodan | |
// | |
// Created by Sam Marshall on 2/16/14. | |
// Copyright (c) 2014 Sam Marshall. All rights reserved. | |
// | |
#ifndef Daodan_bundle_c | |
#define Daodan_bundle_c | |
#include "bundle.h" | |
#define kCFDaodanPreferenceBundle CFSTR("com.samdmarshall.Daodan") | |
bool Daodan_DetectBundle() { | |
bool foundBundle = false; | |
CFStringRef currentApp = CFBundleGetIdentifier(CFBundleGetMainBundle()); | |
CFArrayRef knownApps = (CFArrayRef)CFPreferencesCopyAppValue(CFSTR("RegisteredPlugins"), kCFDaodanPreferenceBundle); | |
CFShow(knownApps); // SDM: this line here will cause bad things | |
// By removing line 20, the rest of the code executes fine | |
CFIndex knownAppsCount = CFArrayGetCount(knownApps); | |
for (CFIndex index = 0; index < knownAppsCount; index++) { | |
CFDictionaryRef app = (CFDictionaryRef)CFArrayGetValueAtIndex(knownApps, index); | |
CFShow(app); | |
CFStringRef appIdentifier = CFDictionaryGetValue(app, CFSTR("CFBundleIdentifier")); | |
if (CFStringCompare(appIdentifier, currentApp, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { | |
printf("found a registered plugin for current app!\n"); | |
CFShow(app); | |
// However when i get to here, the dictionary that should have two values only ever displays the one value (CFBundleIdentifier) | |
} | |
} | |
return foundBundle; | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>RegisteredPlugins</key> | |
<array> | |
<dict> | |
<key>CFBundleIdentifier</key> | |
<string>com.somedomain.someapp</string> | |
<key>LoadPlugin</key> | |
<string>~/Library/Application Support/Daodan/Test.dylib</string> | |
</dict> | |
</array> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment