Code Monkey home page Code Monkey logo

devicekit's Introduction

GitHub license CocoaPods Compatible Carthage Compatible codecov CocoaPods Maintainability Platform

Branch Versions
master ≥ 2.0
Swift 4 - 4.2 ≥ 1.3 < 1.13
Swift 3 ≥ 1.0 < 1.3
Swift 2.3 < 1.0

DeviceKit is a value-type replacement of UIDevice.

Current version 5.2.4

See our detailed changelog for the latest features, improvements and bug fixes.

Features

  • Equatable
  • Device identification
  • Device family detection
  • Device group detection
  • Simulator detection
  • Battery state
  • Battery level
  • Various device metrics (e.g. screen size, screen ratio, PPI)
  • Low Power Mode detection
  • Guided Access Session detection
  • Screen brightness
  • Display Zoom detection
  • Detect available sensors (Touch ID, Face ID)
  • Detect available disk space
  • Apple Pencil support detection

Requirements

  • iOS 11.0+
  • tvOS 11.0+
  • watchOS 4.0+

Installation

DeviceKit can be installed in various ways.

CocoaPods

Swift 5

pod 'DeviceKit', '~> 5.2'

iOS 8.0 support

pod 'DeviceKit', '3.2'

Swift 4.0 - Swift 4.2

pod 'DeviceKit', '~> 1.3'

Swift 3

pod 'DeviceKit', '~> 1.2.3'

Swift 2.3 (Unsupported)

pod 'DeviceKit', :git => 'https://github.com/devicekit/DeviceKit.git', :branch => 'swift-2.3-unsupported'

Swift Package Manager

Swift 5

dependencies: [
    .package(url: "https://github.com/devicekit/DeviceKit.git", from: "4.0.0"),
    /// ...
]

iOS 8.0 support

dependencies: [
    .package(url: "https://github.com/devicekit/DeviceKit.git", from: "3.2.0"),
    /// ...
]

Carthage

Swift 5

github "devicekit/DeviceKit" ~> 4.0

iOS 8.0 support

github "devicekit/DeviceKit" ~> 3.2

Swift 4.0 - Swift 4.2

github "devicekit/DeviceKit" ~> 1.3

Swift 3

github "devicekit/DeviceKit" ~> 1.2.3

Swift 2.3 (Unsupported)

github "devicekit/DeviceKit" "swift-2.3-unsupported"

Manually

To install it manually, drag the DeviceKit project into your app project in Xcode. Or add it as a git submodule by running:

$ git submodule add https://github.com/devicekit/DeviceKit.git

Usage

First make sure to import the framework:

import DeviceKit

Here are some usage examples. All devices are also available as simulators:

.iPhone6 => .simulator(.iPhone6)
.iPhone6s => .simulator(.iPhone6s)

You can try these examples in Playground.

Note:

To try DeviceKit in the playground, open the DeviceKit.xcworkspace and build DeviceKit.framework for any simulator first by selecting "DeviceKit" as your current scheme.

Get the Device You're Running On

let device = Device.current

print(device)     // prints, for example, "iPhone 6 Plus"

if device == .iPhone6Plus {
  // Do something
} else {
  // Do something else
}

Get the Device Family

let device = Device.current
if device.isPod {
  // iPods (real or simulator)
} else if device.isPhone {
  // iPhone (real or simulator)
} else if device.isPad {
  // iPad (real or simulator)
}

Check If Running on Simulator

let device = Device.current
if device.isSimulator {
  // Running on one of the simulators(iPod/iPhone/iPad)
  // Skip doing something irrelevant for Simulator
} 

Get the Simulator Device

let device = Device.current
switch device {
case .simulator(.iPhone6s): break // You're running on the iPhone 6s simulator
case .simulator(.iPadAir2): break // You're running on the iPad Air 2 simulator
default: break
}

Make Sure the Device Is Contained in a Preconfigured Group

let groupOfAllowedDevices: [Device] = [.iPhone6, .iPhone6Plus, .iPhone6s, .iPhone6sPlus, .simulator(.iPhone6), .simulator(.iPhone6Plus),.simulator(.iPhone6s),.simulator(.iPhone6sPlus).simulator(.iPhone8),.simulator(.iPhone8Plus),.simulator(.iPhoneX),.simulator(.iPhoneXS),.simulator(.iPhoneXSMax),.simulator(.iPhoneXR)]

let device = Device.current
 
if device.isOneOf(groupOfAllowedDevices) {
  // Do your action
}

Get the Current Battery State

Note:

To get the current battery state we need to set UIDevice.current.isBatteryMonitoringEnabled to true. To avoid any issues with your code, we read the current setting and reset it to what it was before when we're done.

if device.batteryState == .full || device.batteryState >= .charging(75) {
  print("Your battery is happy! 😊")
}

Get the Current Battery Level

if device.batteryLevel >= 50 {
  install_iOS()
} else {
  showError()
}

Get Low Power mode status

if device.batteryState.lowPowerMode {
  print("Low Power mode is enabled! 🔋")
} else {
  print("Low Power mode is disabled! 😊")
}

Check if a Guided Access session is currently active

if device.isGuidedAccessSessionActive {
  print("Guided Access session is currently active")
} else {
  print("No Guided Access session is currently active")
}

Get Screen Brightness

if device.screenBrightness > 50 {
  print("Take care of your eyes!")
}

Get Available Disk Space

if Device.volumeAvailableCapacityForOpportunisticUsage ?? 0 > Int64(1_000_000) {
  // download that nice-to-have huge file
}

if Device.volumeAvailableCapacityForImportantUsage ?? 0 > Int64(1_000) {
  // download that file you really need
}

Source of Information

All model identifiers are taken from the following website: https://www.theiphonewiki.com/wiki/Models or extracted from the simulator app bundled with Xcode.

Contributing

If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue. If you extended the functionality of DeviceKit yourself and want others to use it too, please submit a pull request.

Contributors

The complete list of people who contributed to this project is available here. DeviceKit wouldn't be what it is without you! Thank you very much! 🙏

devicekit's People

Contributors

a-elnajjar avatar bugix avatar chedabob avatar craigsoveritall avatar dearprakash avatar denisenepraunig avatar dennisweissmann avatar dependabot[bot] avatar e-marchand avatar gianpispi avatar guidev avatar karlzeo avatar kingiol avatar kraigwastlund avatar mishagray avatar mumer92 avatar parski avatar phiren avatar piellarda avatar piterwilson avatar robbiet480 avatar s-faychatelard avatar saltylight avatar semty avatar shivahuang avatar somerandomiosdev avatar stevemoser avatar urkman avatar walsht avatar zandor300 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  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

devicekit's Issues

Carthage update issue with XCode 9

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

deployment target is 9.1

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!

Add static var to get all plus devices

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

Cannot build with Carthage

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)

iPad Pro not working?

Weird, tried this on iPad Pro Simulator but it is returning false?
print(Device().isOneOf([Device.iPadPro]))

Xcode 8.3.3 - Swift Language version error

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?

Safer logic in `Device().isPad`

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).

Device.allPhonesIncludingSimulators

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.

Build failure on Carthage due to lack of formatting tools

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.

Get the `Device` as string

Hey,

I would like to store the outcome of print(Device) in a variable. Is that possible?

Best regards

Expand on Simulator Devices

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"))

Installed the pod but what should I import?

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?

xcodebuild: error Scheme DeviceKit-iOS is not currently configured for the build action

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

CocoaPods instruction for Swift 3.0 in README doesn't work

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:inrun'
/Users/dennis/.rvm/gems/ruby-2.3.1/gems/cocoapods-1.1.0.rc.1/lib/cocoapods/command.rb:50:in run' /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:in load' /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:in eval' /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! 🙏

Device's PPI

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.

isZoomed() Not working

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

UserInterfaceIdiom CarPlay problem

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

Pod / Carthage

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!

You don't seem to have a license

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?

Carthage won't build DeviceKit.framework

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

enum for iPad Pro size?

I looked at the code but didn't see anything to differentiate between iPad Pro size.

How do we do this?

Carthage build still not working with version 1.3.3

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.

CarPlay

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!

Crashes when searching for device that doesn't exist

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

Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift.

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 ?

Support for zoomed displays

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!

All devices available everywhere

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?

Needs update for Xcode 7.1 Swift 2.1

Add:
default: self = .Unspecified

Change To:
let batteryLevel = Double(round(100.0 * (UIDevice.currentDevice().batteryLevel * 100.0)) / 100.0) // rounded, with 2 digits precision

"Module compiled with swift 4.0 cannot be imported in swift 3.1" error on build

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.

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.