我刚刚将我的iPhone 4S软件更新到iOS 7 Beta 2,而我正在最后接触到一个新的应用程序(Phonegap)..不是一个好主意!
完成后,Xcode没有检测到我的iPhone,所以我安装了Xcode 5 beta。在摆弄它之后我终于得到它来检测我的手机。现在唯一的问题是使用的架构存在错误。
以下是产生的错误:
ld: warning: ignoring file /Users/-----------/Library/Developer/Xcode/DerivedData/testtest-bmnbmujiosugcmgeiceofgcfmsec/Build/Products/Debug-iphoneos/libCordova.a, file was built for archive which is not the architecture being linked (armv7s): /Users/--------/Library/Developer/Xcode/DerivedData/testtest-bmnbmujiosugcmgeiceofgcfmsec/Build/Products/Debug-iphoneos/libCordova.a
Undefined symbols for architecture armv7s:
"_OBJC_METACLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_METACLASS_$_MainCommandDelegate in MainViewController.o
"_CDVLocalNotification", referenced from:
-[AppDelegate application:didReceiveLocalNotification:] in AppDelegate.o
"_OBJC_CLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_CLASS_$_MainCommandDelegate in MainViewController.o
"_OBJC_CLASS_$_CDVCommandQueue", referenced from:
_OBJC_CLASS_$_MainCommandQueue in MainViewController.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVCommandQueue", referenced from:
_OBJC_METACLASS_$_MainCommandQueue in MainViewController.o
"_CDVPluginHandleOpenURLNotification", referenced from:
-[AppDelegate application:handleOpenURL:] in AppDelegate.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
有关架构应该更改为什么的任何想法,以使其在我的手机上工作? (它在模拟器上工作正常)
答案 0 :(得分:104)
简答:
详细解答:
问题是您在主应用程序中链接的静态库'libCordova.a'仅针对一个体系结构(armv7,但不是armv7s)进行编译。
您可能已让Xcode执行静态库项目的所有建议更改,而不会阅读这些更改实际上是什么。说到我自己,我从来没有费心仔细看看那个信息对话框(下面的截图),当我切换到新版本的Xcode时 - 直到现在。
问题是执行这些更改会激活调试构建一个名为仅构建活动架构的新功能(构建设置参数键为'ONLY_ACTIVE_ARCH')。原则上,这是Xcode的一个非常酷的增强,因为将其设置为YES会缩短构建时间,因为当您点击运行按钮时,Xcode仅编译您当前在顶部选择的连接设备的体系结构。
但是,当在静态库中盲目接受这个新参数时,您可能会遇到此错误。当您在连接armv7设备时构建静态库的调试版本时会发生错误,然后,当您调试主应用程序时,您已连接armv7s设备(反之亦然)。随后你会得到上面的错误(或类似的错误)。
所以我的建议是从所有静态库的项目构建设置中完全删除项目级别的仅构建主动架构的值。因为如果你看一下iOS的默认值,那就是NO。当然,您也可以将设置覆盖为“否”,以确保设置正确,即使将来默认值会改变(参见第1张截图)。
答案 1 :(得分:75)
如果你的项目是使用Cordova 2.x和Xcode 4.x构建的,并且你收到了OP提到的错误,那么这个解决方案对我有用。 (我遇到了Cordova 2.5和Xcode 5的错误。)
https://issues.apache.org/jira/browse/CB-3768
转到您的Cordova项目
根文件夹 - > CordovaLib - >右键单击CordovaLib.xcodeproj - >显示包装内容 - >打开project.pbxproj
替换所有出现的(我有4个)
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;//in 2 out of 4 occurrences
"ARCHS[sdk=iphoneos*]" = armv7;
"ARCHS[sdk=iphoneos6.*]" = (
armv7,
armv7s,
);
/* other settings here */
};
有了这个
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;//in 2 out of 4 occurrences
"ARCHS[sdk=iphoneos*]" = armv7;
"ARCHS[sdk=iphoneos7.*]" = (
armv7,
armv7s,
);
"ARCHS[sdk=iphoneos6.*]" = (
armv7,
armv7s,
);
/* other settings here */
};
现在您的项目将构建良好!
答案 2 :(得分:13)
我已从armv7s
部分删除valid architectures
,但它对我有效。
构建设置 - >架构 - >有效的架构
答案 3 :(得分:11)
我正在使用Xcode 5,因此iOS SDK 7.对我有用的解决方案就是删除arm64架构。
选择项目目标(不是CordovaLib.xcodeproj),然后在构建设置>有效体系结构中,删除列表中的arm64。删除arm64架构后,这是我的。
答案 4 :(得分:4)
因为我的lib.a仅用于armv7
我做的是
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
"ARCHS[sdk=iphoneos*]" = (
armv7s,
armv7,
);
"ARCHS[sdk=iphoneos6.*]" = (
armv7s,
armv7,
);
"ARCHS[sdk=iphoneos7.*]" = (
armv7,
armv7s,
);
它构建并存档很好
希望有所帮助
答案 5 :(得分:3)
njtman有一个正确的答案。我没有代表评论,所以我要添加更多细节。
您需要iOS 7 SDK才能使用标准架构(armv7,armv7s)。
我的项目默认为(armv7),不包括armv7s。
要解决这个问题, 打开CordovaLib.xcodeproj, 在“构建设置”下(顶行中的一个菜单,居中对齐) 在体系结构,体系结构,调试和发布下,使用标准体系结构添加iOS 7.0。
答案 6 :(得分:0)
在构建设置中......
Strip Debug Symbols During Copy:
Debug: No
Release: No