您的位置:首页 > 其它

Xcode - 1

2015-06-17 09:07 896 查看
Xcode快捷键,一些盲区

总体的操作:http://www.cocoachina.com/ios/20141225/10761.html (参考)

前面提到的arm:

1.arm.
http://www.cocoachina.com/industry/20140527/8566.html (转自)

wiki:https://en.wikipedia.org/wiki/ARM_architecture 估计也没时间看

Advanced RISC Machine:进阶精准指令集

armv6:

iPhone

iPhone2

iPhone3G

第一代和第二代iPod Touch

armv7:

iPhone4

iPhone4S

armv7s:

iPhone5

iPhone5C

arm64:

iPhone5S

机器对指令集的支持是向下兼容的,因此armv7的指令集是可以运行在iphone5S的,但是效率会低一点。

Architectures:该编译选项指定了工程将被编译成支持哪些指令集,支持指令集是通过编译生成对应的二进制数据包实现的,如果支持的指令集数目有多个,就会编译出包含多个指令集代码的数据包,造成最终编译的包很大!

Valid Architectures:该编译项指定可能支持的指令集,该列表和Architectures列表的交集,将是Xcode最终生成二进制包所支持的指令集。

比如,你的Valid Architectures设置的支持arm指令集版本有:armv7/armv7s/arm64,对应的Architectures设置的支持arm指令集版本有:armv7s,这时Xcode只会生成一个armv7s指令集的二进制包。

Build Active Architecture Only:该编译项用于设置是否只编译当前使用的设备对应的arm指令集。

当该选项设置成YES时,你连上一个armv7指令集的设备,就算你的Valid Architectures和Architectures都设置成armv7/armv7s/arm64,还是依然只会生成一个armv7指令集的二进制包。当然该选项起作用的前提是你的Xcode必须成功连接了调试设备。

如果你没有任何活跃设备,即Xcode没有成功连接调试设备,就算该设置项设置成YES依然还会编译Valid Architectures和Architectures指定的二进制包。

通常情况下,该编译选项在Debug模式都设成YES,Release模式都设成NO。

顺便说说Debug和Release模式:
http://my.oschina.net/leejan97/blog/296920
2.project.pbxproj

对着任意的工程文件ArbitraryProjectDemo.xcodeproj 右键后,显示Show Package Contents



将发现有3个文件:



点击最上面的一个文件,会发现大量很陌生的东西,摘取一段如下:

// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		CCB171DD1B27E16400C6BE34 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CCB171DC1B27E16400C6BE34 /* main.m */; };
		CCB171E01B27E16400C6BE34 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CCB171DF1B27E16400C6BE34 /* AppDelegate.m */; };
		CCB171E31B27E16400C6BE34 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CCB171E21B27E16400C6BE34 /* ViewController.m */; };
		CCB171E61B27E16400C6BE34 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CCB171E41B27E16400C6BE34 /* Main.storyboard */; };
		CCB171E81B27E16400C6BE34 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CCB171E71B27E16400C6BE34 /* Images.xcassets */; };
		CCB171EB1B27E16400C6BE34 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = CCB171E91B27E16400C6BE34 /* LaunchScreen.xib */; };
		CCB171F71B27E16400C6BE34 /* xSDK_CP_DemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCB171F61B27E16400C6BE34 /* xSDK_CP_DemoTests.m */; };
		CCB1720D1B27E54B00C6BE34 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CCB1720C1B27E54B00C6BE34 /* libsqlite3.dylib */; };
		CCB1720F1B27E55700C6BE34 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCB1720E1B27E55700C6BE34 /* AdSupport.framework */; };
		CCB172111B27E56100C6BE34 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCB172101B27E56100C6BE34 /* SystemConfiguration.framework */; };
		CCB172131B27E56E00C6BE34 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCB172121B27E56E00C6BE34 /* CoreTelephony.framework */; };
		DA0CEC361B281168006EF074 /* AlipaySDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DA0CEC2F1B281168006EF074 /* AlipaySDK.bundle */; };
		DA0CEC371B281168006EF074 /* GTMBase64.m in Sources */ = {isa = PBXBuildFile; fileRef = DA0CEC311B281168006EF074 /* GTMBase64.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
		DA0CEC381B281168006EF074 /* libXSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DA0CEC331B281168006EF074 /* libXSDK.a */; };
		DA0CEC391B281168006EF074 /* XSDKResource.bundle in Resources */ = {isa = PBXBuildFile; fileRef = DA0CEC351B281168006EF074 /* XSDKResource.bundle */; };
/* End PBXBuildFile section */


由上面的信息就可以看到些常见的配置信息:Info.plist的位置在xSDK_CP_Demo目录下,iPhoneOS的部署环境:IPHONEOS_DEPLOYMENT_TARGET,library_search_paths,other_link_flags等等重要信息。详情看:http://www.tuicool.com/articles/yER7ziu参考和扩展:http://www.olinone.com/?p=1983.Header Search Paths: Library Search Paths:打开Xcode至TARGETS-Build
Settings-Search Paths,我们发现如下图所示:明眼一看就知道是环境路径的设置,找到stackoverflow一篇很好的解释,翻译出来:http://stackoverflow.com/questions/8342982/ios-clarify-different-search-paths

