开发问题


XCODE 一直显示inexing


SZ12031560:~ test$ defaults write com.apple.dt.XCode IDEIndexDisable 1  跳过index

SZ12031560:~ test$ defaults write com.apple.dt.XCode IDEIndexEable 1    恢复index

How to disable indexing for XCode4 (2012-05-04 16:09:37)

$defaults write com.apple.dt.XCode IDEIndexDisable 1
$defaults delete com.apple.dt.XCode IDEIndexDisable

原因:工程里面已经有一个NSString 的扩展叫做 extension,我又添加了一个相同名字的NSString扩展
函数,,而且这个代码加再聊一个经常被引用的.h里面,最终导致xcode已启动,就停留在
indexing界面,罪过啊罪过。

huangxianjiang 18665862907

无法判断文件是否存在
这个可以判断:
/var/mobile/Applications/29B2E3ED-0B2E-4EDA-81DA-83E7042BF8FB/Documents/musicExport/exportedMusic.mp3


这个不行,但是删除可以,考的
file://var/mobile/Applications/29B2E3ED-0B2E-4EDA-81DA-83E7042BF8FB/Documents/musicExport/exportedMusic.mp3



Controller 的 view的frame去掉status的20像素: 
self.wantsFullScreenLayout = YES; 


NSZombies可以用来检测之前提到的内存过度释放问题…

NSZombies搞定EXC_BAD_ACCESS
作者:terryj   2010-08-12 12:25 星期四 晴
  方法很简单 :  
   When this feature is enabled, a dummy object (a zombie) is kept on the place of every released object, thus allowing to debug objects which were released already. Very easy to enable:  
   1. Double click your executable in the “Executables” in XCode
   2. Open “Arguments” tab
    3. In “Variables to be set in the environment” (that’s the list at the bottom, be careful which one you edit) click the “+” button and for name of the variable enter “NSZombieEnabled” and for value “YES”  
  这样至少知道了是哪个类的哪个方法有问题, 当然, 这个选项在提交发布应用之前还是关掉为好。顺便再次鄙视下xcode的编译器,宽容度太大了



静态库中添加扩展导致无法识别扩展的问题
设置Other Linker Flags:-ObjC
不加的话就会有'unrecognized selector sent to instance的错误





iOS 3D UI---CALayer的transform扩展http://www.cocoachina.com/applenews/devnews/2012/1126/5178.html 
clang: error: no such file or directory: '/Users/test/Library/Developer/Xcode/DerivedData/Wonbox-eqhcuidjadbmlqasummmdkixnxyf/Build/Products/Debug-iphoneos/libtaglib-objc.a'

将第三方工程的体系结构由 arm6 改为 arm7


iPhone UIButton图标与文字间距设置
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 50, 150, 50)];
    [button setTitle:@"HHH" forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:@"narrowend.png"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"panelicon.png"] forState:UIControlStateNormal];   

默认情况下,图片及按钮文字如下:
 
加入如下代码后
 [button setImageEdgeInsets:UIEdgeInsetsMake(0.0, -20, 0.0, 0.0)];

