Xcode4.6创建和使用iOS的dylib动态库
2013-12-04 16:34
393 查看
转载请注明出处:http://blog.csdn.net/hursing
此为xcode4的方法,xcode3的方法请查看 Xcode3创建和使用iOS的dylib动态库
找到两个目录,最好用两个finder窗口分别打开:
目录一:
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/
目录二:
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/
(这里只说iOS真机版,模拟器版类似,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform)
把目录一下的iPhoneOSPackageTypes.xcspec和iPhoneOSProductTypes.xcspec拷贝到桌面(或者其它有写权限的地方),分别用xcode打开。
再用xcode打开目录二下的MacOSX Package Types.xcspec和MacOSX Product Types.xcspec
把MacOSX Package Types.xcspec中Identifier为com.apple.package-type.mach-o-dylib的item拖到iPhoneOSPackageTypes.xcspec,令iPhoneOSPackageTypes.xcspec变成:
把MacOSX Product Types.xcspec中Identifier为com.apple.product-type.library.dynamic的item拖到iPhoneOSProductTypes.xcspec,令iPhoneOSProductTypes.xcspec变成:
保存修改,把iPhoneOSPackageTypes.xcspec和iPhoneOSProductTypes.xcspec拷贝回去目录一,此时会因为没有写权限而提示需要鉴定,输入密码即可。
创建工程模板:
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/Cocoa Touch Static Library.xctemplate
把以上整个文件夹复制到桌面,文件夹改名为Cocoa Touch Dynamic Library.xctemplate,用xcode打开里面的TemplateInfo.plist,修改三个地方:
保存,然后把Cocoa Touch Dynamic Library.xctemplate拷贝回去
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/
这时又需要鉴定。
重启xcode,就能看到:
随便创建一个app工程和一个dylib工程,做好编译依赖以及copy dylib to bundle。(点击查看大图)
动态库的工程要设置安装目录:(点击查看大图)
demo/sample和已经改好的模板 下载地址:http://download.csdn.net/detail/hursing/5416617
安装好app后,运行。然后修改UIAlertView的message,编译,用各种工具(我在Mac上用的是iPhone Explorer)把新的dylib覆盖旧的,重启程序,message成功改变! 验证ok。
以上是直接链接静态库的方法,也可以用dyld函数动态加载。要把dylib放在Document文件夹内的话,修改安装目录即可,第一次启动要自己copy出去哦。
此为xcode4的方法,xcode3的方法请查看 Xcode3创建和使用iOS的dylib动态库
找到两个目录,最好用两个finder窗口分别打开:
目录一:
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/
目录二:
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/
(这里只说iOS真机版,模拟器版类似,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform)
把目录一下的iPhoneOSPackageTypes.xcspec和iPhoneOSProductTypes.xcspec拷贝到桌面(或者其它有写权限的地方),分别用xcode打开。
再用xcode打开目录二下的MacOSX Package Types.xcspec和MacOSX Product Types.xcspec
把MacOSX Package Types.xcspec中Identifier为com.apple.package-type.mach-o-dylib的item拖到iPhoneOSPackageTypes.xcspec,令iPhoneOSPackageTypes.xcspec变成:
把MacOSX Product Types.xcspec中Identifier为com.apple.product-type.library.dynamic的item拖到iPhoneOSProductTypes.xcspec,令iPhoneOSProductTypes.xcspec变成:
保存修改,把iPhoneOSPackageTypes.xcspec和iPhoneOSProductTypes.xcspec拷贝回去目录一,此时会因为没有写权限而提示需要鉴定,输入密码即可。
创建工程模板:
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/Cocoa Touch Static Library.xctemplate
把以上整个文件夹复制到桌面,文件夹改名为Cocoa Touch Dynamic Library.xctemplate,用xcode打开里面的TemplateInfo.plist,修改三个地方:
保存,然后把Cocoa Touch Dynamic Library.xctemplate拷贝回去
[plain]
view plaincopy
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/
这时又需要鉴定。
重启xcode,就能看到:
随便创建一个app工程和一个dylib工程,做好编译依赖以及copy dylib to bundle。(点击查看大图)
动态库的工程要设置安装目录:(点击查看大图)
demo/sample和已经改好的模板 下载地址:http://download.csdn.net/detail/hursing/5416617
安装好app后,运行。然后修改UIAlertView的message,编译,用各种工具(我在Mac上用的是iPhone Explorer)把新的dylib覆盖旧的,重启程序,message成功改变! 验证ok。
以上是直接链接静态库的方法,也可以用dyld函数动态加载。要把dylib放在Document文件夹内的话,修改安装目录即可,第一次启动要自己copy出去哦。
相关文章推荐
- 使用CocoaPods来做iOS程序的包依赖管理
- IOS RGB颜色转换
- iOS程序初始化
- ios Lable 自动换行
- ios NSString 去除空格和回车
- ios中tableviewcell允许长按出现剪切板
- IOS开发笔记_4自定义TabBar
- iOS导航控制器
- ios的frame,bound和center的原理和区别
- iOS 图片压缩以及保存到doucument的方法
- IOS下遇到的singal SIGPIPE的错误
- ios4 NAND layout
- iOS官网问答:Detecting the Debugger(判断是否处于联机调试)
- x86 BIOS 中断 INT 10h
- 在iOS设备(iPhone/iPad)中调用摄像头进行全屏拍摄时的处理方案
- iOS小技巧:根据SDK版本区分代码
- IOS7 开发注意事项
- 在IOS项目中使用常量
- IOS工程中Info.plist文件详解
- IOS设计模式浅析之单例模式(Singleton)