Tuesday, October 25, 2016

How to create PDFs from images in Mac OS

Creating a PDF from images as daunting it may seem, is quite easy to do in a Mac. It comes with a PDF creator which can be accessed from the print menu.
The simple steps are as follows:

  1. Select all the images that you want in the PDF by pressing Command while selecting, and right click to open with Preview.
  2. If you don't see the sidebar with thumbnails, click View -> Thumbnails.
  3. Reorder the thumbnails, as you would like them to appear in the PDF.
  4. You can also add additional images by dragging them to the thumbnail sidebar.
  5. Click File -> Print.
  6. In the bottom left corner you will see a Menu labeled PDF.
  7. Click the label to open the menu, and select "Save as PDF."
  8. Now you can save the pdf with an appropriate name at an appropriate location.
That's it!

Saturday, October 22, 2016

XCode Objective-C custom frameworks and iOS 10

There are two kinds of frameworks, those that come with XCode and those that you create on your own. Those that come with XCode can be used without any special steps, albeit the headers, but the other ones need special configuration, and there are two ways to it:
First, Drag the framework package, e.g. somelib.framework, to the Frameworks folder of the project and choose to copy the framework to the project and you are done. The problem with this approach is that the framework is "copied" to the project, so any changes that you may do to the framework in its own project, and new builds would not be reflected immediately and automatically in the dependent project. You will have to copy again and again for every change that you make.

Second, Add the framework package by drag 'n' drop, but do not copy. You can access the framework in XCode, but the linker will throw an error, stating the framework is missing. It's because the XCode does not take an additional step that it definitely should, and that is to add the framework's path to Framework Search Paths automatically, which you will have to do manually.

To add the path, select the target and go to "Build Settings." Scroll down to find the section labeled  "Search Paths". Under that you will find "Framework Search Paths". When you double click on the blank space on the right, it will open up a list with (+) and (-) buttons. Add the (+) button and add the path to the folder in which the framework is located, and you are good to go. Now the linker will link without throwing an error.

For iOS 8 and later, there would be a runtime error about missing library, stating, "dyld: Library not loaded ... Reason: image not found." This can be fixed by selecting the target and going to "General." After scrolling down, you should see a section labeled "Embedded Binaries." Press the (+) sign, and add the framework in question, and your app should not crash. That's it.