Framework search path<: where to search frameworks (.framework bundles) in addition to system frameworks paths. Not used very much in iOS development, officially there is no developer iOS frameworks.



In Mac development, it's set automatically if you drag a 3rd party framework into the project. Otherwise, just set it to the container directory where you saved the framework.



In xcconfig files you use this variable:



FRAMEWORK_SEARCH_PATHS = "/path/to/frameworks/container/directory"

Framework search path:这个搜索frameworks(.framework包)来添加系统的frameworks路径,在Mac开发不经常使用,官方的来说是没有iOSframeworks的。

在Mac开发中,将会自动设置当你拉三方framework进工程,否则,仅仅设置:FRAMEWOEK_SEARCH_PATHS = "/path/to/frameworks/container/directory"

<span style="color:#339999;">Header search path</span>: where to search for header files (.h files) in addition to system paths. Usually you'll need it if you are using a 3rd party library. Set it to the directory where you have the header files. If you use a directory to include the header (example: #import "mylibrary/component.h") set it to the parent directory.

In xcconfig files you use this variable:

HEADER_SEARCH_PATHS = "/path/to/headers/container/directory"


Header search path:搜索头文件来添加系统路径。通常来说你将需要用来设置第三方库。将它设置成你所需要的头文件目录。如果你设置这个目录来包括头文件:

HADER_SEARCH_PATHS = "/path/to/headers/container/directory"

<span style="color:#339999;">Library search path</span>: where to search for library files in addition to system paths. Xcode will set it automatically if you drag a library (.a files) into the project. To set it manually, use the directory where the library is located.

In xcconfig files you use this variable:

LIBRARY_SEARCH_PATHS = "/path/to/libraries/container/directory"


Library search path:搜索库文件来添加系统路径。Xcode将会自动添加如果你拉了库文件进去工程。

LIBRARY_SEARCH_PATHS = "/path/to/libraries/container/directory"

$(BUILT_PRODUCTS_DIR)

build成功后的,最终产品路径--即build/Debug-iphoneos路径下

$(TARGET_NAME)

目标工程名称

$(SRCROOT)

工程文件(比如Nuno.xcodeproj)的路径

$(CURRENT_PROJECT_VERSION)

当前工程版本号

用法: $(inherited) "$(SRCROOT)/.a文件所在的文件名"

单个工程的路径设置非常简单,如果没有设置到团队的合作甚至可以直接拉路径,使用绝对路径,也可以保证不出错读取路径有效,但是涉及团队合作就要用到相对路径,一般只要理解上面的SRCROOT、PROJECT的意义就可以避免错误,但是当设计到使用framework(可以理解多工程)的时候就要小心,其实也是理解好以上就可以避免出错,一定要知道“相对”是相对于本工程为目标的!

例子:一个DEMO工程(内涵一个framework的引用)

LibTest是工程的外层:



SQGame是工程的“内层”即framework:



注意到它们两个对aisi 和 iiappleSDK的引用的路径。很好理解吧! 相对于自身而言,这个一定要理解好,不好真的浪费时间于没有意义的地方!

3.other linker flags:

参考:http://www.cnblogs.com/robinkey/archive/2013/05/27/3101095.html

(有空再做详述)

4.URL schemes:

参考:http://mobile.51cto.com/iphone-386384.htm

参考:http://blog.sina.com.cn/s/blog_5673c12f0100qd6i.html

看上面两篇大概就能明白原理,我来说说使用:进入到Info.plist文件后,在Information Property List中添加URL types关键字,随后在URL types目录下面的Item 0添加URL Schemes即可:



有一点是和CFBundleURLTypes的关系,将info.plist文件用sublime打开之后:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string></string>
			</array>
			<key>CFBundleURLName</key>
			<string></string>
		</dict>
	</array>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>com.wjc.ily.$(PRODUCT_NAME:rfc1034identifier)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>ios222</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
</dict>
</plist>
打开之后对应着一个xml文件,结果就非常明显了,URL types对应着一个key字段 - Core Foundation框架下的CF变量:CFBundleURLTypes

URL schemes 对应着另一个key字段 - CFBundleURLSchemes

而在程序中,你完全可以直接取出plist信息的值:

NSDictionary *bundleDic = [[NSBundle mainBundle] infoDictionary];
NSString *version = [bundleDic objectForKey:@"CFBundleVersion"];


CFBundleDevelopmentRegion,

DTPlatformName,

CFBundleVersion,

LSRequiresIPhoneOS,

CFBundleSignature,

CFBundleIdentifier,

CFBundleExecutable,

CFBundleDisplayName,

CFBundleShortVersionString,

CFBundleName,

CFBundleSupportedPlatforms,

CFBundlePackageType,

NSBundleResolvedPath,

CFBundleInfoDictionaryVersion,

UIRequiredDeviceCapabilities,

UISupportedInterfaceOrientations,

NSBundleInitialPath,

CFBundleInfoPlistURL,

CFBundleExecutablePath,

DTSDKName,

UIDeviceFamily
这些可以直接右键plist的XML形式直接查看
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: