sxg / forecastio Goto Github PK
View Code? Open in Web Editor NEWA Swift library for the Forecast.io Dark Sky API
License: MIT License
A Swift library for the Forecast.io Dark Sky API
License: MIT License
Copied from an email to forecast.io registered accounts:
First, we’re consolidating our branding under the Dark Sky name, getting rid of Forecast.io entirely. We’ve found that people often don’t realize the two are related, and this causes a lot of confusion.
This means a few things for you as a developer:
- The developer portal is now https://darksky.net/dev/.
- The attribution requirement of the Terms of Service have changed. Attribution should:
- Display “Powered by Dark Sky”
- Link to https://darksky.net/poweredby/.
- Please make this change at your earliest convenience!
- The API endpoint has changed from https://api.forecast.io/ to https://api.darksky.net/.
pod lib lint
is currently commented out, but it should be added to .travis.yml.
In Swift 3.3 .
sometime got error ,because Unable to bridge NSNumber to Float Swift 3.3.
latitude = json["latitude"] as! Float
you should fix like this
The UK
units are deprecated in favor of UK2
, and offset
on Forecast
is also deprecated. Remove these and other deprecated properties in v3.0.
/// A class to interact with the Dark Sky API.
open class APIClient : NSObject {
APIClient.swift:12:1: Expressions are not allowed at the top level
APIClient.swift:12:5: Consecutive statements on a line must be separated by ';'
APIClient.swift:12:1: Ambiguous use of 'open'
I was able to compile replacing the instances of "open" with "public".
(Xcode 8 beta 5, iOS 10, Swift 3)
Hello,
I'm getting following error as I installed ForecastIO pod:
/---/---/ForecastViewController.swift:10:8: Module file was created by an older version of the compiler; rebuild 'ForecastIO' and try again: /---/---/Library/Developer/Xcode/DerivedData/SwiftyWeather-fcvyupiaiunpivcfwaqvzlakstdf/Build/Products/Debug-iphonesimulator/ForecastIO.framework/Modules/ForecastIO.swiftmodule/x86_64.swiftmodule
Any clue?
AlamoFire does this. It's cleaner than having optional values and optional errors.
This reduces the file size of APIClient.swift and will not be a breaking change.
Everything about the API and ForecastIO is working well, except having trouble with getting the metadata for the apiRequestsCount and responseTime. Not sure if the issue is in my code, in ForecastIO, or in the DarkSky API
My code:
self.client.getForecast(latitude: lat, longitude: lon, excludeFields: [.alerts, .daily, .flags, .minutely]) { result in
switch result {
case .success(let currentForecast, let requestMetadata):
// We got the current forecast!
if let currentFeelsTemperature: Double = currentForecast.currently?.temperature {
print(currentFeelsTemperature)
DispatchQueue.main.async {
self.feelsLikeTmpLbl.text = String(Int(round(currentFeelsTemperature)))
}
}
if let summaryInfo: String = currentForecast.currently?.summary {
print(summaryInfo)
DispatchQueue.main.async {
self.summaryLbl.text = summaryInfo
}
}
print(requestMetadata)
case .failure(let error):
// Uh-oh. We have an error!
print(error)
}
}
Returns:
RequestMetadata(cacheControl: Optional("max-age=3600"), apiRequestsCount: nil, responseTime: nil)
Are there instructions on how to install all of the dependencies without using Pods?
I am getting error:
Library not loaded: @rpath/ForecastIO.framework/ForecastIO
Thanks.
All numeric non-time properties of DataPoint
have error properties associated with them. These need to be implemented by the DataPoint
model.
I'm getting a crash at line 35 in Alert.swift
The code assumes that the "expires" property is required, but the documentation says its an optional.
expires optional
The UNIX time at which the alert will expire. (Some alerts sources, unfortunately, do not define expiration time, and in these cases this parameter will not be defined.)
https://darksky.net/dev/docs/response
There is currently an alert with no "expire" property at Whistler, but because alerts are temporary in nature, the I'm sure the repro won't last:
https://api.darksky.net/forecast/[key]/50.1149639,-122.9486474
"alerts": [ { "title": "Snowfall Warning", "regions": [ "Sunshine Coast" ], "severity": "warning", "time": 1486412460, "description": "Bands of snow rotating around a low pressure system off the coast will continue to stream across southern Vancouver Island, the Sunshine Coast and the Lower Mainland today. Snowfall amounts across these regions will vary widely depending on the location and intensity of the individual bands. Local amounts of 5 cm or more are likely. Be prepared to adjust your driving with changing road conditions. Visibility may be suddenly reduced at times in heavy snow. Please continue to monitor alerts and forecasts issued by Environment Canada. To report severe weather, send an email to [email protected] or tweet reports to #BCStorm.", "uri": "https://weather.gc.ca/warnings/report_e.html?bc38" } ]
Manually setting the default units could cause a lot of confusion if (for some reason) Forecast.io ever decides to change the default. The getForecast
method should just make the GET request without specifying the units URL parameter unless the user sets the units
property on APIClient
.
This article explains how Error
works in Swift 3.
The .travis.yml
file is basically just a copy of the AlamoFire one right now. A lot of builds seem to be passing when they shouldn't. This needs to be fixed ASAP.
When the public init(fromJSON json: NSDictionary) (line 68) is called and it attempts to bridge the type NSNumber to Float, it causes a fatal error. I am running it with Swift 4 with iOS 11.3 and Xcode beta 9.3. Has anybody heard of this issue?
How could I get extended hourly forecast (by using extend=hourly option on get-request) for the next seven days using this library?
Basically, it's not only about extended hourly forecast. There is a lot of request options described in API docs (and "extend=hourly" just one of them), so could it be used with this library?
Hello.
Very nice library first of all!
Is there any way to learn the weather for a certain date? Because i have lat and lon but i just want to change the date and not to see what the weather is now!
Thanks a lot :D
How to get weather of 7 up-coming days using your Wrapper library?
As docs says
The Forecast API lets you query for most locations on the globe, and returns:
Current conditions
Minute-by-minute forecasts out to 1 hour (where available)
Hour-by-hour forecasts out to 48 hours
Day-by-day forecasts out to 7 days
We detected yesterday that the library was crashing few hours. After that, we didn't see the crash anymore.
Crashed: NSOperationQueue 0x1740346c0 :: NSOperation 0x174c5d340 (QOS: DEFAULT)
0 ForecastIO 0x1012e710c specialized Forecast.init(fromJSON : NSDictionary) -> Forecast (Forecast.swift:69)
1 ForecastIO 0x1012dd2d0 specialized DarkSkyClient.(getForecast(url : URL, completionHandler : (Result) -> ()) -> ()).(closure #1) (Forecast.swift)
2 ForecastIO 0x1012dd084 partial apply for DarkSkyClient.(getForecast(url : URL, completionHandler : (Result) -> ()) -> ()).(closure #1) (DarkSkyClient.swift)
3 CFNetwork 0x18a7c934c __75-[__NSURLSessionLocal taskForClass:request:uploadFile:bodyData:completion:]_block_invoke + 32
4 CFNetwork 0x18a7e1048 __49-[__NSCFLocalSessionTask _task_onqueue_didFinish]_block_invoke + 148
5 Foundation 0x18ac8e854 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 16
6 Foundation 0x18abd37b0 -[NSBlockOperation main] + 96
7 Foundation 0x18abc3b68 -[__NSOperationInternal _start:] + 612
8 Foundation 0x18ac90bf0 __NSOQSchedule_f + 228
9 libdispatch.dylib 0x1890769a0 _dispatch_client_callout + 16
10 libdispatch.dylib 0x189084ad4 _dispatch_queue_serial_drain + 928
11 libdispatch.dylib 0x18907a2cc _dispatch_queue_invoke + 884
12 libdispatch.dylib 0x189086a50 _dispatch_root_queue_drain + 540
13 libdispatch.dylib 0x1890867d0 _dispatch_worker_thread3 + 124
14 libsystem_pthread.dylib 0x18927f100 _pthread_wqthread + 1096
15 libsystem_pthread.dylib 0x18927ecac start_wqthread + 4
It's close, but there's still a little more to do.
Is there a way to pass in our Decodable object so that when the JSON returns in the response, it can be decoded into our custom data model?
For example, the ForecastField
enum should really be namespaced under the Forecast
struct. There's no reason for these to be global.
In using the sample project i'm receiving an interesting console message:
invalidJSON(10 bytes)
I verified my trial key works based on the sample link in the darksky console. Any thoughts as to what this is?
Receiving this error after running 'carthage update'
I've also seen other resolved issues in the carthage repo that require you to remove the CarthageKit folder from Library/Cache but I've already tried that.
Cartfile:
github "sxg/ForecastIO" "swift3"
A shell task (/usr/bin/xcrun xcodebuild -workspace /Users/tylermrolfe/Developer/Fake Name/Carthage/Checkouts/ForecastIO/ForecastIO.xcworkspace -scheme "Pods-ForecastIO OS X Tests-ForecastIO" -configuration Release CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean -showBuildSettings) failed with exit code 66:
xcodebuild: error: Scheme Pods-ForecastIO OS X Tests-ForecastIO is not currently configured for the clean action.
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.