简体   繁体   English

CGRectMake中的XCode'Build for Archive'巨大错误

[英]XCode 'Build for Archive' HUGE errors in CGRectMake

I'm just building my Cocoa app for distribution on mac app store, but this it the forst time I have used 'build and archive'. 我只是在构建我的Cocoa应用程序,以便在Mac应用程序商店中分发,但这是我第一次使用“构建并存档”。 Now, for all of my cgrectmake , it gives me a build error saying: 现在,对于我所有的cgrectmake ,它给我一个构建错误,说:

error: incompatible type for argument 1 of 'setFrame:'

The code always affected is: 始终受影响的代码是:

image.frame = cgrectmake(x, y, width, height);

This dosent happen in normal debug. 这是在正常调试中发生的。 What is going on? 到底是怎么回事?

By the way I'm using XCode 4 if that makes a difference 顺便说一下,我正在使用XCode 4,如果有区别的话

Presuming you are building for the Mac App Store (like you say), then you are using an NSImageView. 假设您正在构建Mac App Store(如您所说),那么您正在使用NSImageView。 Your problem is that NSImageView takes an NSRect to set the frame, which can be created with NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) 您的问题是NSImageView使用NSRect设置框架,可以使用NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h)创建框架。

Make sure you spell CGRectMake correctly. 确保正确拼写CGRectMake Objective-C is case-sensitive, so cgrectmake is a different and wrong function name. Objective-C区分大小写,因此cgrectmake是一个错误的函数名称。

Also, if you're building for 32-bit (as I assume you would be for a release build), the CG types are not the same as their NS counterparts there. 另外,如果您要构建32位(我假设您将使用发布版本),则CG类型与那里的NS对应类型不同。 AppKit uses types such as NSRect , which is defined as CGRect on 64-bit, but not by default on 32-bit. AppKit使用NSRect类的类型,该类型在64位上定义为CGRect ,但默认情况下在32位上定义为CGRect Define NS_BUILD_32_LIKE_64 in your prefix header, before importing Cocoa.h, to make NSRect be defined as CGRect even on 32-bit architectures. 在导入Cocoa.h之前,请在前缀标头中定义NS_BUILD_32_LIKE_64 ,以使NSRect即使在32位体系结构上也被定义为CGRect

Defining that macro has other ramifications, particularly with regard to the definitions of NSInteger and NSUInteger . 定义一个宏有其他后果,特别是有关的定义NSIntegerNSUInteger Do additional testing before you upload to the App Store. 在上载到App Store之前,请执行其他测试。

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

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