iOS 7.1 gives error after updating to Xcode 5.1

半城伤御伤魂 提交于 2020-01-01 05:31:27

问题


I have updated my Xcode to version 5.1 recently. After update, it runs fine with all simulators except iOS 7.1, in which it gives a mach-O link error. Moreover, there is only a 64-bit architecture option in 'Build setting' tab. 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.


回答1:


Xcode 5.1 changed the standard project settings. 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). 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. You can disable the warnings again for those projects, or choose not to update your project settings right away.




回答2:


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.

Select Other.. doubleclick $(ARCHS_STANDARD) and change it to $(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. See if there is one available and then switch Architecture back to Standard Architectures.




回答3:


Indeed XCode now includes the arm64 architecture. NSInteger is something completely different now as it is define in 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. Avoid all kind of :

int i = [aString integerValue] ( as it returns a NSInteger)

but

NSInteger i = [aString integerValue] (and if it's a long type then you won't have any trouble.)

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. 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)



来源:https://stackoverflow.com/questions/22372264/ios-7-1-gives-error-after-updating-to-xcode-5-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!