Code Monkey home page Code Monkey logo

uideviceidentifier's Introduction

Description

UIDeviceHardware is a class originally created in a gist by Jaybles. It allows querying of the current users device, and returns a human formatted string.

It is written as a class method, to allow use without direct instantiation.

⚠️ Note

I don't use this helper much anymore, so I'm not keeping up to date with device models. While I welcome Pull Requests to update the model, I'd recommend moving over to something more modern, like DeviceKit.

Usage

// "iPhone 5C (GSM)"
NSString *platformString = [UIDeviceHardware platformString];
    
// "iPhone 5C"
NSString *simpleString = [UIDeviceHardware platformStringSimple];

Installation

This class can be installed with Swift Package Manager, Cocoapods, or by directly copying the files into your source code.

Swift Package Manager

Add the package to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/squarefrog/UIDeviceIdentifier", .upToNextMajor(from: "1.7.0"))
],

Then import as follows:

// ObjC
@import UIDeviceIdentifier;
// Swift
import UIDeviceIdentifier

Cocoapods

Add the cocoapod to your Podfile:

pod 'UIDeviceIdentifier', :git => 'https://github.com/squarefrog/UIDeviceIdentifier.git'

Import the file into your Objective-C file:

// ObjC
#import <UIDeviceIdentifier/UIDeviceHardware.h>

Copying the files

Copy UIDeviceHardware.{h/m} into your project. Then just import the header:

#import "UIDeviceHardware.h"

Licence

UIDeviceHardware is available under the MIT licence. See the LICENCE file for more info.

uideviceidentifier's People

Contributors

arfaoui avatar bjhomer avatar cabbiepete avatar chenpingsheng avatar coeur avatar kawanet avatar lefex avatar mangerlahn avatar maxhasadhd avatar mflint avatar paulz avatar readmecritic avatar rgomesbr avatar silviasfondrini avatar squarefrog avatar stevel6868 avatar stevemoser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uideviceidentifier's Issues

enhencement idea

Hi,

Any reason why this is an extra class for this one method ?

I'd suggest to change it to a protocol to add the method to the uidevice class.

Bastian

1.4.0 issues

The platforms supported were modified from version 1.3.0 in UIDeviceIdentifier.podspec, like:
s.platforms = { :ios => nil, :tvos => nil }
to version 1.4.0, like:

 s.ios.deployment_target = ""
 s.tvos.deployment_target = ""

This changed can lead to the not support for architecture armv7 when archiving by Xcode 11.x.

iPad Pro + Enum support?

Please add iPad Pro constant.

Also it would be awesome if this returned an enum value or constant.

Good job.

Xcode13.1 iOS12 crash

Use this pod in Xcode13.1, run on iOS12,App will crash.
截屏2021-12-14 上午11 22 25
Specify s.ios.deployment_target to 6.0 or any other version, can avoid crash.

Fall 2021 Models Release?

Was version 1.7.0 supposed to contain the model name updates from #45?

I just noticed the change flow into one of my apps via pod install, except it only had the changes from #43. Got a little confused why a readme-only change from July suddenly decided to show up. Any chance the 1.7.0 had previously been created for the SPM support?

New Release needed

I see master already supports iPhone 8 and X, but those are not in a tagged release yet. Any plans for a new release?

Late 2023 model numbers

From the device_traits.db in today's Xcode 15 release candidate:

model device more info
iPhone15,4 iPhone 15
iPhone15,5 iPhone 15 Plus
iPhone16,1 iPhone 15 Pro
iPhone16,2 iPhone 15 Pro Max
Watch7,1 Apple Watch Series 9 (GPS) guessing 41mm
Watch7,2 Apple Watch Series 9 (GPS) guessing 45mm
Watch7,3 Apple Watch Series 9 (GPS + Cellular) guessing 41mm
Watch7,4 Apple Watch Series 9 (GPS + Cellular) guessing 45mm
Watch7,5 Apple Watch Ultra 2

platformString cause `message sent to deallocated instance`

Subsequent calls to platformString cause crash due to deallocated instance of NSDictionary.

Here is a Quick spec to reproduce the issue:

import Quick
import Nimble
import UIDeviceIdentifier

class UIDeviceHardwareSpec : QuickSpec {
    override func spec() {
        context("platformString") {
            it("should not crash with message sent to deallocated instance") {
                var platform : String?
                autoreleasepool {
                    platform = UIDeviceHardware.platformString()
                }
                autoreleasepool {
                    platform = UIDeviceHardware.platformString()
                }
                expect(platform).notTo(beNil())
            }
        }
    }
}

UIDevice Category

Why not making the library as a category for UIDevice? For example:

[[UIDevice currentDevice] platformString];

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.