大家好,
我目前正在开发一个需要使用WeatherKit的iOS应用程序。我已在我的aioutfit3.entitlements文件中添加了必要的权限,如下所示:
<?xml版本="1.0"编码="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist版本="1.0">
<字典>
<键>com.apple.developer.weatherkit</键>
<真实/>
</字典>
尽管如此,当我试图获取天气数据时,该应用程序报告说它找不到授权文件,并特别提到WeatherKit授权缺失。以下是日志输出的一部分:
❌未找到权利文件
📱捆绑ID:com.superhuang.aioutfit3
❌未找到WeatherKit权利
我已确认授权文件在Xcode项目中配置正确,并已尝试清理和重建该项目。然而,这个问题仍然存在。
有人遇到过类似的问题吗?或者有人有可能有助于解决这个问题的建议吗?非常感谢您的帮助!
我希望这个帖子的内容能帮助你在论坛上找到解决方案。如果您需要更多信息或修改,请告诉我!
一些图片
WeatherKit
RSS for tagBring weather information to your apps and services through a wide range of data that can help people stay up to date, safe, and prepared.
Posts under WeatherKit tag
58 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I'm using WeatherKit for my weather app built with SwiftUI. Even though the location is set in an area where the NWS is issuing weather alerts, WeatherKit randomly returns availability.alertAvailability as temporarilyUnavailable or unsupported, and the weatherAlerts is always nil.
Hello fellow developers,
I’m posting this short message because I’m trying to add WeatherKit to my application, but I’m running into a problem.
I have correctly declared my application on Apple’s website under Certificates, IDs & Profiles, and I have checked WeatherKit.
However in Xcode, I do not have the option to add WeatherKit in Signing & Capabilities.
The option doesn’t appear even though I have the Automatically manage signing box checked.
What can I do to resolve this issue?
Thank you for your response.
HI there,
when requesting the daily forecast via the WeatherKit REST API, I found out that under certain circumstances the moon phase full is skipped.
Example from Japan (working):
{
"forecastDaily": {
"name": "DailyForecast",
"metadata": {
"attributionURL": "https://developer.apple.com/weatherkit/data-source-attribution/",
"expireTime": "2024-10-21T15:16:10Z",
"latitude": 35.650,
"longitude": 139.840,
"readTime": "2024-10-21T14:16:10Z",
"reportedTime": "2024-10-21T12:00:37Z",
"units": "m",
"version": 1,
"sourceType": "modeled"
},
"days": [
...,
{
"forecastStart": "2024-10-16T15:00:00Z",
"forecastEnd": "2024-10-17T15:00:00Z",
"conditionCode": "MostlyCloudy",
"maxUvIndex": 4,
"moonPhase": "waxingGibbous",
"moonrise": "2024-10-17T07:47:26Z",
"moonset": "2024-10-16T20:09:01Z",
"precipitationAmount": 0.09,
"precipitationChance": 0.43,
"precipitationType": "rain",
...
"windSpeedMax": 16.03,
},
{
"forecastStart": "2024-10-17T15:00:00Z",
"forecastEnd": "2024-10-18T15:00:00Z",
"conditionCode": "Rain",
"maxUvIndex": 4,
"moonPhase": "full",
"moonrise": "2024-10-18T08:20:34Z",
"moonset": "2024-10-17T21:24:49Z",
"precipitationAmount": 4.83,
"precipitationChance": 0.83,
"precipitationType": "rain",
...
"windSpeedMax": 15.57,
},
{
"forecastStart": "2024-10-18T15:00:00Z",
"forecastEnd": "2024-10-19T15:00:00Z",
"conditionCode": "Drizzle",
"maxUvIndex": 5,
"moonPhase": "waningGibbous",
"moonrise": "2024-10-19T08:58:43Z",
"moonset": "2024-10-18T22:42:03Z",
"precipitationAmount": 3.85,
"precipitationChance": 0.76,
...
"windSpeedMax": 28.81,
},
...
]
}
}
Example from Germany where the fullmoon is skipped:
{
"forecastDaily": {
"name": "DailyForecast",
"metadata": {
"attributionURL": "https://developer.apple.com/weatherkit/data-source-attribution/",
"expireTime": "2024-10-21T15:41:17Z",
"latitude": 47.760,
"longitude": 12.650,
"readTime": "2024-10-21T14:41:17Z",
"reportedTime": "2024-10-21T13:00:37Z",
"units": "m",
"version": 1,
"sourceType": "modeled"
},
"days": [
{
"forecastStart": "2024-10-16T22:00:00Z",
"forecastEnd": "2024-10-17T22:00:00Z",
"conditionCode": "MostlyClear",
"maxUvIndex": 3,
"moonPhase": "waxingGibbous",
"moonrise": "2024-10-17T16:07:30Z",
"moonset": "2024-10-17T05:19:30Z",
"precipitationAmount": 0.0,
...
"windSpeedMax": 8.23,
},
{
"forecastStart": "2024-10-17T22:00:00Z",
"forecastEnd": "2024-10-18T22:00:00Z",
"conditionCode": "Cloudy",
"maxUvIndex": 2,
"moonPhase": "waningGibbous",
"moonrise": "2024-10-18T16:30:22Z",
"moonset": "2024-10-18T06:48:39Z",
"precipitationAmount": 1.17,
...
"windSpeedMax": 8.73,
},
{
"forecastStart": "2024-10-18T22:00:00Z",
"forecastEnd": "2024-10-19T22:00:00Z",
"conditionCode": "Cloudy",
"maxUvIndex": 2,
"moonPhase": "waningGibbous",
"moonrise": "2024-10-19T16:59:14Z",
"moonset": "2024-10-19T08:18:33Z",
"precipitationAmount": 0.02,
...
"windSpeedMax": 7.16,
},
]
}
}
As you can see here https://moon.nasa.gov/moon-observation/daily-moon-guide/?intent=011#1729171951907::0:: and on several other sites specialized on the lunar cycle) on 2024-10-17 should be shown full moon.
I know this error is probably because the forecast starts prior to the full moon phase and ends after it but customers don't care about technicalities. They see that there is a full moon missing and complain to me. And they are right. Can you fix this somehow? For example, if a DailyForecast spans the majority of a full moon this Day is marked as full moon.
Another question: Are you considering providing a moonPhase attribute to the "currentWeather" dataset? That would be the best option. (At least for me :))
My Weather beach app displays the time according to the country in the weather link under iOS 17 but not under IOS 18
NSTimeZone.resetSystemTimeZone() is no longer supported by IOS 18 or it is a bug
I keep getting severe weather warnings in CA but I’m in NY. I have checked my locations and I have no CA weather requests selected. I clicked on the alert and it said it was from weatherkit. How do I make these CA go away for good? Thanks!
Over 1 month ago I was in Los Angles with my iPhone 15 Pro Max running iOS 18.1. Since then, I have returned and am getting weather alerts on a daily basis weather warning despite me NOT having their weather displayed on my iPhone
Hi all
There is a weather alert for Manhattan New York (Coastal Flood Advisory) all weather apps give this info but Weatherkit doesn't include this alert data. Weatherkit api team improved my skill for testing apps with creating random issue...
With the introduction of the Tides app in watchOS 11, users can now view information about tides and swells along the coast. Is this data accessible to developers via WeatherKit?
In the Tides app, the data source for tides and weather is shown as WeatherKit.
Hi there!
The parameter AreaName is not present in the WeatherAlertSummary object received via the API.
But here it is showing up: https://weatherkit.apple.com/alertDetails/index.html?ids=708c32b5-e760-5fb3-9c47-68394e07353a&lang=de-DE&timezone=Europe/Berlin
It worked for a couple of month now and suddenly it disappeared.
I've noticed in the past few weeks that the minutely precipitation values reported by WeatherKit are much bigger than they were before. Specifically I'm referring to WeatherKit.MinuteWeather.precipitationIntensity.
In my app, I convert to mm per hour:
let mmPerHour = $0.precipitationIntensity.converted(to: UnitSpeed.kilometersPerHour).value * 1e6
This has worked perfectly since WeatherKit came out, but now when I look at rainy locations and compare with the built-in Apple Weather app on my phone, it seems that the new values are about 3x what they should be. I have checked this in multiple locations across the USA.
My intuition says this is an inches/cm conversion issue (2.54x). Is this an intentional change in WeatherKit that requires me to update my app, or is this a bug on Apple's end??
Weatherkit service works at some places and doesnt work other places. I have tried via vpn and I can see still working at USA but not working some part of europe
Hello, is there any rough timeframe of when we can expect MonthPrecipitationStatistics to be fully populated with WeatherKit?
averagePrecipitationAmount is being returned. averagePrecipitationProbability and averageSnowfallAmount are not and are always zero.
I did file FB14326506 about this.
A year ago I filed feedback FB13055082 about this and I just realized that it was marked as "works as currently designed". I need help understanding why this is the expected behavior.
For the feedback example I used Nepal, which is +5:45 from GMT.
When the UTC offset is not at an hour interval, the dates returned by DayWeather and HourWeather do not match.
I’ll request weather with a start date of Aug 25 at 12:0:0 AM GMT+5:45 and end date of Sep 3 at 12:0:0 AM GMT+5:45.
The first daily forecast returns a date of Aug 25, 2023 at 12:0:0 AM GMT+5:45, which is what I expect. It's midnight in Nepal and the start of the day. If in my code I call (correct calendar).startOfDay(for: ) I'll also get this same time back.
However, the first hourly forecast returned is for Aug 25, 2023 at 12:45:0 AM GMT+5:45 which is NOT the start of the day in Nepal or the start I asked for. It is 45 minutes off.
How is the hourly data not starting at the time I requested the expected behavior? Especially when the day data does start at the time I requested.
My application engages the following:
Generates and properly displays a selected location with MapKit.
Generates SwiftUI WeatherKit information for a selected MapKit location.
Generates correct Timezone WeatherKit [DayWeather] Sunrise and Sunset times within my timezone using the [ForEach] function.
Generates incorrect Timezone WeatherKit [DayWeather] using the ForEach function, while retrieving Sunrise and Sunset times outside of my timezone.
I modified my MapKit application to locate and retrieve weather information at specified locations. The application correctly illustrates all the weather information views I want to display without issue for a MapKit selected location. One view exception presents itself specific to the [ForEach] function inside a WeatherKit view, which retrieves Sunrise and Sunset information. The retrieved Sunrise and Sunset times for a selected timezone location outside of my identified timezone are not correct. My application does not generate nor apply an incorrect timezone identifier, such as [Europe/Paris] anywhere within the application, but the following view code segment surely hiccups.
The selected timezone location view presents the Sunrise and Sunset time information as an equivalent time within my timezone, displayed in the images below.
The issue happens to be within the view's following ForEach function code:
Text(day.sun.sunrise?.formatted(.dateTime.hour().minute()) ?? "?")
For the moment, I am struggling to discover how to correct the above code to properly display the [Sunrise] and [Sunset] times within a [ForEach] function. I do not know whether this issue happens to be inherent to WeatherKit's ForEach function, but most likely I am not properly applying the code to reflect the selected location's timezone format within the [Text]. I have not found a solution to apply within the [ForEach] function to correct this issue, as the application iterates through the supplied WeatherKit DayWeather information.
I know I can retrieve the correct current TimeZone time for a selected location with the following code:
func main() {
let d = Date()
// Show the [VARIABLE f] as [HOUR / MINUTE] such as [12:23PM]
var f = Date.FormatStyle.dateTime.hour().minute()
print("The [LOCAL TIME ZONE TIME with MAIN] :: \(d.formatted(f))")
f.timeZone = TimeZone(identifier: "Europe/Paris")!
print("The [SELECTED TIME ZONE TIME with MAIN] :: \(d.formatted(f))\n")
}
// Call the function
main()
The above code does not solve my application's issue, because the code simply returns the selected location's current timezone time relative to my current timezone time. So, if my timezone time happens to be 1:40 PM, then the above code generates a timezone time for a selected location, such as Paris to be 9:40 PM. I know a [View] does not respond to the incremental function code, such as stated above.
As a side note :: My application displays the WeatherKit information through a Container and Hosting Controller, where the application's SwiftUI ContentView calls ::
if let dailyForecast {
TestForecastView(dailyForecast: dailyForecast, timezone: timezone)
}
If you have a moment, I appreciate your possible corrective suggestions, which would be very welcome ... :]
Best regards,
jim_k
My TestForecastView Code with the attached generated views follow:
import Foundation
import SwiftUI
import CoreLocation
import WeatherKit
struct TestForecastView: View {
let dailyForecast: Forecast<DayWeather>
let timezone: TimeZone
var body: some View {
Spacer()
.frame(height: 10)
Text("Sunrise Sunset")
.font(.system(size: 24, weight: .bold))
.foregroundStyle(.white)
Text("Ten Day Forecast")
.font(.system(size: 11, weight: .medium))
.foregroundStyle(.white)
Spacer()
.frame(height: 4)
VStack {
ForEach(dailyForecast, id: \.date) { day in
LabeledContent {
HStack(spacing: 20) {
RoundedRectangle(cornerRadius: 10)
.fill(Color.orange.opacity(0.5))
.frame(width: 120, height: 5)
.padding(.leading, 2)
.padding(.trailing, 0)
VStack {
Image(systemName: "sunrise")
.font(.system(size: 24.0, weight: .bold))
.foregroundColor(.yellow)
Text(day.sun.sunrise?.formatted(.dateTime.hour().minute()) ?? "?")
.font(.system(size: 10.0))
}
.frame(width: 50, height: 20)
VStack {
Image(systemName: "sunset")
.font(.system(size: 24.0, weight: .bold))
.foregroundColor(.yellow)
Text(day.sun.sunset?.formatted(.dateTime.hour().minute()) ?? "?")
.font(.system(size: 10.0))
}
.frame(width: 50, height: 20)
Spacer()
.frame(width: 2)
}
} label: {
Text(day.date.localDate(for: timezone))
.frame(width: 80, alignment: .leading)
.padding(.leading, 30)
.padding(.trailing, 0)
}
.frame(width: 380, height: 52)
.background(RoundedRectangle(cornerRadius: 4).fill(LinearGradient(gradient: Gradient(colors: [Color(.systemBlue), Color(.black)]), startPoint: .topLeading, endPoint: .bottomTrailing)).stroke(.black, lineWidth: 6).multilineTextAlignment(.center))
.shadow(color: Color.white.opacity(0.1), radius: 4, x: -2, y: -2)
.shadow(color: Color.white.opacity(0.1), radius: 4, x: 2, y: 2)
}
}
.padding(.top, 20)
.padding(.bottom, 20)
.padding(.leading, 20)
.padding(.trailing, 20)
.contentMargins(.all, 4, for: .scrollContent)
.background(RoundedRectangle(cornerRadius: 10).fill(Color.black.opacity(0.0)).stroke(.gray, lineWidth: 4))
} // End of [var body: some View]
} // End of [struct TestForecastView: View]
My resultant code views ::
Calgary
Paris
Location requested in WeatherService monthlyStatistics() does NOT match the location in the response
We pass a CLLocation to the new WeatherService monthlyStatistics() BUT in the returned metadata the CLLocation data does NOT match what we sent in the request.
For example, send lat -27.1480114 long -109.4273371 in the monthly stat request and get back data for lat -27.148000717163086, long -109.427001953125.
There’s no mention in the documentation of the returned location being “close to” the requested location. If this is working as designed how close are the results allowed to be? In my small sample they seem to be around 45-55 meters away. I’m considering less than 100 meters away to be a match, but don’t know if that’s correct.
Starting in the last week or two the daily forecast returned by weatherkit rest api changed to 9 days instead of 10 days if I don't pass in the dailyStart and dailyEnd paramters.
Now, if I pass in those parameters to get me anything more than 9 days then I get 400 error. 9 days or less works.
Obviously something changed in the api.
Apple, please fix this asap!!!
I am using WeatherKit to display relevant weather information to the User in my App.
I also thought it would be helpful to show any time-sensitive WeatherAlert. I would like to direct the User directly into the system Weather app to get more details/information.
weather://open ... works... Is this a faux-pas? Is there a approved/proper way of doing this?
I know WeatherAlert.detailsURL exists but I figured it may be useful for the User to see all details related to weather right from the source.
I would like to request two enhancements to the Weather app:
Add a Celsius/Fahrenheit conversion option directly on the home page, rather than requiring users to access it through the three-dot menu.
Consider displaying both Celsius and Fahrenheit scales side by side, without requiring users to choose a conversion option(only if its feasible for your team). This would be particularly helpful for users who are familiar with both scales, such as Asians living in America.
Thank you for considering my request!
Hello Apple team,
I would like to request a feature to display the past temperature data (e.g., last 7 days) for each place in the Weather app(Especially past 24 hours of data for any given city ). Just like how it shows future 7-10 days of data. This would allow users to quickly view temperature trends and patterns for users like us to re-member how that day was like,etc,etc.
Please consider adding a 'Past Weather' section or a graph that shows the temperature fluctuations over the past week.
Thank you for considering my request!