Determine If iOS Device Is 32- or 64-Bit

Determine if iOS device is 32- or 64-bit

There is no other "official" way to determine it. You can determine it using this code:

if (sizeof(void*) == 4) {
NSLog(@"32-bit App");
} else if (sizeof(void*) == 8) {
NSLog(@"64-bit App");
}

Analytics: How to detect 32-bit only devices?

In this answer I will address the root question which is: "How do I determine how many 32-bit device users I will lose when Apple bans 32bit apps from the App Store for the iOS 11 release?"

As anticipated in the comments, Apple has NOT banned 32bit apps from the App Store as of Sept 23, 2017. Instead, they have continued to support 32bit apps in the App Store for older devices. The only requirement at this time for apps is that they must support 64bit as well.

This is because the requirements for iOS 11 and for the App Store are independent sets of requirements.

I have been able to confirm this by viewing the available updates for my 32bit iPad 2 running iOS 9.3 (see below). I can confirm that the apps do run (though rather slowly due to the old hardware).

While this issue is not currently a concern, I would keep an eye on Apple's Developer News and Updates page for future changes in app submission requirements.

Sample Image

Is there an API in Swift to determine processor register size of iOS device?

MemoryLayout<Int>.size == MemoryLayout<Int32>.size ? 32 : 64

Find if an ipa file is 32 or 64-bit. (macos/unix)

First, try unzip the ipa file to a directory, eg:

unzip <filename>.ipa -d ~/Downloads/tmp

Second, use file command to identify the architectures, eg:

file ~/Downloads/tmp/Payload/<appname>.app/<app>

Then, you will have what you want~

~/Downloads/tmp/Payload/<appname>.app/<app>: Mach-O universal binary with 2 architectures
~/Downloads/tmp/Payload/<appname>.app/<app> (for architecture armv7): Mach-O executable arm
~/Downloads/tmp/Payload/<appname>.app/<app> (for architecture cputype (16777228) cpusubtype (0)): Mach-O 64-bit executable

iOS Simulator - how to test older (32-bit) devices?

XCode --> Preferences --> Components will allow you do download simulator images for older versions of iOS

how can I know the iOS app that I made is 32 bit or not? and how can I change that?

To change to 64 bit you should:

  1. Select your project
  2. Select your target
  3. Select Build Settings
  4. Look for Valid Architectures
  5. Set only arm64 as the Valid Architecture

How to determine if compiling for 64-bit iOS in Xcode

To determine if you are compiling for 64-bit, use __LP64__:

#if __LP64__
return CGSizeMake(ceil(size.width), ceil(size.height));
#else
return CGSizeMake(ceilf(size.width), ceilf(size.height));
#endif

__LP64__ stands for "longs and pointers are 64-bit" and is architecture-neutral.

According to your transition guide it applies for iOS as well:

The compiler defines the __LP64__ macro when compiling for the 64-bit
runtime.

However, the preferred way to handle your use case is to use CGFLOAT_IS_DOUBLE. There is no guarantee that __LP64__ will always mean the CGFloat is a double, but it would be guaranteed with CGFLOAT_IS_DOUBLE.

#if CGFLOAT_IS_DOUBLE
return CGSizeMake(ceil(size.width), ceil(size.height));
#else
return CGSizeMake(ceilf(size.width), ceilf(size.height));
#endif

Is there a API to know current iOS/Mac is 64bit OS or 32 bit OS?

In general, you can assume OS X is 64-bit based on the OS version.
(more specifically the Cocoa version.)

More importantly, you have to ask yourself what you are trying to accomplish.
In general, the Frameworks protect you from needing to think about this most of the time, especially in Objective-C land.
If you stay in Objective-C land, you can go simple with macros:
CGFLOAT_IS_DOUBLE (from CGGeometry.h)

NSObjCRuntime.h defines NSInteger and NSUInteger.
The macro LP64 found there indicates 64-bit integers

https://developer.apple.com/library/Mac/DOCUMENTATION/Cocoa/Conceptual/Cocoa64BitGuide/64BitChangesCocoa/64BitChangesCocoa.html

In general if you try to use NSInteger, NSUInteger and CGFloat, you don't need to think about it.

If you want to know more specifically about the core C type sizes, you want to learn about the standard models created. LP64 ILP64 LLP64 ILP32 LP32
These indicate what to expect. You can't really actually assume there is one model for 64-bit.
You can have different integer and float max lengths depending on architecture.
Depending on system, you could even have an emulation of a type length.
http://www.unix.org/version2/whatsnew/lp64_wp.html
These are defined with macros like LP64

You can find these in CFBase.h

But the real question is still, what are you trying to do?



Related Topics



Leave a reply



Submit