Hi! I'm working with a new workflow in Xcode Cloud. The workflow basically edits the Info.plist file to increase the build number and then sends the new version to TestFlight. The workflow works fine, but after editing and sending the file, I want to save the Info.plist file with the new version and create a new commit automatically. Is this possible? I can't find any documentation about it.
Any information would be greatly appreciated! Thanks!
Post
Replies
Boosts
Views
Activity
Hi, I am trying to create a function that when passed a URL containing a JSON file and a list of names, it returns me some structure.
I have created (with help) the function that returns all the values of the JSON without problem, but I am having problems filtering them and only returning those that are in the array.
let urlString = "https://jsonplaceholder.typicode.com/users"
let arrayInput = ["Leanne Graham",
"Nicholas Runolfsdottir V"]
This is what I use for the function that returns all data:
struct WelcomeElement: Codable {
let name: String?
let username: String?
let email: String?
}
typealias Datos = [WelcomeElement]
class UserItems {
var purchases = [WelcomeElement]()
func loadData(urlString: String, completion: @escaping (Datos) - Void) {
let url = URL(string: urlString)!
URLSession.shared.dataTask(with: url) { data, _, error in
if let error = error as NSError?, error.domain == NSURLErrorDomain, error.code == NSURLErrorNotConnectedToInternet {
print("Not connected")
}
do {
let items = try JSONDecoder().decode([WelcomeElement].self, from: data!)
self.purchases = items
completion(items)
} catch {
print(error)
}
}.resume()
}
}
And this is the function that I have created to return certain values but I get an error and I don't know if it is well handled.
class UserItems {
var purchases = [WelcomeElement]()
var purchases_new = [WelcomeElement]()
func loadData(urlString: String, arrayInput: ArrayString, completion: @escaping (Datos) - Void) {
let url = URL(string: urlString)!
URLSession.shared.dataTask(with: url) { data, _, error in
if let error = error as NSError?, error.domain == NSURLErrorDomain, error.code == NSURLErrorNotConnectedToInternet {
print("Not connected")
}
do {
let items = try JSONDecoder().decode([WelcomeElement].self, from: data!)
for position in 0...items.count-1 {
for a in arrayInput {
if a == items[position].name {
print(items[position])
self.purchases_new = items[position] // Cannot assign value of type 'WelcomeElement' to type '[WelcomeElement]'
}
}
}
self.purchases_new = items
completion(items)
} catch {
print(error)
}
}.resume()
}
}
Surely there is a more efficient way to find the value of the array in the json but that was the only thing that occurred to me.
This function, I use it to create a table with the structure.
Any help is welcome, thank you!
Hello. I am trying to show an image for a short time, in an animated way, and hidden again.
This is the function:
@IBOutlet var statusField: UIImageView!
@IBAction func debugbutton(_ sender: UIButton) {
showIcon()
}
override func viewDidLoad() {
super.viewDidLoad()
statusField.isHidden = true
func showIcon() {
statusField.isHidden = false
UIView.animate(withDuration: 1, delay: 0.5, options: UIView.AnimationOptions.transitionFlipFromTop, animations: {
self.statusField.alpha = 0
}, completion: { finished in
self.statusField.isHidden = true
})
}
When I run the function for the first time it works fine but then it stops doing it. The icon is no longer displayed. Any advice on what's going on?
Thanks!
I am learning Swift to develop macOS applications and I ran into a problem. I am trying to get certain data from a JSON from the internet. I have managed to get such data and put it in simple text labels in the view but when I run Xcode and get the values, if the values from the JSON get updated, I can't see it reflected in my app. I know that I must perform a function to refresh the data but what I have always found is the function to refresh the data that is in a table, not a simple text label. So, basically to summarize, I get the values of the json file from url but if those values are updated, my app does not show them.
Values.swift
import Foundation
struct WelcomeElement: Codable {
let link: String?
let state: String?
let editable: Bool?
let type, name: String?
let groupNames: [String]?
let label, category: String?
let members: [JSONAny]?
let groupType: String?
}
typealias Datos = [WelcomeElement]
class UserItems {
func loadData(completion: @escaping (Datos) - Void) {
let url = URL(string: "http://192.168.0.15:8080/json")!
URLSession.shared.dataTask(with: url) { data, _, error in
if let error = error { print(error); return }
do {
let items = try JSONDecoder().decode([WelcomeElement].self, from: data!)
completion(items)
} catch {
print(error)
}
}.resume()
}
}
ViewController.swift
import Cocoa
class ViewController: NSViewController, NSTextFieldDelegate {
let userItems = UserItems()
@IBOutlet var itemSalida: NSTextField!
override func viewDidLoad() {
super.viewDidLoad()
userItems.loadData { users in
print(users)
if let position = users.firstIndex(where: { $0.name == "test2" }) {
DispatchQueue.main.async {
print(users[position].state!)
self.itemSalida.stringValue = users[position].state ?? "na"
}
}
}
}
}
A sample of the json in the url:
{
"link": "null",
"state": "NULL",
"editable": false,
"type": "String",
"name": "m",
"tags": [],
"groupNames": []
},
{
"link": "test1",
"state": "-1",
"stateDescription": {
"pattern": "%d",
"options": []
},
"editable": true,
"type": "Number",
"name": "test2",
"label": "Current",
"category": "",
"tags": [
"Point"
],
"groupNames": []
}
Any help will help me! Thanks!