Showing posts with label ios. Show all posts
Showing posts with label ios. Show all posts

Friday, 5 September 2014

Ionic & Yeoman

Ionic HTML5 Mobile App Framework 
# create new folder for app and open it
mkdir my-ionic-project && cd $_
# clear npm cache. more info @ NPM config 
rm -rf ~/.npm 
npm clear cache
# install generator-ionic globally
npm install -g generator-ionic
# installs:
  • Lo-Dash.js (Utility Library. Superset of Underscore.js)
  • Chalk (Package for Terminal string styling)
  • MOUT { Modular JS Utility Collection. Use whole package or individual Modules (Helper Methods) }, includes Dependencies:
    • Commander.js (Node.js Full Command-Line Interface Utility)
    • Handlebars (Semantic templates)
    • Istanbul (JS code coverage)
    • Jasmine-Node (Node.js integration of Jasmine Spec Framework)
    • JSHint (JS error detection)
    • MDOC (Markdown based documentation generator)
    • Nodefy { convert AMD JS modules (RequireJS define(..) into Node.js format (module.exports...) }
    • Regenerate (JS RegEx generator
    • RequireJS { Node.js Adapter for RequireJS (loading AMD Modules) incl. Optimiser (Minifies Scripts, CSS Inlined w/out Comments) }
    • RimRaf { Node.js deep Deletion Module (rm -rf) }
    • Rocambole { Recursive walk and manipulate EcmaScript Abstract Syntax Tree (AST) to Compile code (i.e. Rocambole Visualiser) }
  • Yeoman-Generator { Rails-inspired Generator System to Scaffold apps }, adds Additional Dependencies:
    • Dargs { Spawn CLTs by Converting Options Object into Command-Line (CL) Args }
    • Diff { Text Differences for JS (Sample) } 
    • Debug { Node.js Debugging Utility }
    • Mime { Mime-type Mapping API includes Node.js and Apache Project extensions }
    • Text-table { Text Tables borderless and aligned to print to STDOUT }
    • Async (Node.js Utility Module with Functions for Asynchronous JS)
    • Mkdirp (Node.js Recursively create Nested Directories)
    • Isbinaryfile (Node.js check if file is binary)
    • Shelljs (Node.js portable Unix Shell commands)
    • Underscore.string (Underscore.js String manipulation for JS) 
    • Iconv-lite (Convert character encoding/decoding in JS)
    • Glob (Pattern Matching search walking either Sync/Async)
    • Findup-sync (Pattern Matching first File found in current or nearest Ancestor Directory)
    • File-utils { User CLT Sync File and Directory Utils (do not use on Node.js server as is equivalent to Grunt.file) } 
    • Cheerio (Lean Server implementation of core jQuery)
    • Request {Node.js HTTP and HTTPS Request Client (Forwarding, File Streaming, Piping, Proxies, Unix Sockets, Form Data URL Encoding, HTTP Auth, OAuth Signing, Custom HTTP Headers) }
    • Inquirer { Node.js Collection of Common Interactive CLIs (lightweight form of Commander.js }
  • Cordova { Platform to build Native Mobile apps using HTML, CSS, JS }, adds Additional Dependencies:
    • Q { Tool for creating Promises in JS. then method resolves handling eventual return value (fulfillment) or thrown exception (rejection) asynchronously and mitigates the Pyramid of Doom } UncommonJS Promises Manager
    • Semver (NPMs semantic parser of package versions in package.json file)
    • Underscore (Helper Library for JS is Underscore.js)
    • Plist-with-patches (Node.js parsing of Property List files (.Plist) or string into native JS object with Pull requests applied)
    • Optimist (lightweight Option Parsing with Argv Hash)
    • Npmconf (NPM configuration. Alternative RC)
    • Xcode (Node.js parser of xcodeproj/project.pbxproj files)
    • Tar (compression)
    • Elementtree { Module for XML serialization (creation) and parsing }
    • Plugman (Install/Uninstall Cordova plugins)
yo ionic
# installs:


# ionic starter blank creates:
  • Gruntfile.js
  • .gitignore
  • hooks/after_prepare/icons_and_splashscreens.js (Scripts executed before and after directory-related commands) Example Hooks
  • test/spec/controllers.js
# bower_components folder (similar to the /vendor folder in Rails) updated with: 
  • Collide (JS animation engine built by Ionic Framework team allowing developers to hook into every frame)
  • Angular-ui-router (AngularJS flexible routing with nested views to organise parts of interface into a state machine)
  • Angular-mocks (testing)
  • Angular-sanitize (Parse HTML using tokens to avoid unsafe input with ngSanitize)
  • Angular-animate (Animation hooks for common Directives using ngAnimate)
  • Angular-scenario
    • TODO: 
    • TODO - Test Driven Development (TDD)
      • Karma { Cross-browser HTML Test Server & Runner } uses Plugins / Adapters
        • Jasmine { AngularJS Testing Framework
        • Protractor { AngularJS Testing Framework End-to-end using Jasmine as Test Interface and Selenium Server to control browsers}
        • Mocha { JS Testing Framework. Integrates with GitHub }
          • Chai { Assertion Library }
        • PhantomJS { Testing code on Headless Instance }
        • Istanbul { Automatic Coverage Report Generation }
        • RequireJS { Modular Script and Source File Loader. Optimises and Minifies JS for Deployment }
        • QUnit { EmberJS Testing Framework }
      • Continuous Integration & Deployment Pipeline
        • Adobe PhoneGap Build { Free for Open Source. JS. GitHub Integration. }
        • Codeship  { Free for Open Source. Multiple Languages / Endpoints / Tools / Databases. GitHub Integration. }
        • Jenkins CI { AngularJS Automated Tests. GitHub Integration }
        • Travis CI { Automated Tests. GitHub Integration. Integrated using a YAML file. Results in Pull Requests }
        • Semaphore CI { GitHub Integration. Platform includes NodeJS, PhantomJS, and Headless Firefox }
        • CircleCI $19/mth+ { Multiple Languages. GitHub Integration. Fast }
      • Beta Testing
      • Sass
      • Encryption
        • Database Encryption
      • UI Libraries & Tools
      • Scaffolding Tool (modular code shell generator similar to the role of Rails)
        • Yo (Yeoman)
          • Package.json { informs Node.js of specific packages and version the specific project needs installed (instead of all installed globally) }
          • Bower.json { informs Bower of JS and CSS components to install in /app/bower_components }
          • Gruntfile.js { set of task instructions on specific project for Grunt } 
          • Angular Generator of Boilerplate  
            • Generates Modules { controllers, directives, filters, routes (controller + view), services (providers, factories, values, constants), decorators (with config and delegate), views }
            • Modules (resources)
            • Bootstrap
      • Build & Utility Tools (modular Configuration & Tasks)
        • Grunt { i.e. optimisation tasks including JS and CSS concatenation and/or minification (__.main.css, __.plugins.js, __.scripts.js), running local server, JS error checking and unit tests, Grunt server (uses Node.js) for live reload of changes with re-compiled Sass and CoffeeScript. Similar to Ant for Java }
        • Gulp
      • Packaging
      • Package Manager (Dependency Managers. use npm install (or update) [-g] and bower install to install tools in Package.json into /app/node_packages and Bower.json into /app/bower_components)
        • npm (Node Package Manager) { Installation Utility }
        • Bower { Web component dependency installer (i.e. bower install --save __ to add to list of dependencies in Bower.json). Similar to Maven and Ivy in Java }
        • Wiredep { Bower dependency Injection from Grunt into HTML. Manage JS and CSS includes. }
      • APIs
        • Google Maps
        • PubNub (Websockets)
  • Alias Ionic Unix Commands
    • Setup an alias function in your .bash_profile
gii() { gulp sass ; ionic build ios ; ionic emulate ios ; }



Sublime Text 2
  • Custom Tab Spaces
    • Open a document in Sublime Text 2 with the File Extension that you want to apply custom tab spacing to (i.e. two tab spaces preceding the code instead of the default of four spaces when you press the 'tab' key on your keyboard)
    • Go to the Menu and select: Sublime Text 2 > Preferences > Settings - More > Syntax Specific - User
    • Paste the following in the file that has opened automatically and then save it 
{
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "detect_indentation": false
}

Contributions

Links

    Friday, 4 July 2014

    PhoneGap & Apache Cordova (Hybrid Mobile Development)


    PhoneGap & Apache Cordova

    • Usage: Hybrid mobile development using cross-platform app extensions mixing the native (i.e. iOS SDK platform WebViews) and web-side (i.e. embed Cordova-enabled Cleaver WebView using common JavaScript interface with a iOS Cordova plugin mapping to Objective-C service class) app components to streamline API access
    • Hooks: Node.js framework (server-side JavaScript) with build process in Apache Cordova Command Line Interface (CLI) using interface server-side hook scripts to automatically install required plugins when developers check out updated versions of a project - Thanks Holly Schinsky!

    Challenges

    Purchases

    Links

    Tuesday, 1 July 2014

    Edumal Startup, iOS (Swift iOS8)


    Edumal

    • Landing Page - "Together we enrich the lives of dogs and dog owners around the world" 


    Purchases

    Friday, 23 May 2014

    iOS Unit Testing

    Challenges
    • Error 'Parse/Parse.h' file not found (Unit Testing in iOS)
      • Background: I added the following Unit Testing lines of code in appropriate sections of my RibbitTests.m file in Xcode 5 to import the view controller header file that I wanted to test.
    #import "ImageViewController.h"
    @property (nonatomic) ImageViewController *imageViewController;
    #pragma mark - App Test Cases
    - (void) testImageViewController{   XCTAssertNotNil(self.imageViewController, @"imageViewController model was not nil");}
      • Problem: Received error message 'Parse/Parse.h' file not found 
      • Solution: 
        • Deleted Parse.framework in Xcode 5 (use Apple Finder to check that there is no Parse.framework folder still in your project directory) 
        • Re-downloaded the Parse.com iOS SDK
        • Dragged the downloaded Parse.framework folder into the Frameworks directory within Xcode 5, and ensure that you tick the following boxes (noting that the initial error message you received may have been caused because when you initially installed Parse.com's SDK, you may not have also added a tick next to RibbitTests)
        • Dragged the downloaded Parse.framework folder into the Frameworks directory within Xcode 5, and ensure that you tick the following boxes (noting that the initial error message you received may have been caused because when you initially installed Parse.com's SDK, you may not have also added a tick next to RibbitTests)
    Activities @ TeamTreeHouse - 

    Unit Testing for iOS (using Xcode 5 IDE) with Amit Bijlani

    DONE (using Ribbit iPhone App)
    • Unit Testing { 
      • Runtime errors (insufficient type testing)
      • Logic errors (insufficient scenarios)
      • Regressions (team scenario bugs)
      • XCTest.framework { write tests that a subclasses of XCTestCase }
      • XCT Assertion types
      • Running Unit Tests
        • CMD + U { Product > Tests }
        • Re-Testing { Product > Perform Action > Test Again }
        • Method Testing { Press 'Play' Button in gutter to the left of the method }
      • Navigating Unit Tests
        • Test Navigator (in the Project Navigator)
          • Running Specific Tests { Press 'Play' Button shown on right of: }
            • Test Suite
            • Test Cases
            • Test Methods
      • Creating Tests { Press + Button in bottom left corner of Test Navigator }
        • Test Classes
        • Test Targets
      • Matching Test Case Methods with corresponding Code Methods { Assistant Editor > Click Breadcrumb Navigation bar (at top right), then scroll down and Click either:
        • Test Classes
        • Test Callers { identifies other methods that call the method, including Unit Testing methods }
      • Continuous Integration 
      • Shortcuts 
        • CMD + U  { Runs Unit Test }
        • CMD + Click { Press this combination when hovering a method to toggle between the methods location in the header and implementation files } 

    Monday, 12 May 2014

    Post WDI - iOS Dev App (User Accounts, BaaS, Mobile Design, Parse.com Framework API, Asynchronous, Helper Methods, Git Ignore, RubyMotion)

    Challenges
    • Debugged extensively trying to solve why checkmarks were appearing on currently selected cells in the table view only after clicking another different cell in the table view 
      • Solution: Incorrect method chosen when creating instance method with autocomplete, should have used didSelectRowAtIndexPath (NOT 
        didDeselectRowAtIndexPath)
    Activities @ TeamTreeHouse - 

    iOS Development (using Xcode 5 IDE) with Ben Jakuben

    DONE Ribbit iPhone App
    • Xcode 5 Tabs for Open Files { Xcode5  > Preferences > Navigation > Double Click > Use Separate Tab }
    • View Controller Lifecycle 
      • Start App (First Time)
        1. view not exist
        2. call viewDidLoad (only called if no view controller exists in memory)
        3. call viewWillAppear 
        4. call viewDidAppear
        5. view controller appears on screen in ready state (user can view and interact)
      • Navigating Away from current ViewController
        1. call viewWillDisappear
        2. call viewDidDisappear
        3. view controller remains in memory for future use as long as memory avail
      • Start App (After First Time)
        1. skips viewDidLoad (as it already exists)
        2. call viewWillAppear
        3. call viewDidAppear
      • Typical Usage
        • viewDidLoad { use for code that only needs to run once when view first loaded (i.e. creating, loading data, config display) }
        • viewWillAppear { use to display something every time view controller displays on screen (i.e. refresh data, animation) }
    • Stack (of View Controllers) (Nav Controller maintains VC's pushed onto or pulled off the array stack above Root VC)
      • pushViewController
      • popViewController
    • Import Types (used in Header file)
      • " "   means search current project for header file
      • < >  means search certain present system paths (i.e. frameworks)
    • UITabBarController (switches between different tab areas of app) & UITabBarItem
      • selectedIndex property
      • setSelectedIndex
      • badgeValue property
    • UIAlertView { [alertView show] }
    • UITableViewCellAccessoryCheckmark (or None)
      • accessoryType 
      • Prevent Scrolling Cell Reuse { explicitly set each cell only when user corresponding to current table view row is in an array to prevent reuse of cells and incorrectly mirrored checkmarks being displayed }
    • UIImagePickerController (capturing photos and videos with either Default (presented modally) or Customer implementation type )
      • Protocols { Custom View Controller created in conformance with UIImagePickerController delegate, which in turn conforms to UINavigationController delegate protocol, so when user cancels or captures images or video the system notifies the cameras delegate of the users choice }
      • presentViewController used to display the the camera view modally
      • imagePickerControllerDidCancel { delegate method of UIImagePickerController where Custom Class that we've named 'CameraViewController' is the delegate }
      • didFinishPickingMediaWithInfo { stores image info in NSDictionary with a key }
      • UIImagePickerControllerMediaType { key method constant passed in and used to retrieve different media types stored as constants as part of Mobile Core Services Framework }
        • #import <MobileCoreServices/UTCoreTypes.h> (constant values of media types obtained)
        • kUTTypeImage { image media type from Core Foundation (CF) that needs to be converted to Next Step (NS) String counterpart type of data structure using Cast (NSString *). use @properties to store images retrieved for use throughout view controller and to set it to be stored in NSDictionary key }
      • UIImagePickerControllerMediaURL { key path method constant passed in and used to retrieve local iOS internal path as a string and stored in @property defined in header (videos not stored in NSDictionary like images are) }
      • Simulator Testing with Photo Album (the iPhone camera is not available unless testing using the device so to test within the simulator using the photo album instead perform the following actions in Xcode Simulator)
        • Hardware > Home, Open Safari in Simulator, Drag a photo to Safari browser, Click the 'Share' button, Click 'Save to Camera Roll'
      • Help Menu Keywords { camera programming topics for iOS }
    • Video Player 
      • Options on iPhone
        • Default Video Player (MPMoviePlayerController)
        • Embedded Video Player
      • #import <MediaPlayer/MediaPlayer.h>
      • Media Player Framework (MediaPlayer.framework)
        • Project > Build Phases > Link Binary Libraries
    • NSTimer 
      • scheduleTimerWithTimeInterval
    • Testing 
      • respondsToSelector (check if method exists before calling it in code block)
    • Modal Control Dfn { UI of VC requiring user input before proceed with app }
      • Modal View Controller { layer over current VC, child of current VC (i.e. UIAlertView) } 
    • NavigationController (NavC) (help navigate different sections of app screen flow)
      • Set NavC for the TableVC and TabBarC { pairs NavCs with TabBarController and used to control the Manual Segues with VC, Click VC, Menu > Embed In > Navigation Controller  }
        • popToRootViewControllerAnimated
        • Remove Default Back Button Setup by NavC { self.navigationItem.hidesBackButton = YES; }
        • Remove Tab Bar  { Add method to prepareForSegue setHideBottomBarWhenPushed before VC pushed onto the stack of the workflow 
    • Segue (With)
      • VC onto NavC { CTRL+click, Drag to ViewController(VC), select Action Segue }
      • Button to VC { CTRL+click button, Drag to VC, select Action Segue }
    • Segue (Without)
      • VC onto TableVC { access VC without Segue attached to Action, CTRL+click 'yellow icon' below VC, Drag to VC, select Manual Segue }
    • Segue (Identifier)
      • Click Segue between VC, Add "Identifier" to pass Data between VCs
      • Create method to perform segue to second view controller { -(void)___ { [self perfomSegueWithIdentifier:@"<insert identifier>" sender:self]; }
    • Linking the Prototype Cell of VC in Storyboard with Class Method (Attributes Inspector > Identifier > "Cell", to match CellIdentifier in code) 
    • @property Storage { Data Source 'Weak' for Text Fields on Sign Up and Sign In forms as dependent on life of View Controller itself }
    • IBOutlet { used for Text Fields for user input, dragged to @interface using Assistant Editor View }
    • IBAction { used for Button to submit, dragged to @interface }
    • Refactoring Code { Select code for refactoring (encapsulating into separate method to comply with DRY principle) into a new Helper method and then go to Edit > Refactor > Extract > <enter name for method> 
    • Stub { i.e. - (void)___ { } }
    • API  { Application Programming Interface to interact with sub systems and third party systems i.e. UIKit and Foundation frameworks }
    • Black Box { System designed with Interfaces (i.e. sets of methods and properties defined in publicly viewable header file) clearly defined between components }
    • Web Interface { between Front-End Black Box and Back-End (i.e. Parse.com Back-end-as-a-Service (BaaS) dynamically creates what is needed in Back-End) }
    • Parse.com Framework SDK Setup { extra Frameworks required as Dependencies by Parse Framework installed per Parse.com instructions via Project > Target (Ribbit) > Build Phases (tab) > Click “Link Binary with Libraries” }
    • Parse.com API Calls { iOS Guide, iOS API } 
      • objectWithClassName (PFObject) (creates Parse.com database table object) saveInBackground (save data to Parse.com back-end)
      • signUpInBackgroundWithBlock (PFUser) (asynchronous multi threaded approach using Block construct set up as callback mechanism with Parse.com response, receipt and processing in block with success and error handling)
      • currentUser (PFUser) (returned value is automatically Cached on device and user session logged in)
      • logOut (PFUser)
      • loginHandler block (PFUser)
      • loginWithUsernameInBackground (PFUser)
      • findObjectsInBackgroundWithBlock (PFQuery) (block that returns array of PFObjects)
      • relationForKey (PFRelation)
      • saveInBackgroundWithBlock 
      • reloadData (method to refresh the Table View data)
      • addObject
      • saveInBackground
    • Parse.com Classes { 
      • PFObject (iOS Guide > Users)
      • PFUser
      • PFRelation  (ensures Parse.com not dealing with too much Data at once. Relations are stored in Parse.com Table Object under column (property of Class) with designated Key. PFRelation has a PFQuery property to use to retrieve data linked by relation)
      • PFQuery (retrieving and viewing data 
      • PFFile (uploading files and associate them with a message PFObject that will be )
    • Uploading Files to Parse.com
      • PFFile to upload file itself
      • PFObject uploaded separately as message Object (created dynamically at Parse.com) associated with PFFile
        • Message Object 
          • Message Contents
          • Sender
          • Recipient
        • Schemaless means not req'd to specify keys existing on each PFObject, just set KV pair and back-end stores them
      • Chaining Asynchronous Calls { upload file itself and then other details if initial asynchronous call succeeded improves UX by not delaying user }
    • Deleting Files on Parse.com
      • Options
        • RESTful API's 
        • Clean Up Files (Dashboard > Settings > Clean Up Files) { deletes all files that we have uploaded that are no longer referenced by any other objects in back-end }
    • Asynchronous Indeterminant Nature (amount of Time) of calls as data not always returned in order expected. Multiple Callback Blocks must be managed. Avoid where possible by implementing DRY principle and sharing data between methods of VC's with prepareForSegue method
    • Block { ^ (<parameters defined inside parenthesise>) { curly braces with code } }
    • Helper Methods (i.e. looping mechanism to check for friends against current user)
      • Alternative is Hash or Cache for efficiency with high volume of users 
    • Shortcuts 
      • Hidden Files (show hidden files with CMD + Shift + . }
      • Indentation CMD + ]  or CMD + [
    • Git Ignore { store API keys in .plist file using this guide https://teamtreehouse.com/forum/hiding-api-credentials-in-github-for-xcode-5-projects }
    • Mobile Design

    Events:
    • ATTENDED SydInMotion - Ruby & iOS development (awesome! early stage community)
      • @fluffyjack (inspiring presentation, RubyInMotion time after exams finish mid June '14)

    Curiosity:

    Purchases:
    • RubyMotion a personal leap of faith inspired by SydInMotion! Now I just need to buy some coding friends...

    Links: