Я строю новое приложение и пытаюсь использовать новые места Google Swift SDK для iOS. Я следую за этими руководствами, предоставленными Google:
Руководство по настройке Google и руководство по поиску текста Google < /p>
К сожалению, я всегда получаю следующую ошибку: < /p>
< ul>
Места извлечения ошибок: внутренняя ошибка < /li>
Информация об ошибке: внутренняя («внутренняя ошибка») < /li>
Код ошибки: 2 < /li>
Ошибка домен: GooglePlacessWift.placeserror < /li>
Информация пользователя: [:] < /li>
< /ul>
Основные части моего кода выглядят так и настраиваются в проекте приложения Apple: < /p>
// my content view
import SwiftUI
import GooglePlacesSwift
@main
struct MyApp: App {
init() {
PlacesClient.provideAPIKey("my API key")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
< /code>
// my google file
import Foundation
import SwiftUI
import CoreLocation
import GooglePlacesSwift
func searchForPizzaInNewYork() async {
// Define the bounds for New York City
guard let region = RectangularCoordinateRegion(
northEast: CLLocationCoordinate2D(latitude: 20, longitude: 30),
southWest: CLLocationCoordinate2D(latitude: 40, longitude: 50)
) else {
print("Failed to create region.")
return
}
// Create a SearchByTextRequest with the desired parameters
let searchByTextRequest = SearchByTextRequest(
textQuery: "pizza",
placeProperties: [.placeID],
locationBias: region,
includedType: .restaurant,
maxResultCount: 2,
isStrictTypeFiltering: true
)
// Perform the search
switch await PlacesClient.shared.searchByText(with: searchByTextRequest) {
case .success(let places):
// Handle the places retrieved
for place in places {
if let placeID = place.placeID {
print("Place ID: \(placeID)")
}
}
case .failure(let placesError):
// Handle the error with detailed feedback
print("Error fetching places: \(placesError.localizedDescription)")
// Print additional details if available
print("Error details: \(placesError)")
if let nsError = placesError as NSError? {
print("Error code: \(nsError.code)")
print("Error domain: \(nsError.domain)")
print("User info: \(nsError.userInfo)")
}
}
}
< /code>
// my view
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
Button(action: {
Task {
await searchForPizzaInNewYork()
}
}) {
Text("Search for Pizza in New York")
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding()
}
.padding()
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... rnal-error
Новый Google помещает Swift SDK для iOS только для внутренней ошибки ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как получить максимально доступный размер внутренней высоты и внутренней ширины окна?
Anonymous » » в форуме Javascript - 0 Ответы
- 26 Просмотры
-
Последнее сообщение Anonymous
-