问题1:ARC与MRC混编
可以给ARC项目添加MRC标记(-fno-objc-arc),也可以给MRC项目添加ARC标记(-fobjc-arc)
问题2:OC委托报错 Existing instance variable 'middleMan' for property 'middleMan' with assign
@interface Student : NSObject { id<Question> delegate; } 改为:
@interface Student : NSObject { __unsafe_unretained id<Question> delegate; }
问题3:xcode6 使用MJRefresh,Too many arguments to function call, expected 0, have *
将XCode升级到6后,报Too many arguments to function call, expected 0, have *,在XCode5.1里能编译通过的,到xcode6就报错
objc_msgSend(self.beginRefreshingTaget, self.beginRefreshingAction, self);
Too many arguments to function call, expected 0, have *
问了下度娘,
选中项目 - Project - Build Settings - ENABLE_STRICT_OBJC_MSGSEND 将其设置为 NO 即可
问题4:Undefined symbols for architecture i386: 问题
Undefined symbols for architecture i386:
"_sqlite3_backup_finish", referenced from:
_loadOrSaveDb in FMDatabase+InMemoryOnDiskIO.o
"_sqlite3_backup_init", referenced from:
_loadOrSaveDb in FMDatabase+InMemoryOnDiskIO.o
"_sqlite3_backup_step", referenced from:
_loadOrSaveDb in FMDatabase+InMemoryOnDiskIO.o
"_sqlite3_bind_blob", referenced from:
-[FMDatabase bindObject:toColumn:inStatement:] in FMDatabase.o
"_sqlite3_bind_double", referenced from:
-[FMDatabase bindObject:toColumn:inStatement:] in FMDatabase.o
"_sqlite3_bind_int", referenced from:
-[FMDatabase bindObject:toColumn:inStatement:] in FMDatabase.o
"_sqlite3_bind_int64", referenced from:
-[FMDatabase bindObject:toColumn:inStatement:] in FMDatabase.o
"_sqlite3_bind_null", referenced from:
-[FMDatabase bindObject:toColumn:inStatement:] in FMDatabase.o
"_sqlite3_bind_parameter_count", referenced from:
-[FMDatabase executeQuery:withArgumentsInArray:orDictionary:orVAList:] in FMDatabase.o
-[FMDatabase executeUpdate:error:withArgumentsInArray:orDictionary:orVAList:] in FMDatabase.o
"_sqlite3_bind_parameter_index", referenced from:
-[FMDatabase executeQuery:withArgumentsInArray:orDictionary:orVAList:] in FMDatabase.o
-[FMDatabase executeUpdate:error:withArgumentsInArray:orDictionary:orVAList:] in FMDatabase.o
这个错误的发生原因一般是“XXX”这个文件(类库)虽然引入了工程中,但是由于种种原因(常见于多人开发,svn同步不规范)导致“XXX”并未被添加到project.pbxproj这个文件中。
解决方法是点击工程,在targets界面中找到Build Phases,根据提示信息“XXX”来判断缺少什么文件,一般如果缺少自定义的文件,XXX会是缺少的类名,那么就在Complie Sources中加入该文件。如果缺少类库,则在Link Binary With Libraries中加入该类库。
而上面问题是因为少在Link Binary With Libraries 中加入 libsqlite3.dylib ,添加后就可以编译通过。
Xcode 7 缺少 *.dylib库的解决方法
Xcode7中 Link Binary With Libraries 没有 *.dylib库,只能找到对应的 *.tbd,但不能代替使用,通过查找资料,尝试后得到以下两种解决方法。
1.Link Binary With Libraries 手动添加
首先点击 “+”
显示搜索添加页面,点击 Add Other
出现文件目录页面,快捷键 CMD+Shift+G (Go to the folder),输入/usr/lib,添加你需要的 *.dylib。
2.Build Phases 配置
project -> Build Phases ->Linking -> Other Linker Flag
添加 -l< 所需 dylib 的名称 >
例如:libsqlite3.dylib -> -lsqlite3
问题5:在编译RegexKitLite的时候,报错如下:
Undefined symbols for architecture i386:
"_uregex_open", referenced from:
_rkl_getCachedRegex in RegexKitLite.o
"_uregex_groupCount", referenced from:
_rkl_getCachedRegex in RegexKitLite.o
"_uregex_setText", referenced from:
_rkl_setCachedRegexToString in RegexKitLite.o
解决办法:
在项目的编译设置中找到Build settings->Linking->Other Linker Flags,然后在后面字段空白处双击,
添加“-licucore”就可以了。
问题6: "OBJC_CLASS$MFMessageComposeViewController", referenced from:
l_OBJC$CATEGORY_MFMessageComposeViewController$_BlocksKit in BlocksKit(BlocksKit)
原因:
这是编译器找不到符号定义,通常这意味着某些framework没有加入项目中
解决参考:
解读信息,是因为找不到叫MFMessageComposeViewController的ObjC类。
查找MFMessageComposeViewController的信息,得知其定义在MessageUI.framework中,将其加入到项目中即可
问题7:"OBJC_CLASS$_CTTelephonyNetworkInfo", referenced from:
解决方法:在build phases里加一下 CoreTelephony.framework就可以了
问题8: Xcode "_deflate", referenced from:
解决办法:添加libz.dylib类库
问题9:iOS真机调试的时候报错:/libUPPayPlugin.a(UPJSON.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
error: linker command failed with exit code 1 (use -v to see invocation)
解决办法:看看是不是bitcode开着呢,把bitcode改为no
问题10:
XCTest/XCTest.h not found on old projects built in Xcode
问题描述:
fatal error: 'XCTest/XCTest.h' file not found
import 解决方法: 在报错的Target中的Building settings中FRAMEWORK_SEARCH_PATHS添加$(PLATFORM_DIR)/Developer/Library/Frameworks
XCTest/XCTest.h <wbr>not <wbr>found <wbr>on <wbr>old <wbr>projects <wbr>built <wbr>in <wbr>Xcode
问题11:添加第三方类库造成的linker command failed with exit code 1 (use -v to see invocation)的错误调试
linker command failed with exit code 1 (use -v to see invocation)这个错误貌似遇见并不止一次,当我想用某个第三方类库的时候(如SBJson),我直接把类库文件copy到工程目录里面,然后一编译就出现这样错误(并不是一定会出这样错误),开始以为是网上下载的类库本身问题,所以重新找类库或者其他方式将它添加进去,只要不出错就行,也一直没有深入了解根本问题,今天在给工程添加一个FMDB(SQLIte第三方类库)文件编译时又出现这种错误,一开始以为工程问题,但是新建工程后还是出现这个问题,经过网上查找,得到了解决办法;
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_FMDatabase", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
在网上得到解决办法是:
在工作左边导航栏Target-->Build Phases-->compile Sources中,第三库库的所有.m文件都添加到里面,然后编译通过了;
添加.m文件
根据对比可以看见 in FMDBTest,FMDBTest的Target里添加进去了了一些.m文件
对于以上错误,根据网友解答我的理解是
我们在使用这些第三方类库文件时直接将其拖拽到工程之中,编译的的时候Xcode也没有自动引用,所以造成这样错误,这就需要我们手动添加。假如我们在工程中新建某个文件就不会出现这样问题;
问题12:
关于导入文件错误:too many errors emitted, stopping now [-ferror-l
解决方法:build settings 里 Compile Sources As选项改为Objective C++。
问题13:dyld: Library not loaded: @rpath/XCTest.framework/XCTest
Referenced from: /var/containers/Bundle/Application/B5212ED6-4ECE-4BCC-A52A-689CBD400E44/02 - album.app/02 - album
Reason: image not found
解决方法:多加了两个m文件,下图中m文件删除即可
问题14:
Unsupported compiler 'com.apple.compilers.llvmgcc42' selected for architecture 'armv7'
解决方法:
Change your compiler for C/C++/ObjectiveC Go to Build Settings->Build OPtions->compiler for C/C++/ObjectiveC; select Default(Apple LLVM5.0)