Post

Replies

Boosts

Views

Activity

Reply to JSONDecoder unable to decode my API
Xcode has the full value, this is just truncated by the inspector. "{"forecast":[{"air_temperature":8.532769775400027,"cloud_coverage":0.9872359037,"relative_humidity":90.86474776,"wind_speed":5.56043127408,"wind_direction":131.1224219363,"wind_speed_description":"Light wind","wind_gust":16.74143199936,"wind_gust_description":"Moderate","coverage_label":"cloudy","datetime":"2022-08-26T00:00:00+12:00","label":"12:00am","duration":1.0,"phase":"night","icon":"cloudy"},{"air_temperature":8.456719970700021,"cloud_coverage":0.9532022476,"precipitation_amount":0.0,"snow_amount":0.0,"relative_humidity":90.19520283,"wind_speed":5.46783980976,"wind_direction":122.6922215381,"wind_speed_description":"Light wind","wind_gust":18.46313724528,"wind_gust_description":"Moderate","coverage_label":"cloudy","precipitation_label":"none","datetime":"2022-08-26T01:00:00+12:00","label":"1:00am","duration":1.0,"phase":"night","icon":"cloudy"},{"air_temperature":8.32317504880001,"cloud_coverage":0.9182502031,"precipitation_amount":0.0,"snow_amount":0.0,"relative_humidity":89.92497325,"wind_speed":5.43"... I know what the API returns and it is valid, and I built the Swift models using a sample JSON and the QuickType.io site so I am pretty sure parsing them should not be an issue. Using your debug code both data and data2 appear to have the same value of "(Foundation.Data?) 66469 Bytes" and the "try decoder.decode" line still crashes with the same error "The data couldn’t be read because it is missing."
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’22
Reply to JSONDecoder unable to decode my API
Ah progress, Maybe the auto generation of the Swift model is at fault. There are optional parts of the JSON which it didn't pick up (sample must of contained them all) and when I used print(error) instead of print(error.localizedDescription) I got a more helpful output keyNotFound(CodingKeys(stringValue: "precipitation_amount", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "forecast", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: "precipitation_amount", intValue: nil) ("precipitation_amount").", underlyingError: nil))
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’22
Reply to No playgrounds work "Could not build Objective-C module 'SwiftUI'"
Well that does seem to have fixed it for me. I had a clean slate with no Playgrounds saved. I created a new one from the App template and it failed as above, so I deleted it. Then I deleted the app via Mission Control (I think that is what it is called, the Expose like view with the randomly sorted application icons, a bit like like iOS), then reinstalled it from the Mac App Store and created another one from the App template, and it works! I did nothing else in-between, not even checking my emails. Fail -> uninstall -> reinstall -> work. A relief, but quite disappointing really.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23
Reply to Does ClaudeAgentConfig support CLAUDE_CODE_USE_BEDROCK AWS_BEARER_TOKEN_BEDROCK
I've put a config.json file into ~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig "awsAuthRefresh": "aws sso login --profile ai", "env": { "AWS_PROFILE": "ai", "AWS_REGION":"ap-southeast-2" "CLAUDE_CODE_USE_BEDROCK":"1", "ANTHROPIC_MODEL":"au.anthropic.claude-sonnet-4-5-20250929-v1:0", "ANTHROPIC_SMALL_FAST_MODEL":"au.anthropic.claude-haiku-4-5-20251001-v1:0", "CLAUDE_CODE_MAX_OUTPUT_TOKENS":"4096", "MAX_THINKING_TOKENS":"1024" } } These are the env vars I use for Claude Code. I'm not sure how that relates to Claude Agent within Xcode or whether it is even possible to use Bedrock from within Xcode.
Feb ’26
Reply to JSONDecoder unable to decode my API
Xcode has the full value, this is just truncated by the inspector. "{"forecast":[{"air_temperature":8.532769775400027,"cloud_coverage":0.9872359037,"relative_humidity":90.86474776,"wind_speed":5.56043127408,"wind_direction":131.1224219363,"wind_speed_description":"Light wind","wind_gust":16.74143199936,"wind_gust_description":"Moderate","coverage_label":"cloudy","datetime":"2022-08-26T00:00:00+12:00","label":"12:00am","duration":1.0,"phase":"night","icon":"cloudy"},{"air_temperature":8.456719970700021,"cloud_coverage":0.9532022476,"precipitation_amount":0.0,"snow_amount":0.0,"relative_humidity":90.19520283,"wind_speed":5.46783980976,"wind_direction":122.6922215381,"wind_speed_description":"Light wind","wind_gust":18.46313724528,"wind_gust_description":"Moderate","coverage_label":"cloudy","precipitation_label":"none","datetime":"2022-08-26T01:00:00+12:00","label":"1:00am","duration":1.0,"phase":"night","icon":"cloudy"},{"air_temperature":8.32317504880001,"cloud_coverage":0.9182502031,"precipitation_amount":0.0,"snow_amount":0.0,"relative_humidity":89.92497325,"wind_speed":5.43"... I know what the API returns and it is valid, and I built the Swift models using a sample JSON and the QuickType.io site so I am pretty sure parsing them should not be an issue. Using your debug code both data and data2 appear to have the same value of "(Foundation.Data?) 66469 Bytes" and the "try decoder.decode" line still crashes with the same error "The data couldn’t be read because it is missing."
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to JSONDecoder unable to decode my API
Ah progress, Maybe the auto generation of the Swift model is at fault. There are optional parts of the JSON which it didn't pick up (sample must of contained them all) and when I used print(error) instead of print(error.localizedDescription) I got a more helpful output keyNotFound(CodingKeys(stringValue: "precipitation_amount", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "forecast", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: "precipitation_amount", intValue: nil) ("precipitation_amount").", underlyingError: nil))
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to SwiftCharts: How to clip data to specific range?
+1 I could trim the data to fit the charts, but I need the interpolation to carry on so that the line curves correctly right up to the edge of the chart using the values that are outside the bounds of the x-axis. .clipped() trims the left side of the chart, but not the right :/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to SwiftUI Charts: Is it possible to have a LineChart with a different color line above certain threshold
You can colour lines with gradients. If you know the min/max of your chart then you can work out what % of that range represents your colour change point and make a gradient the matches. For example, a range of 0 to 10 with anything above 9 being red would mean a gradient with 0 being green, 8.999999 being green, 9 being red.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to No playgrounds work "Could not build Objective-C module 'SwiftUI'"
Well that does seem to have fixed it for me. I had a clean slate with no Playgrounds saved. I created a new one from the App template and it failed as above, so I deleted it. Then I deleted the app via Mission Control (I think that is what it is called, the Expose like view with the randomly sorted application icons, a bit like like iOS), then reinstalled it from the Mac App Store and created another one from the App template, and it works! I did nothing else in-between, not even checking my emails. Fail -> uninstall -> reinstall -> work. A relief, but quite disappointing really.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to Does ClaudeAgentConfig support CLAUDE_CODE_USE_BEDROCK AWS_BEARER_TOKEN_BEDROCK
I've put a config.json file into ~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig "awsAuthRefresh": "aws sso login --profile ai", "env": { "AWS_PROFILE": "ai", "AWS_REGION":"ap-southeast-2" "CLAUDE_CODE_USE_BEDROCK":"1", "ANTHROPIC_MODEL":"au.anthropic.claude-sonnet-4-5-20250929-v1:0", "ANTHROPIC_SMALL_FAST_MODEL":"au.anthropic.claude-haiku-4-5-20251001-v1:0", "CLAUDE_CODE_MAX_OUTPUT_TOKENS":"4096", "MAX_THINKING_TOKENS":"1024" } } These are the env vars I use for Claude Code. I'm not sure how that relates to Claude Agent within Xcode or whether it is even possible to use Bedrock from within Xcode.
Replies
Boosts
Views
Activity
Feb ’26