简体   繁体   English

更新到Xcode 5.1后,iOS 7.1会出错

[英]iOS 7.1 gives error after updating to Xcode 5.1

I have updated my Xcode to version 5.1 recently. 我最近将我的Xcode更新到了5.1版。 After update, it runs fine with all simulators except iOS 7.1, in which it gives a mach-O link error. 更新后,它可以在除iOS 7.1之外的所有模拟器上正常运行,其中会出现mach-O链接错误。 Moreover, there is only a 64-bit architecture option in 'Build setting' tab. 此外,“构建设置”选项卡中只有64位架构选项。 According to me, it is the cause of all the problems & errors. 据我所知,这是所有问题和错误的原因。 Does anybody know reason for this & how to solve it? 有谁知道这个的原因以及如何解决它?

Here are some warnings & errors I've got: 以下是我收到的一些警告和错误:

Warning : 警告 :

Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead

Error: 错误:

Symbol(s) not found for architecture x86_64

Thanks. 谢谢。

Xcode 5.1 changed the standard project settings. Xcode 5.1改变了标准项目设置。 Among others it now includes the arm64 architecture for the project - but a lot of 3rd party projects don't support that yet, so I recommend to remove it from the architectures settings again (leaving you with armv7 and armv7s ). 其中它现在包括项目的arm64架构 - 但是很多第三方项目还不支持,所以我建议再次从架构设置中删除它(让你使用armv7armv7s )。 Keep it in the valid architectures setting, though - this specifies on which architectures it may run. 尽管如此,请将其保留在有效的体系结构设置中 - 这指定了它可以运行的体系结构。

It also introduced the default activation of some extra warnings, like the typecast to long warning - same counts here, when you use quite some other libraries (as source code) you might get lots of warnings you can't (or don't want to) do much about. 它还引入了一些额外警告的默认激活,例如长期警告的类型转换 - 这里计算相同,当你使用其他一些库(作为源代码)时,你可能会得到很多警告,你不能(或者不想要) to)做很多事情。 You can disable the warnings again for those projects, or choose not to update your project settings right away. 您可以再次为这些项目禁用警告,或选择不立即更新项目设置。

Got to Build Settings -> Architectures 必须构建设置 - >架构

You probably have Standard Architectures set, right? 您可能已设置标准体系结构,对吧?

As of Xcode 5.1 Standard Architectures includes arm64, which you are not ready to support. 从Xcode 5.1开始,标准架构包含arm64,您尚未准备好支持它。

Select Other.. doubleclick $(ARCHS_STANDARD) and change it to $(ARCHS_STANDARD_32_BIT) 选择其他..双击$(ARCHS_STANDARD)并将其更改为$(ARCHS_STANDARD_32_BIT)

Note: This is a temporary fix. 注意:这是一个临时修复。 You are probably using some static library that didn't come with a 64-bit slice. 您可能正在使用一些没有64位切片的静态库。 See if there is one available and then switch Architecture back to Standard Architectures. 查看是否有可用的,然后将架构切换回标准架构。

Indeed XCode now includes the arm64 architecture. 事实上,XCode现在包含arm64架构。 NSInteger is something completely different now as it is define in NSObjCRuntime.h : NSInteger现在完全不同,因为它在NSObjCRuntime.h中定义:

#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif

To deal with it you should improve your codebase. 要处理它,你应该改进你的代码库。 First of all, you have to be really consistent. 首先,你必须非常一致。 Assign NSInteger only to NSInteger and not to int. 仅将NSInteger分配给NSInteger而不分配给int。 Avoid all kind of : 避免各种:

int i = [aString integerValue] ( as it returns a NSInteger) int i = [aString integerValue](因为它返回一个NSInteger)

but

NSInteger i = [aString integerValue] (and if it's a long type then you won't have any trouble.) NSInteger i = [aString integerValue](如果它是一个long类型,那么你将没有任何麻烦。)

Moreover, another issue you might have is when you want to create a string from a value. 此外,您可能遇到的另一个问题是当您想要从值创建字符串时。 What you could do is something like: 你能做的是:

#define cL(v)    (long)(v)
#define cUL(v)   (unsigned long)(v)

NSLog(@"array.count: %ld", cUL(anArray.count));

array.count returns an unsigned int under armv7(s) and an unsigned long under arm64. array.count返回armv7(s)下的unsigned int和arm64下的unsigned long。 By always casting into an unsigned long you will not face any warning anymore and, more important, do not get any bug. 通过始终投入无符号长度,您将不会再遇到任何警告,更重要的是,不会遇到任何错误。

This "logic" have been introduced by Apple itself on some tech-talks videos there: https://developer.apple.com/tech-talks/videos/ (video "Architecting Modern iOS Games". Play the video around 10m00s) 这个“逻辑”已经由Apple自己介绍了一些技术会谈视频: https//developer.apple.com/tech-talks/videos/ (视频“架构现代iOS游戏”。播放视频大约10分钟)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM