制作可启动的Mavericks安装盘

制作可启动的Mavericks安装盘

验证原盘是否可靠

打开终端,执行以下命令:

# sha1 = 2d73cea41072c028105332a6e7c1027161fa07fe
openssl sha1 "Software/Install OS X Mavericks.app/Contents/SharedSupport/InstallESD.dmg"

制作可启动的Mavericks安装盘

打开终端,执行以下命令:

#
# ~/Software是我放置Install OS X Mavericks.app的位置
# /Volumes/OS 是安装盘分区的名字
cd ~/Software
sudo ./"Install OS X Mavericks.app/Contents/Resources/createinstallmedia" --volume /Volumes/OS --applicationpath "Install OS X Mavericks.app" --nointeraction

回车就开始制作安装盘,整个过程大概需要20多分钟。

CodeIgniter 和 Twig 整合

为啥还要用 Twig

PHP可以嵌入HTML,可以说本身就是模版语言,为啥还要用Twig这样的模版引擎?

首先,PHP可以嵌入HTML,但它首先是一种编程语言,这就意味着他对语法的要求很严格。比如,你在View中少写个分号会导致整个页面的崩溃,使用了模版引擎则不会。

安全性。如果允许用户自定义模版,那你就必须使用模版引擎,否则用户在模版中注入了攻击的PHP代码,呵呵,兄弟,你就等着哭吧。

跨语言。Twig和Jinja还有Django的模版规则几乎相同,Python开发者自然不会拒绝为你的系统开发模版。

模版功能更强大。可以自定义标签、过滤器、函数,支持Base语法。

IDE的支持。PHP的标签会影响HTML在IDE中的高亮显示,而Twig则不会。Vim和Textmate有Twig插件支持你快速的编写模版。

Twig 和 Codeigniter 整合

Codeigniter是一个PHP Framework,我一直使用他,没用过的请返回吧。下边的内容对你没有帮助。

Twig 和 Codeigniter 整合非常简单,仅仅两步即可完成

第一步,引入Twig库

下载Twig,解压Twig,将Twig源代码中的lib/Twig目录复制到CI的Application/third_party中,复制后的结果如下图
安装Twig

第二步,为Codeigniter创建Twig类

在Codeigniter的library目录中增加一个Twig.php文件,将如下代码粘贴进去

注意把APPPATH/cache目录设置为可写,twig会把编译后的模版放到这个目录中

:::PHP
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
 * Created on 2013-10-25 by haojue
 * Twig CI Library
 *
 */
require_once APPPATH . 'third_party/Twig/Autoloader.php';

class Twig {

    private $loader ;
    private $twig;
    private $_ci;

    function __construct() {
    Twig_Autoloader::register();
        $this->loader = new Twig_Loader_Filesystem(APPPATH.'views');
        $this->twig = new Twig_Environment($this->loader, array(
            'cache' => APPPATH.'cache',
      'auto_reload' => true
        ));
    }

    public function render($tpl,$data,$return = FALSE) {
        $output = $this->twig->render($tpl,$data);
        $this->_ci =& get_instance();
        $this->_ci->output->append_output($output);
        if ($return) {
            return  $output;
        }
    }
  /**
   * __call
   * @param string $method
   * @param array $args
   * @throws Exception
  */
    public function __call($method,$args) {
        $return = call_user_func_array(array($this->twig,$method),$args);
        if ($return) {
            return $return;
        }
    }

}

在Codeigniter中使用Twig模版

:::PHP
class Test extends CI_Controller {

    public function index()
    {
        $this->load->library('twig');
        $this->twig->render('twig_template.html'); //模版文件放置在view目录中
    }
}

为Twig添加函数

以下代码新建了一个CI的Helper,加载helper后,可以使用{{ base_url('something') }}获得base_url

:::PHP
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

 if ( ! function_exists('twig_extend'))
 {
   function twig_extend()
   {
     $CI = & get_instance();
     if ( ! $CI->twig instanceof Twig) {
       log_message('error', "Twig library not initialized");
       return;
   }
   $CI->load->helper('url');
   $base_url = new Twig_SimpleFunction('base_url', 'base_url');

   // Now you’ll be able to use {% raw %}{{ base_url('something') }}{% endraw %} in your
   // template files, after you call this twig_extend() helper function
   // in your controllers.
   $CI->twig->addFunction($base_url);
  }
}

APP上线前测试确认清单

App Development Company Limited

RELEASE AUTHORISATION FORM v1.0

App name insert content
Version insert content
Date of submission insert content

This form is to document the testing that has been done on each app
version before submitting to the App Store. For each item, indicate Yes
if the testing has been done, Not Applicable if the testing does not
apply (eg testing audio for an app that doesn’t play any), or No if the
testing has not been done for another reason.

###Internet Connectivity
Test all the data downloading sections of the app by trying them on the appropriate connection type. Consider graceful degradation and failure as well as success conditions.

