All posts by admin

Adding LumberJack via source code to your project

ref – http://code.tutsplus.com/tutorials/cocoalumberjack-logging-on-steroids–mobile-15287

Go to CocoaLumberJack’s site and download their source code here

Unzip the LumberJack project and take a look at the LumberJack class folder’s source files.

lumberjack-class-directory

Import LumberJack’s Source files

Start a new xCode project.

Drag the listed files:

  • DDLog.h/.m
  • DDASLLogger.h/.m
  • DDTTYLogger.h/.m
  • DDFileLogger.h/.m
  • DDLegacyMacros.h
  • DDLegacyMacros.h

lumberjack-drag_to_proj

from the LumberJack project’s class folder, and into your project.

Creating the PCH file

Long ago, if there is a utility class that a developer needs for every of his source files, its very tiring for them to import that utility .h file in every of their source file. Hence, Prefix.pch was invented.

It is a precompiled header. It implicitly is included at the start of every source file. In other words, it’s like as if each source file adds:

Hence, you can easily include lumberjack’s functionality in all of your source code by using PCH file.

File >> New >> File
lumberjack-create-pch-file

Other >> PCH file

lumberjack-create-pch-file-2

use “Logging-PrefixHeader.pch”
make sure you check the checkbox for adding it to our target.

lumberjack-pch-file-3

Add

inside the ifndef statements.

Then at the end of the file, add

Your Logging-PrefixHeader.pch file should look like this:

Project Build Settings

Then in your Project, select your Target, Build Settings, and in the search box, type prefix. Scroll down and you’ll see Apple LLVM 7.0 – Language.

In Prefix Header, enter your .pch file name. In our case it would be Logging_PrefixHeader.pch.

Using the code

Add the following imports for DD in your AppDelegate.m file:

Then also in AppDelegate.m, insert the code as shown below:

Build and run the project. You should now see the log messages in your console.

Go to your Logging-PrefixHeader.pch file, highlight the macro LOG_LEVEL_VERBOSE, right click, and select “Jump To Definition”. Use all the different MACROS for setting what kind of log messages you want to see.

Installing xCode Colors Plugin

Install xCode color plugin by following the directions provided here.

Make sure you restart xCode.

Open up your project and in AppDelegate.m:

You should now see that your log messages are color-coded.

Adding colors to xCode debug console

download the project from here

1) Open the XcodeColors project with Xcode
2) select the XcodeColors Plugs in your target.

xcode-colors

Then compile and build it.

xcode-build

When you do this, the Xcode plugin is automatically copied to the proper location.
This is done via the build settings.

Validate by opening up Finder. While the window is opened, press command + Shift + g.

Then copy and paste the below into it.

You should see the plugin file there.

Now completely Quit Xcode
Re-Launch Xcode

linker framework issue when Cordova iOS proj adds Watch

First export an iOS project using Cordova like so here

After that, if you decide to add Apple Watch code, you must resolve some framework linker issues.

framework not found AVFoundation….etc

The idea is that when you add target for Apple Watch, it links to a few frameworks that overlaps with the Target’s frameworks. Thus, if you remove the overlapping frameworks in the Apple Watch, the linker issue will disappear.

You need to select your Watch’s extension, and under Build Settings, type in linker, and you’ll see all the frameworks that it links to.
Then remove everything except -ObjC.

linkder-issue-watchext

Do the same for Apple Watch:

linker-issue-watch

Also, make sure your build versions all match in numbers:

plist-files

Creating iOS app with Cordova

ref – https://cordova.apache.org/docs/en/4.0.0/guide/cli/

Install Cordova

Open up terminal:

Install the emulator

Creating the Cordova Project

arg1 (hello) – specifies a directory to be generated for your project. This directory should not already exist, Cordova will create it for you. Its www subdirectory houses your application’s home page, along with various resources under css, js, and img, which follow common web development file-naming conventions. These assets will be stored on the device’s local filesystem, not served remotely. The config.xml file contains important metadata needed to generate and distribute the application.

arg2 (com.example.hello) – provides your project with a reverse domain-style identifier.

arg3 (HelloWorld) – The third argument HelloWorld provides the application’s display title. This argument is optional. You can edit this value later in the config.xml file, but do be aware that there may be code generated outside of config.xml using this value, such as Java class names. The default value is HelloCordova, but it is recommended that you select an appropriate value.

Adding the iOS platform

This will create an ios folder in your Cordova’s platforms folder.

go into the ios folder, open the project in xCode, and run it.

pointer array parameter passing

Create a new Array on the Heap

Creating a new array on the heap basically means:

1) we create a row of new objects that are next to each other
2) We then have an index pointer pointing to it. A index pointer is a pointer pointing to the FIRST element of the array. That way, we can access the rest of the array. If there is no index pointer, we wouldn’t know how to access the rest of the array elements.

1) We create the row of new objects like so:

2) Then we create the index pointer and point to it like so:

That’s it, and what this looks like in memory is this:

ptr_to_array

The index pointer by default is pointing to the 1st, or 0th element of the array.
The reason why we have an index pointer is so that we can reference the whole array like so:

0th element *(arrayA)
1st element *(arrayA + 1)
2nd element *(arrayA + 2)
nth element *(arrayA + n)

Thus, you can display all the elements in an array via an for loop and simply using the index i to display whatever element you’d like. That is the most important purpose of the index pointer.