简体   繁体   中英

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'. Now, for all of my cgrectmake , it gives me a build error saying:

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

Presuming you are building for the Mac App Store (like you say), then you are using an 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)

Make sure you spell CGRectMake correctly. Objective-C is case-sensitive, so cgrectmake is a different and wrong function name.

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. AppKit uses types such as NSRect , which is defined as CGRect on 64-bit, but not by default on 32-bit. 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.

Defining that macro has other ramifications, particularly with regard to the definitions of NSInteger and NSUInteger . Do additional testing before you upload to the App Store.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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