devicekit / devicekit Goto Github PK
View Code? Open in Web Editor NEWDeviceKit is a value-type replacement of UIDevice.
License: MIT License
DeviceKit is a value-type replacement of UIDevice.
License: MIT License
I tried out the:
public var isZoomed: Bool {
return UIScreen.main().scale < UIScreen.main().nativeScale
}
But it will never return true even if I have my device on zoomed.
My device is a real iphone 6 Plus/iOS 10.1
Talking about phones, The plus versions can have some different spacing or behaviours than "regular" sized devices (4.7inches and below).
In our project, we have some complex custom designs and currently we have this line of code there:
Device().isOneOf([.iPhone6Plus, .iPhone6sPlus, .iPhone7Plus, .iPhone8Plus])
Which is not ideal, because we have to manually update it everytime we have new iPhones released.
Instead, it would be nice to have something like:
Device().isOneOf(Device.allPlusPhones)
What do you think? If you agree, I can create a small PR adding the method + a small test
Add:
default: self = .Unspecified
Change To:
let batteryLevel = Double(round(100.0 * (UIDevice.currentDevice().batteryLevel * 100.0)) / 100.0) // rounded, with 2 digits precision
Hey,
I would like to store the outcome of print(Device)
in a variable. Is that possible?
Best regards
If theres an allPhones option it seems silly to have to add in a bunch of extras in order to support simulators. Adding an additional static var for simulators would be super helpful for me as i use these all over my project for UI layout.
When determining if the device is a phone, the iPhone 5c is not under it. It is a very simple fix. Just add iPhone 5c to the allPhones Bool
Hi!
Got an issue
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -project /Users/Andrey/MFO_BOX/Carthage/Checkouts/DeviceKit/DeviceKit.xcodeproj -scheme DeviceKit -configuration Release -derivedDataPath /Users/Andrey/Library/Caches/org.carthage.CarthageKit/DerivedData/8.3.3_8E3004b/DeviceKit/1.3.2 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES build (launched in /Users/Andrey/MFO_BOX/Carthage/Checkouts/DeviceKit)This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/4j/220h75g17k32pn1_6t59tc8w0000gp/T/carthage-xcodebuild.ySawYr.log
I have 2 XCode versions on machine: 8.3.3 and 9 GM. It happened when I tried to update carthage with DeviceKit v. 1.4.0 at Cartfile. Downgrate to v. 1.2.3 only help me, but I need to get support for new devices
I am working on my shared framework (iOS/tvOS) and tried to use DeviceKit inside but then I found, that i have to use #if os(iOS) ...
around DeviceKit calls using because they are already around funcs and vars inside DeviceKit. Wouldn't be better to have all devices available everywhere? I would like to use it for example then like this:
switch device {
case iPhone6, iPhone6s: ...
case AppleTV4: ...
}
Currently I have to write this, because not all funcs and vars are available everywhere
switch device {
#if os(iOS)
case iPhone6, iPhone6s: ...
#elseif os(tvOS)
case AppleTV4: ...
#end
}
I know that the tvOS code probably should not be present in iOS version and vice versa, but this could decide DeviceKit inside implementation. Or is there any issue with Simulator detection or something else?
Weird, tried this on iPad Pro Simulator but it is returning false?
print(Device().isOneOf([Device.iPadPro]))
When I install the master branch from pods, it is not working:
pod 'DeviceKit', :git => 'https://github.com/dennisweissmann/DeviceKit', :branch => 'master'
Is it possible, that you make a new release asap?
can we use it in objective c file?
I looked at the code but didn't see anything to differentiate between iPad Pro size.
How do we do this?
Any plans to add the new iPhones?
I want to know that if it is possible to check if current device is older than a certain device (e.g. iPhone 4s)? Thanks!
Hi man, long time no see!
I'm getting a compiling problem when using 0.3.1 (that first included CarPlay in
private init() {
switch UIDevice.currentDevice().userInterfaceIdiom {
case .Pad: self = .Pad
case .Phone: self = .Phone
case .TV: self = .TV
case .Unspecified: self = .Unspecified
}
}
But since CarPlay has been included there, the app fails when building (as it doesn't exist) and I have to stick to 0.3.0.
I wouldn't like to miss future updates of this repo because of this :D
Thanks!
Hey there,
I'm trying to use this framework. I installed the pod (Swift 3.0) and now I'm trying to use the actual framework. When I write in my class file: let device = Device() it comes up with an error: "Use of an unresolved identifier "Device". So my question is how I can fix that?
I want to fetch IP address, when it is connected to network.
Hi, here is the log from carthage update DeviceKit --platform ios --cache-builds
*** Checking out DeviceKit at "1.3.3"
*** xcodebuild output can be found in /var/folders/9w/ng8hkhns2lb5hqdcw85vm5kc0000gn/T/carthage-xcodebuild.b8QBr5.log
*** Invalid cache found for DeviceKit, rebuilding with all downstream dependencies
*** Building scheme "DeviceKit" in DeviceKit.xcodeproj
Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -project /Users/[myuser]/[myproject]/Carthage/Checkouts/DeviceKit/DeviceKit.xcodeproj -scheme DeviceKit -configuration Release -derivedDataPath /Users/[myuser]/Library/Caches/org.carthage.CarthageKit/DerivedData/8.3.3_8E3004b/DeviceKit/1.3.3 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES build (launched in /Users/[myuser]/[myproject]/Carthage/Checkouts/DeviceKit)
This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/9w/ng8hkhns2lb5hqdcw85vm5kc0000gn/T/carthage-xcodebuild.b8QBr5.log
I reverted to 1.2.3 for the moment.
Got an invalid binary when pushing to Apple because your framework has "Gather coverage date" checked on your test target. Please update.
https://developer.apple.com/library/content/qa/qa1964/_index.html#//apple_ref/doc/uid/DTS40017675
https://developer.apple.com/library/content/qa/qa1964/_index.html#//apple_ref/doc/uid/DTS40017675-CH1-INSPECT
Same issue I fixed for Agrume JanGorman/Agrume#61
I will make a PR shortly.
Hi,
I was wondering if you had any thoughts on expanding the simulator device models? I ran into a scenario where I needed to inspect the device to see if it was an iPhone 6 plus or 6s Plus and I noticed that the simulator only returns Simulator.
What do you think about making a Bool flag that is something like "Is Simulator" and allowing the simulator to resolve to the model that is simulating?
the model name of the simulator can be retrieved by using:
String(UTF8String: getenv("SIMULATOR_MODEL_IDENTIFIER"))
Hey @dennisweissmann, would you consider adding info about the device's total and available disk space within scope for the library?
Newly introduced Apple devices might report incorrectly from Device().isPad
.
In my case, I had not updated DeviceKit and the newly introduced iPad (7,4)
was not being handled properly.
If developers are not careful, this might cause critical bugs.
I think it might be safer if the logic is such that there is at least a 'fallback' for APIs such as isPad
. For example if the device lookup (in Device.swift.gyb
) fails, the isPad
logic falls back to native Apple APIs (e.g. userInterfaceIdiom
).
Can we extend this to get the type of the device as well say whether the device is GSM or CDMA or supports both ?
We were using a older version of the library in our app and hadn't updated it in awhile and then the iPhone 7 came out and we still didn't update...It couldn't find the identifier in the list and so it attempted to try and guess it was a Simulator which it wasn't and so it crashed because of the force unwrap here it would be nice if the case where a device doesn't exist in the list that it didn't crash but returned a unknown device or handled things in a better way
A shell task (/usr/bin/xcrun xcodebuild -project /Carthage/Checkouts/DeviceKit/DeviceKit.xcodeproj -scheme DeviceKit-iOS -configuration Release CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -showBuildSettings) failed with exit code 66:
xcodebuild: error: Scheme DeviceKit-iOS is not currently configured for the build action.
Getting the error above after running a carthage update
. Running carthage update --platform iOS
does the same. Recently updated to XCode 8.0
My cartfile looks like this:
github "dennisweissmann/DeviceKit" ~> 1.0
swiftformat not found. Trying to install it via Homebrew...
Installing swiftformat via homebrew failed. Homebrew not found. Aborting.
External dependencies that format code or lint code should not be required for creating a release build.
As it stands, I can't build DeviceKit using Carthage.
I'm getting this when using Carthage, or building master directly from a git clone:
Check dependencies
“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
I think the project file for master is defaulting to Swift 4.0, where it should be changed to Swift 3.0. Should I be using the "swift-3" branch?
I noticed the device code "iPad5,1" is being incorrectly used to identify iPad Air 2 when it should actually be detecting iPad Mini 4 (according to https://www.theiphonewiki.com/wiki/Models).
The issue seems to be on this section of the code:
case "iPad5,1", "iPad5,3", "iPad5,4": self = iPadAir2
case "iPad5,1", "iPad5,2": self = iPadMini4
This line:
var systemInfo = utsname()
doesn't seem to work. I get the error:
Missing argument for parameter 'sysname' in call
.
I tried to install it through cocoapod. Installation went successful but my xcode force me to convert swift code i tried doing it later i got 18 errors. Then i deintegrate it pod from my project and again tried installing it. However, process was successful again but this time i didnt choose conversion of swift syntax on which i got this error: " Check dependecies: Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly." What should i do next ?
iOS has no public API for getting the device's PPI.
It seems the only way is to hardcode the values based on the device.
When dealing with interfaces for different device sizes I would like to know what scale the user is using for the display i.e. Standard or Zoomed
Because the zoomed display on an iPhone 6 has the same resolution as an iPhone 5 the interface will not layout correctly.
It would be useful to something such as:
let Device = Device()
if device.isZoomed {}
Thanks!
Got this error after upgrading to the newest version.
El Capitan 10.11.1
Xcode 7.2.1 (7C1002)
DeviceKit 0.3.1
CocoaPods 0.39.0
Module file's minimum deployment target is ios9.1 v9.1: /Carthage/Build/iOS/DeviceKit.framework/Modules/DeviceKit.swiftmodule/arm64.swiftmodule
Could you change the deployment target to 8.0 as indicated in the README, so someone could use the Carthage version for projects which should support iOS version before 9.1?
Thanks!
Yesterday I tried Xcode9 beta. Now I want to go back using Xcode 8 but I faced this error on project build for DeviceKit and only for DeviceKit:
Module compiled with swift 4.0 cannot be imported in swift 3.1
The framework installation is made by Carthage. Building DeviceKit project on Xcode 8 works fine. But not on my project. I've tried a lot of things from deleting all Carthage and rebuild all, cleaning project, removing Derived Data... But the problem is still here. And only on DeviceKit.
So I wonder if there is some configuration in DeviceKit to be made to solve it.
The CocoaPods instruction
pod 'DeviceKit', '~> 1.0'
doesn't work.
This is due to a bug in CocoaPods ... I currently cannot submit any new versions to the CocoaPods trunk because it doesn't lint. The error I get is:
=== CLEAN TARGET DeviceKit OF PROJECT Pods WITH CONFIGURATION Release ===
Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for >targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
=== BUILD TARGET DeviceKit OF PROJECT Pods WITH CONFIGURATION Release ===Check dependencies
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
-> DeviceKit (1.0.0)
- ERROR | xcodebuild: Returned an unsuccessful exit code.Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error.
/Users/dennis/.rvm/gems/ruby-2.3.1/gems/cocoapods-1.1.0.rc.1/lib/cocoapods/command/spec/lint.rb:77:in
'run' /Users/dennis/.rvm/gems/ruby-2.3.1@global/gems/claide-1.0.0/lib/claide/command.rb:334:in
run'
/Users/dennis/.rvm/gems/ruby-2.3.1/gems/cocoapods-1.1.0.rc.1/lib/cocoapods/command.rb:50:inrun' /Users/dennis/.rvm/gems/ruby-2.3.1/gems/cocoapods-1.1.0.rc.1/bin/pod:55:in
<top (required)>'
/Users/dennis/.rvm/gems/ruby-2.3.1/bin/pod:23:inload' /Users/dennis/.rvm/gems/ruby-2.3.1/bin/pod:23:in
/Users/dennis/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:ineval' /Users/dennis/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in
'
SWIFT_VERSION
is set to 3.0
.
If anyone has any insights on this and knows how to work around please let me know! Thanks! 🙏
I think this is handy, you could make a pod to make it available easier and it should be simple as it's just one file without dependencies.
That would be nice for sure!
I got it in Device.swift, line 211. Any solution?
Running carthage update --platform iOS
results in the following error:
*** Building scheme "DeviceKit" in DeviceKit.xcodeproj Failed to write to /Users/ryan/Developer/storefront-ios/Carthage/Build/iOS/DeviceKit.framework: Error Domain=NSCocoaErrorDomain Code=260 "The file “DeviceKit.framework” couldn’t be opened because there is no such file." UserInfo={NSURL=file:///Users/ryan/Library/Caches/org.carthage.CarthageKit/DerivedData/9.0_9A235/DeviceKit/1.3.0/Build/Products/Release-iphoneos/DeviceKit.framework, NSFilePath=/Users/ryan/Library/Caches/org.carthage.CarthageKit/DerivedData/9.0_9A235/DeviceKit/1.3.0/Build/Products/Release-iphoneos/DeviceKit.framework, NSUnderlyingError=0x7fdbf3c1cb40 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
Versions:
macOS Sierra 10.12.6
Xcode 9.0 (9A235)
Carthage 0.25.0
DeviceKit 1.3.0 and 1.3.1
UIDevice has a property that shows the current orientation of the device.
Hello,
I've a crash when i use device.isSimulator
You can see the crash log
com.aircall.aircall_issue_1754_crash_a9c6a42051ee437aacd6c697e0e2d8c1_88e7791d791311e7817856847afe9799_0_v2.txt
Do you have an idea ?
Using Carthage 0.15, I get the following error when trying to build for iOS:
*** Building scheme "DeviceKit-iOS" in DeviceKit.xcodeproj
2016-03-09 11:02:52.948 xcodebuild[15957:23586646] [MT] PluginLoading: Required plug-in compatibility UUID F41BD31E-2683-44B8-AE7F-5F09E919790E for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPodUI.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-03-09 11:02:52.948 xcodebuild[15957:23586646] Failed to load plugin at: /Users/schjonhaug/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPodUI.xcplugin, skipping. Reason for failure: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64 /Users/schjonhaug/Development/rikstv-jr./Carthage/Checkouts/DeviceKit/Source/Device.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
/Users/schjonhaug/Development/rikstv-jr./Carthage/Checkouts/DeviceKit/Source/Device.swift:352:19: error: enum case 'CarPlay' not found in type 'UIUserInterfaceIdiom'
A shell task failed with exit code 65:
2016-03-09 11:02:52.948 xcodebuild[15957:23586646] [MT] PluginLoading: Required plug-in compatibility UUID F41BD31E-2683-44B8-AE7F-5F09E919790E for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPodUI.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2016-03-09 11:02:52.948 xcodebuild[15957:23586646] Failed to load plugin at: /Users/schjonhaug/Library/Application Support/Developer/Shared/Xcode/Plug-ins/CocoaPodUI.xcplugin, skipping. Reason for failure: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
** BUILD FAILED **
The following build commands failed:
CompileSwift normal arm64 /Users/schjonhaug/Development/rikstv-jr./Carthage/Checkouts/DeviceKit/Source/Device.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
Missing iPhone 5C on allPhones
:
Device.swift#L262
The current pod version is not building for me, saying:
Enum case 'CarPlay' not found in type 'UIUserInterfaceIdiom'
I couldn't find anything about the CarPlay enum in the apple docs for UIUserInterfaceIdiom
Hey you don't seem to have a license anywhere. Is it alright if i use your device.swift file in my project for commercial purposes as long as i leave the file as it is without removing any comments or code?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.