Connection N/A NO YES
Wifi
Edge
GPRS
No Network
Break in Network - use Charles
Server unreachable - timeout
Resumed connect - streaming only

###Locale
Change device’s settings then load the app. Check that dates appear correctly, especially dates from external feeds or services.

Locale N/A NO YES
12 and 24 hour clocks
Regions: fork and add regions for you
Languages: fork and add languages for you
Timezones
Daylight Savings Time

Devices

Run the application through navigations using different devices with different iOS versions and display formats.

Device N/A NO YES
iPhone / iPod touch running iOS 5.0
iPhone / iPod touch running iOS 5.1.1
iPhone / iPod touch running iOS 6.0
iPhone / iPod touch running iOS 6.1.3
iPhone / iPod touch running iOS 7.0
Retina iPhone display
Non-retina iPhone display
iPad 1 running iOS 5.0
iPad 1 running iOS 5.0
iPhone / iPod touch running iOS 5.1.1
iPad running iOS 6.0
iPad running iOS 6.1.3
iPad running iOS 7.0
Retina iPad display
Non-retina iPad display
iPad mini display

Audio

If app plays audio, perform the following checks. For streaming audio, make sure the checks in the network section above have also been done.

Audio N/A NO YES
Headphones/speaker routing
Dock connector audio out routing
iPod touch audio routing (consider model without speaker)
Mute switch functionality (officially it mutes non-user-requested sounds)
Audio pause on received phone call
Background audio (if supported): playback and multitasking bar controls
Start playing audio when another app is already playing
Headphone remote for audio control
Multitasking screen audio control

###Video
Streaming video should have been checked in the network tests.

Video N/A NO YES
User cancels video before playback begins
User cancels video during playback
Video plays to the end
Video return from full screen
Dock connector video out
Video transition between inline and full screen

###Location

Location N/A NO YES
True GPS
Wifi location
Cell tower location
Unable to find location
No results returned (e.g. too far from any searchable points of interest)
Location services turned off
Location services disabled for this app

###Camera / Video
If app takes pictures or video clips, perform the following checks. For streaming video, make sure the checks in the network section above have also been done.

Camera / Video N/A NO YES
Primary camera photo taken
Primary camera video captured
Secondary (user facing) camera taken
Secondary (user facing) video captured
Video recording paused on received phone call

###Logging

Logging N/A NO YES
Logging events to live server
Logging errors (interact with other tests?)

###User Interface
Test each major view in the app.

Title N/A NO YES
Double height status bar (eg in call)
Orientation change
Upside-down orientation
Orientation lock
VoiceOver turned on
Usable by a new user with Screen Curtain turned on
Works with Accessibility Zoom turned on

###Core Data

Core Data N/A NO YES
Validation error in user input
Validation error in web server input
Test migrations with valid and invalid data files
Rollback

###Installation

Installation N/A NO YES
Fresh install
Upgrade from previous live version
Upgrade from older live version
Rollback

###Text

Title N/A NO YES
Shake to Undo
Text selection (including disabled when appropriate)
Copy / Paste
Editing when keyboard is hidden
Dictionary / Suggested Word hover

###Third Party Services
All third party services should use production API key and the new app version should be registered in the respective dashboards

Title N/A NO YES
Production analytics/tracking API key
New app version tracking data available tracking in dashboard
Production crash reporting API key
Upload dSYM to crash reporting tool
New app version available in crash reporting dashboard
Push notification service API key
New app version added to push service dashboard
Production App ID for social services (Twitter, Facebook, Instagram, etc)

###Misc

Misc N/A NO YES
Bluetooth
Motion
Tested in Ad Hoc mode
Version number upgraded
Bundle identifier correct for release




Sign-off: __





Project role: ___

Google Analytics for iOS

Guide

Developer Doc

Liner error when trying to install new Google Analytics 3.0 beta

Add AdSupport.framework

Initializing the tracker

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Optional: automatically send uncaught exceptions to Google Analytics.
  [GAI sharedInstance].trackUncaughtExceptions = YES;

  // Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
  [GAI sharedInstance].dispatchInterval = 20;

  // Optional: set Logger to VERBOSE for debug information.
  [[[GAI sharedInstance] logger] setLogLevel:kGAILogLevelVerbose];

  // Initialize tracker.
  id<GAITracker> tracker = [[GAI sharedInstance] trackerWithTrackingId:@"UA-XXXX-Y"];

}

Manual Screen Tracking

#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIFields.h"

- (void)viewWillAppear:(BOOL)animated
{
    id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];

    // This screen name value will remain set on the tracker and sent with
    // hits until it is set to a new value or to nil.
    [tracker set:kGAIScreenName value:@"Home Screen"];

    [tracker send:[[GAIDictionaryBuilder createAppView] build]];
}

Event Tracking

id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"UI_ACTION"     // Event category (required)
                                                      action:@"BUTTON_PRESS"  // Event action (required)
                                                       label:@"DOWNLOAD"          // Event label
                                                       value:[NSNumber numberWithInt:_slideID]] build]];    // Event value