iOS App 开发问题汇总(三)

1.Checking the Entitlements for an iOS app Submission to the App Store

Making an Inspectable .ipa file
In the Xcode Organizer, instead of Submit to the iOS App Store, do Save for Enterprise or Ad-Hoc Deployment. This will create a local copy of the .ipa file that would be submitted to the App Store.
When asked to choose the provisioning profile to sign with, select the same distribution profile you use when submitting to the App Store. Take a screenshot of your choice (command-shift-3) so you can verify this step later. During submission, this screenshot will be the only record you have identifying which profile was used to sign the app.
When asked to save the package, uncheck Save for Enterprise Distribution, then save the .ipa file.
Checking the Entitlements of an .ipa file
Find the .ipa file and change its the extension to .zip.
Expand the .zip file. This will produce a Payload folder containing your .app bundle.
Use the codesign tool to check the entitlements on the .app bundle like this: $ codesign -d –entitlements :- “Payload/YourApp.app” where YourApp.app is the actual name of your .app bundle.
Use the security tool to check the entitlements of the app’s embedded provisioning profile: // should add cms, Apple may be a typo $ security cms -D -i “Payload/YourApp.app/embedded.mobileprovision”

where YourApp.app is the actual name of your .app bundle.

继续阅读

如何在 Mac 上开启 Apache, PHP, MySQL

Apache

开启 Apache

  1. Applications > Utilities > Terminal > sudo apachectl start
  2. Open http://localhost with safari you can see “It’s works!”.

开启为系统的守护进程

1
$ launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

配置 HTTPS 的详细步骤:

  1. 在配置文件中使能HTTPS/SSL:/private/etc/apache2/httpd.conf

    • 去掉 SSL 模块前的注释使能它:
      LoadModule ssl_module libexec/apache2/mod_ssl.so
    • 去掉包含 SSL 配置文件前的注释,以便顶层配置文件能包含它:
      Include /private/etc/apache2/extra/httpd-ssl.conf
  2. 定制/private/apache2/extra/httpd-ssl.conf

    • 更新 DocumentRoot 指向你的 Web 根目录:
      DocumentRoot "/Users/dongmeiliang/Sites"

    • 修改 ServerName 成类似这样:
      ServerName localhost:443

    • 指定 SSLCertificateFile
      SSLCertificateFile "/private/etc/apache2/ssl/ssl.crt"

    • 指定 SSLCertificateKeyFile
      SSLCertificateKeyFile "/private/etc/apache2/ssl/ssl.key"

    • 在 SSLCACertificatePath 和 SSLCARevocationPath 配置项前加上 # ,注释掉它们。
继续阅读

Enumerated Constants

Objective-C中的枚举常量大致有以下四种情形:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 1. unnamed enumerations
enum {
    NSBorderlessWindowMask      = 0,
    NSTitledWindowMask          = 1 << 0,
    NSClosableWindowMask        = 1 << 1,
    NSMiniaturizableWindowMask  = 1 << 2,
    NSResizableWindowMask       = 1 << 3
 
};

`- (void)setStyleMask:(NSUInteger)styleMask`

// 2 
typedef enum _NSMatrixMode {
    NSRadioModeMatrix           = 0,
    NSHighlightModeMatrix       = 1,
    NSListModeMatrix            = 2,
    NSTrackModeMatrix           = 3
} NSMatrixMode;

// 3
typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
    UITableViewCellStyleDefault,
    UITableViewCellStyleValue1,
    UITableViewCellStyleValue2,
    UITableViewCellStyleSubtitle
};

// 4
typedef NS_OPTIONS(NSUInteger, NSLayoutFormatOptions) {
    NSLayoutFormatAlignAllLeft = (1 << NSLayoutAttributeLeft),
    NSLayoutFormatAlignAllRight = (1 << NSLayoutAttributeRight),
    NSLayoutFormatAlignAllTop = (1 << NSLayoutAttributeTop),
    NSLayoutFormatAlignAllBottom = (1 << NSLayoutAttributeBottom),
    NSLayoutFormatAlignAllLeading = (1 << NSLayoutAttributeLeading),
    NSLayoutFormatAlignAllTrailing = (1 << NSLayoutAttributeTrailing),
    NSLayoutFormatAlignAllCenterX = (1 << NSLayoutAttributeCenterX),
    NSLayoutFormatAlignAllCenterY = (1 << NSLayoutAttributeCenterY),
    NSLayoutFormatAlignAllBaseline = (1 << NSLayoutAttributeBaseline),
    NSLayoutFormatAlignAllLastBaseline = NSLayoutFormatAlignAllBaseline,
    NSLayoutFormatAlignAllFirstBaseline NS_ENUM_AVAILABLE_IOS(8_0) = (1 << NSLayoutAttributeFirstBaseline),
    
    NSLayoutFormatAlignmentMask = 0xFFFF,
    
    /* choose only one of these three
     */
    NSLayoutFormatDirectionLeadingToTrailing = 0 << 16, // default
    NSLayoutFormatDirectionLeftToRight = 1 << 16,
    NSLayoutFormatDirectionRightToLeft = 2 << 16,  
    
    NSLayoutFormatDirectionMask = 0x3 << 16,  
};

情形一相当于定义了常量,但不定义类型;
情形二定义了一个NSMatrixMode类型;

情形三定义了一个NSInteger的UITableViewCellStyle类型;
情形四支持C++的枚举特性。

The NS_OPTIONS macro is defined in different ways if compiling as C++ or not. If it’s not C++, it’s expanded out the same as NS_ENUM. However, if it is C++, it’s expanded out slightly differently. Why? The C++ compiler acts differently when two enumeration values are bitwise OR’ed together. This is something, as shown earlier, that is commonly done with the options type of enumeration. When two values are OR’ed together, C++ considers the resulting value to be of the type the enumeration represents: NSUInteger. It also doesn’t allow the implicit cast to the enumeration type.

Reference:
Effective Objective-C 2.0
NS_ENUM & NS_OPTIONS