Sha256: 00ffcb32e17a522207de2f4859e4e4df29546ff0ba0c1d7b42a9578babb157e1

Contents?: true

Size: 1.54 KB

Versions: 25

Compression:

Stored size: 1.54 KB

Contents

// Dumps a key from a fixture bundle created like so:
//
// $ xcrun clang -framework Foundation -bundle ArtsyKeys.m -o ArtsyKeys.bundle

#import <Foundation/Foundation.h>
#include <dlfcn.h>
#include <stdio.h>

int main(int argc, char **argv) {
  if (argc != 3) {
      fprintf(stderr, "Usage: dump-key path/to/fixture.bundle [KEY]\n");
      return 1;
  }

  char *fixturePath = argv[1];
  char *keyName = argv[2];

  if (dlopen(fixturePath, RTLD_NOW) == NULL) {
      fprintf(stderr, "[!] Unable to load bundle at path `%s`: %s\n", fixturePath, strerror(errno));
      return 2;
  }

  NSString *fixtureClassName = [[[NSString stringWithUTF8String:fixturePath] lastPathComponent] stringByDeletingPathExtension];
  Class fixtureClass = NSClassFromString(fixtureClassName);
  if (fixtureClass == nil) {
      fprintf(stderr, "[!] Unable to load fixture class `%s` from bundle at `%s`\n", [fixtureClassName UTF8String], fixturePath);
      return 3;
  }

  SEL keySelector = sel_registerName(keyName);
  if (![fixtureClass instancesRespondToSelector:keySelector]) {
      fprintf(stderr, "[!] Unable to find key `%s` in fixture class `%s` from bundle at `%s`\n", keyName, [fixtureClassName UTF8String], fixturePath);
      return 4;
  }

  NSString *key = [[fixtureClass new] performSelector:keySelector];
  // TODO Or is a `nil` entry fine?
  if (key == nil) {
      fprintf(stderr, "[!] Got `nil` for key `%s` in fixture class `%s` from bundle at `%s`\n", keyName, [fixtureClassName UTF8String], fixturePath);
      return 5;
  }

  printf("%s\n", [key UTF8String]);
  return 0;
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cocoapods-keys-2.3.1 spec/fixtures/dump-key.m
cocoapods-keys-2.3.0 spec/fixtures/dump-key.m
cocoapods-keys-2.2.1 spec/fixtures/dump-key.m
cocoapods-keys-2.2.0 spec/fixtures/dump-key.m
cocoapods-keys-2.1.0 spec/fixtures/dump-key.m
cocoapods-keys-2.0.7 spec/fixtures/dump-key.m
cocoapods-keys-2.0.6 spec/fixtures/dump-key.m
cocoapods-keys-2.0.5 spec/fixtures/dump-key.m
cocoapods-keys-2.0.4 spec/fixtures/dump-key.m
cocoapods-keys-2.0.3 spec/fixtures/dump-key.m
cocoapods-keys-2.0.2 spec/fixtures/dump-key.m
cocoapods-keys-2.0.1 spec/fixtures/dump-key.m
cocoapods-keys-2.0.0 spec/fixtures/dump-key.m
cocoapods-keys-1.7.0 spec/fixtures/dump-key.m
cocoapods-keys-1.6.1 spec/fixtures/dump-key.m
cocoapods-keys-1.6.0 spec/fixtures/dump-key.m
cocoapods-keys-1.5.2 spec/fixtures/dump-key.m
cocoapods-keys-1.5.1 spec/fixtures/dump-key.m
cocoapods-keys-1.5.0 spec/fixtures/dump-key.m
cocoapods-keys-1.4.0 spec/fixtures/dump-key.m