[button setImageEdgeInsets:UIEdgeInsetsMake(<#CGFloat top#向上偏移量>, <#CGFloat left#向左偏移量>, <#CGFloat bottom#向下偏移量>, <#CGFloat right#向右上偏移量>)];
同时还可以设置文字的偏移量:
[button setTitleEdgeInsets:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)]; 
定位服务判断:
    if ([CLLocationManagerlocationServicesEnabled] &&
        [CLLocationManagerauthorizationStatus] == kCLAuthorizationStatusAuthorized ){
        
        newstate = YES;
    }



取消之前的函数:如果函数待参数的话没参数也必须一致才能取消掉
    [NSObject  cancelPreviousPerformRequestsWithTarget:selfselector:@selector(buttonIsLongPress:) object:[NSNumbernumberWithBool:YES]];



获取当前类的名字
[NSStringstringWithUTF8String:object_getClassName(self)];

字符窜直接生成类
UIViewController *controller = [[NSClassFromString([classes objectAtIndex:indexPath.row]) alloc] init];
[self.navigationControllerpushViewController:controller animated:YES];
[controller release];



关于屏幕旋转的一些资料
http://blog.csdn.net/totogogo/article/details/8002173

http://stackoverflow.com/questions/12504464/ios-6-uitabbarcontroller-supported-orientation-with-current-uinavigation-control

http://www.cocoachina.com/bbs/simple/?t116091.html

取消自动锁屏幕
12345// Disable the idle timer[[UIApplication sharedApplication] setIdleTimerDisabled: YES]; // Or for those who prefer dot syntax:[UIApplication sharedApplication].idleTimerDisabled = YES;有时候我们的app在播放视频或者音频的时候他自己动锁屏了。这个可以解决掉他锁屏的问题。
不过事实上,这个操作也许对用户来说并不是很友好。
还是需要在锁屏或者进入后台的时候,我们将程序处理好



dyld: lazy symbol binding failed: Symbol not found: dyld: lazy symbol binding failed: Symbol not found: _objc_setProperty_nonatomic_copy
  Referenced from: /var/mobile/Applications/35CAC58A-9ED3-4DE2-B06D-63E1F958C8D4/Wonbox.app/Wonbox
  Expected in: /usr/lib/libobjc.A.dylib


可更改deployment target 使起小于os sdk 。
若工程中添加了其他工程  则也应该更改起deployment target


xode 文件存在确显示为红色
解决方法:把整个xcode关闭,然后再重新开启就ok了


xcode4.5.1修改工程名字:
选择项目,点击view-Uitlity-Show File Inspector (其实就是产品的属性界面),修改上面的Project name


项目中含有svn的目录,当删除一些文件的时候,xcode会提示文件mising的警告错误
解决方法:将svn文件夹删除掉


多语言文件字符窜要以封号结尾,否则没用


解决 Could not instantiate class named NSLayoutConstraint


class xcodeinterface
xcode 升级到了 4.5 之后 只要往xib上面拖放控件 就会报错,
解决方法, 选中当前的 xib文件 ,在属性栏里面进行以下操作:

再右边的 inspector 一栏 将 interface builder document 下的 use autolayout 复选框去掉就可以了




1 问题:|
Libtool build/Debug-iphonesimulator/libmailcore.a normal i386
    cd /Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/MailCore
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool -static -arch_only i386 -syslibroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/MailCore/build/Debug-iphonesimulator -filelist "/Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/MailCore/build/MailCore.build/Debug-iphonesimulator/MailCore iOS.build/Objects-normal/i386/mailcore.LinkFileList" -lsasl2 /Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/MailCore/libetpan/build-mac/build/Debug-iphonesimulator/libetpan_ios.a -o /Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/MailCore/build/Debug-iphonesimulator/libmailcore.a

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool failed with exit code 1



原因:
发现添加的库有几个名字一样,级相同的库添加了多次提示这个错误,去掉后就好了。
mail core的子工程已经添加了ssl2这个库,mailcore又添加了这个库,导致问题,将mailcor中的ssl2这个库去掉就好了。




2 ProcessPCH /Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/PrecompiledHeaders/WSRemailIphoneLib-Prefix-dlkxvuyxvkogizefpyugokkkniiv/WSRemailIphoneLib-Prefix.pch.pth WSRemailIphoneLib/WSRemailIphoneLib-Prefix.pch normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/WSRemailIphoneLib
    setenv LANG en_US.US-ASCII
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -x objective-c-header -arch i386 -fmessage-length=0 -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -std=gnu99 -Wno-trigraphs -fpascal-strings -O0 -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -DDEBUG=1 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -fexceptions -fasm-blocks -mmacosx-version-min=10.6 -gdwarf-2 -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -iquote /Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Intermediates/WSRemailIphoneLib.build/Debug-iphonesimulator/WSRemailIphoneLib.build/WSRemailIphoneLib-generated-files.hmap -I/Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Intermediates/WSRemailIphoneLib.build/Debug-iphonesimulator/WSRemailIphoneLib.build/WSRemailIphoneLib-own-target-headers.hmap -I/Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Intermediates/WSRemailIphoneLib.build/Debug-iphonesimulator/WSRemailIphoneLib.build/WSRemailIphoneLib-all-target-headers.hmap -iquote /Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Intermediates/WSRemailIphoneLib.build/Debug-iphonesimulator/WSRemailIphoneLib.build/WSRemailIphoneLib-project-headers.hmap -I/Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Products/Debug-iphonesimulator/include -I/Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Intermediates/WSRemailIphoneLib.build/Debug-iphonesimulator/WSRemailIphoneLib.build/DerivedSources/i386 -I/Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Intermediates/WSRemailIphoneLib.build/Debug-iphonesimulator/WSRemailIphoneLib.build/DerivedSources -F/Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/Products/Debug-iphonesimulator -c /Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/WSRemailIphoneLib/WSRemailIphoneLib/WSRemailIphoneLib-Prefix.pch -o /Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/PrecompiledHeaders/WSRemailIphoneLib-Prefix-dlkxvuyxvkogizefpyugokkkniiv/WSRemailIphoneLib-Prefix.pch.pth -MMD -MT dependencies -MF /Users/test/Library/Developer/Xcode/DerivedData/WSRemailIphoneLib-ahcsolybabarwpawkmiknpfbkmzk/Build/PrecompiledHeaders/WSRemailIphoneLib-Prefix-dlkxvuyxvkogizefpyugokkkniiv/WSRemailIphoneLib-Prefix.pch.d

clang: error: no such file or directory: '/Users/test/Desktop/wangxiaohua/search/mail研究/ReMail/WSRemailIphoneLib/WSRemailIphoneLib/WSRemailIphoneLib-Prefix.pch'
clang: error: no input files
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1

原因:
WSRemailIphoneLib-Prefix.pch路径设置不对,文件做了移动,但是工程里面的设置没有变化。

3 向一个工程添加一个已有工程时,工程添加进去后,不能进行文件浏览,即只有一个工程文件在那里
原因:发现一个打开的工程已经添加了这个已有的工程
解决方法:将那个打开的工程关闭,就可以正常添加,并浏览文件了嘎嘎。

4 user header path VS header path
user:import ""
header:import <>



printf:格式:
http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html



1 中文字符导致的问题
/Users/wangxiaohua/Documents/HelloWord/Classes/HelloWordViewController.h:12:0 /Users/wangxiaohua/Documents/HelloWord/Classes/HelloWordViewController.h:12: error: stray '\357' in program
输入了一个中文的“;”以及“*”号
2 类型要加在括号里面
-(IBAction)buttonPressed:id(sender); //这是错误的
-(IBAction)buttonPressed:(id)sender;
3 注意函数的大小写问题
UILabel 
statusTest.Text = newText;//no tips 错误的
statusTest.text = newText;//no tips
4 静态label无法改变内容
@interface HelloWordViewController : UIViewController { UILabel *statusText;}@property (nonatomic,retain) IBOutlet UILabel *statusTest;-(IBAction)buttonPressedLeft:(id)sender;-(IBAction)buttonPressedRight:(id)sender;@end
原因 :上下两个变量名字不一样,一个是Text一个是Test,1 编译时也没有任何的提示信息。2 运行时statusTest都是空指针了,都没有报错,傲傲,厉害呀。
statusTest.text = newText;//no tips
5 'initWithNibName' undeclared
错误:
/Users/wangxiaohua/Documents/ViewSwitcher/Classes/../SwitcherViewController.m:66:0 /Users/wangxiaohua/Documents/ViewSwitcher/Classes/../SwitcherViewController.m:66: error: 'initWithNibName' undeclared (first use in this function)

/Users/wangxiaohua/Documents/ViewSwitcher/Classes/../SwitcherViewController.m:88:0 /Users/wangxiaohua/Documents/ViewSwitcher/Classes/../SwitcherViewController.m:88: error: 'bundle' undeclared (first use in this function)
问题所在:中括号里面有个逗号,郁闷。去掉逗号就可以了。
BlueViewController *blueController = [[BlueViewController alloc],   initWithNibName:@"BlueView" bundle:nil];

6 warning: missing sentinel(哨兵) in function call

NSArray *array = [[NSArray alloc] initWithObjects:@"zhaoyaqi",@"wangxiaohua",@"zhangyongmu",
  @"longyun",@"fuwenzheng",@"yangyunpeng"];
原因,数组末尾缺少哨兵nil
下面正确:
NSArray *array = [[NSArray alloc] initWithObjects:@"zhaoyaqi",@"wangxiaohua",@"zhangyongmu",
  @"longyun",@"fuwenzheng",@"yangyunpeng",nils];

7 很多时候没有错误提示
空指针没有提示 
协议函数名字写错也没有提示信息,如下:
didSelectRow写成 didSelectedRow 没有任何提示,只是程序没有反应。
-(void)pickerView:(UIPickerView *)pickerView 
didSelectRow:(NSInteger)row 
inComponent:(NSInteger)component
{
if (component == KStateComponent) 
{
NSString *selectedState = [self.states objectAtIndex:row];
NSArray *array = [self.stateZips objectForKey:selectedState];
self.zips = array;
[picker selectRow:0 inComponent:KZipComponent animated:YES];
[picker reloadComponent:KZipComponent];
}
}
 8 ****program recieved signal SIGABRT
Self setvalue for key时总是提示这个错误,程序无法继续走
代码如下:
i=1;
NSString *fieldName = [[NSString alloc] initWithFormat:@"colum%d",i];
[self setValue:imageViewArray forKey:fieldName];//执行到这句时退出,报如题的错误
解决方法:
将“colum”改为“column”
因为代码里面并没有colum1这个对象,只有column1对象,
Setvalue forkey 是针对类中的属性设置的,不是随意的什么东西都行。
9 XCode: Base SDK Missing 收藏
从xcode里提取一个例子程序,准备编译运行,但是XCode报错 Base SDK Missing
这也没啥,设上就行了呗,project info->general->Base SDK for all configurations,选择最新的iOS SDK.
好,为了保险起见,整个退出xcode.再起。。。还是base sdk missing...如此反复多次还是不行,有点邪门
google之,哦也,http://stackoverflow.com/questions/3034912/xcode-cant- find-base-sdk
Normally this would work. However, projects ported from XCode in the iOS 3.x SDK to the iOS 4 SDK may not show the base SDK option. 
原来从3.x sdk port 来的工程会有问题,上面链接中也给出了解决办法,即修改project.pbxproj,寻找SDKROOT,将它改为正确的sdk版本。
注意debug release两处都要改,然后保存,重启,一切恢复正常了。

"Project" ->"Edit project setting" 里面也有修改baseSDK的选项。

该了以后需要重启下XCODE

没有重启的时候提示我‘需要什么签名什么的,什么什么不符合之类的错误“,重启下XCODe好了。
10链接错误ld: symbol(s) not found
  "_AudioServicesPlaySystemSound", referenced from:
-[CustomPickerViewController playWinSound] in CustomPickerViewController.o
-[CustomPickerViewController spin] in CustomPickerViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
11 需要一个地址而不是变量/Users/wangxiaohua/Documents/Pickers/Classes/CustomPickerViewController.m:163:0 /Users/wangxiaohua/Documents/Pickers/Classes/CustomPickerViewController.m:163: warning: passing argument 2 of 'AudioServicesCreateSystemSoundID' makes pointer from integer without a cast
12 No architectures to compile for (ARCHS=, VALID_ARCHS=i386 ppc ppc64 ppc7400 ppc970 x86_64).
网上的方法:
Set the project to "Device", clean the target, and rebuild. 
Well, after a night of good sleep I found it, changing your project to "device' is the big button on the left top corner of the Xcode interface... ops: 
Works great now! 
大师没找到device在哪里嗷嗷。

解决方法:将SDK base版本从3.2改为4.2后就没有出现这个问题了。
但是有新的错误:
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 245


13 interface build unable to open documents of type Cocoa Touch XIB

解决方法:没有解决方法,重新安装了下XCODE可以了。

14 无法写文件mainwindow.xib ,没权限
将项目从共享目录放到document里面,又重新启动了下虚拟机。Mca打开的文件都没有释放。

15 Xcode编译WebApps找不到js的错误解决办法
  最近使用Xcode做了一个简单的WebApps应用,就是使用UIWebview来调用一个页面,其中遇到几个问题,这里记录一下。其中一个就是编译的时候出现黄色感叹号的Warning,js文件都报错:warning: no rule to process file '$(PROJECT_DIR)/jquery-1.5.1.min.js' of type sourcecode.javascript for architecture i386
  明显是找不到js文件。这是什么原因呢?
  其实是将js和html等资源文件加入到project的时候,Xcode错误的将js文件都放到了编译源代码(Compile Sources)文件夹,以为js代码也需要“被编译”。

  解决的办法:
  只需要在XCode左侧的列表中Targets -> Compile Sources 中的js文件拖拽到Copy Bundle Resource中就可以了。

  知识点:
 Copy Bundle Resources:是指生成的product的.app内将包含哪些资源文件。通过Copy Bundle Resources中内容的不同设置, 我们可以让不同的product包含不同的资源, 包括程序的主图标等, 而不是把XCode的工程中列出的资源一股脑的包含进去
 Compile Sources:是指将有哪些源代码被编译
 Link Binary With Libraries:是指编译过程中会引用哪些库文件

16 /Users/wangxiaohua/Documents/tt/main.m:17:0 /Users/wangxiaohua/Documents/tt/main.m:17: internal compiler error: Segmentation fault

妈的:重启动虚拟机竟然好了。折腾我半天

17error: can not use an object as parameter to a method

原来样子:-(void)LoadLocalHtmlFile:(NSString) htmlname;
改后样子:-(void)LoadLocalHtmlFile:(NSString*) htmlname;
没有报错误了
18 error: too many arguments to function 'arrayWithObject:'
不正常htmlname = [NSMutableArray arrayWithObject:htmlname,nil];
正常htmlname = [NSMutableArray arrayWithObjects:htmlname,nil];

19 控件不能赋初值
下面的例子中红色部分存在的话,WebView 界面元素无法显示
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
self.Nav = nil;
self.BackBtn = nil;
self.htmlList = nil;
self.WebView = nil;
[super viewDidLoad];
[WebView setOpaque:NO];
[WebView setBackgroundColor:[UIColor clearColor]];
//load mail html
[self LoadLocalHtmlFile:@"main.shtml"];




iphone5 模拟器屏幕大小问题:
On iPhone5 [[UISCreen mainScreen] bounds].size comes back as 320x480. Why. 
原因:资源里面必须要包含一个Default-568h.png(Default-568h@2x.png)的图片才行 
开发遇到的问题or知识点

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值