xcode 构建 32 位 OS X 应用程序时出错?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7110245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:45:35  来源:igfitidea点击:

Error building 32-bit OS X app?

cocoacompiler-errors32bit-64bitxcode

提问by anna

I'm working on my first Mac OS X app. My project was set-up with XCode defaults and I haven't touched any Build Settings. When building for Mac 64-bit, the app runs fine. However, when building for Mac 32-bit, I get a seemingly arbitrary error that says:

我正在开发我的第一个 Mac OS X 应用程序。我的项目是使用 XCode 默认设置的,我没有触及任何构建设置。为 Mac 64 位构建时,该应用程序运行良好。但是,在为 Mac 32 位构建时,我收到一个看似随意的错误,内容为:

Semantic issue: Synthesized property 'myProperty' must either be named the same as a compatible ivar or must explicitly name an ivar.

Semantic issue: Synthesized property 'myProperty' must either be named the same as a compatible ivar or must explicitly name an ivar.

What kind of things can I check for?

我可以检查哪些项目?

回答by

It sounds like you have found the error but I think I can answer your question just in case someone else later finds it.

听起来您已经发现了错误,但我想我可以回答您的问题,以防其他人以后发现它。

Apple has made a lot of changes in the 64 bit Objective-C runtime which they couldn't do before since it would break binary compatibility. One of the things that is different is that in the 32 bit runtime synthesized properties have to be backed by instance variables. On the 64-bit runtime synthesized properties sill needs that but they are created automatically for you. By default the name of the instance variable should be the same as the name of the property.

Apple 在 64 位 Objective-C 运行时中进行了很多他们以前无法做到的更改,因为它会破坏二进制兼容性。不同之处之一是在 32 位运行时合成属性必须由实例变量支持。在 64 位运行时合成属性 sill 需要这些,但它们是自动为您创建的。默认情况下,实例变量的名称应该与属性的名称相同。

So in case you need to support 32 bit then make sure that you create instance variables for all your properties. If you only support 64 bit then you can still do that so that your code can be built for both 32 bit and 64 bit at the same time but you don't have to.

因此,如果您需要支持 32 位,请确保为所有属性创建实例变量。如果您只支持 64 位,那么您仍然可以这样做,以便您的代码可以同时为 32 位和 64 位构建,但您不必这样做。

回答by theUltimateNoob

You can set the NS_BUILD_32_LIKE_64preprocessor macro in Xcode for the the 32bit build target. This will save you the trouble of maintaining separate code for 32bit and 64bit versions.

您可以在 Xcode 中为 32 位构建目标设置NS_BUILD_32_LIKE_64预处理器宏。这将为您省去为 32 位和 64 位版本维护单独代码的麻烦。