Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/swift-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function build_for_real_device() {
echo "--- :swift: Building for $platform device"
export NSUnbufferedIO=YES
xcodebuild -destination "generic/platform=$platform" \
-scheme wordpress \
-scheme WordPress \
-derivedDataPath DerivedData \
build | xcbeautify
}
Expand Down
20 changes: 10 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let libwordpressFFI: Target = .binaryTarget(name: "libwordpressFFI", path: "targ
#endif

let package = Package(
name: "wordpress",
name: "WordPress",
platforms: [
.iOS(.v13),
.macOS(.v11),
Expand All @@ -23,23 +23,23 @@ let package = Package(
],
products: [
.library(
name: "wordpress-api",
targets: ["wordpress-api"]
name: "WordPressAPI",
targets: ["WordPressAPI"]
)
],
dependencies: [],
targets: [
.target(
name: "wordpress-api",
name: "WordPressAPI",
dependencies: [
.target(name: "wordpress-api-wrapper")
.target(name: "WordPressAPIInternal")
],
path: "native/swift/Sources/wordpress-api"
),
.target(
name: "wordpress-api-wrapper",
name: "WordPressAPIInternal",
dependencies: [
.target(name: "libwordpressFFI")
.target(name: libwordpressFFI.name)
],
path: "native/swift/Sources/wordpress-api-wrapper",
exclude: [
Expand All @@ -48,10 +48,10 @@ let package = Package(
),
libwordpressFFI,
.testTarget(
name: "wordpress-api-tests",
name: "WordPressAPITests",
dependencies: [
.target(name: "wordpress-api"),
.target(name: "libwordpressFFI")
.target(name: "WordPressAPI"),
.target(name: libwordpressFFI.name)
],
path: "native/swift/Tests/wordpress-api"
)
Expand Down
10 changes: 5 additions & 5 deletions native/swift/Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
2479BF832B621CB60014A01D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2479BF822B621CB60014A01D /* ContentView.swift */; };
2479BF852B621CB70014A01D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2479BF842B621CB70014A01D /* Assets.xcassets */; };
2479BF892B621CB70014A01D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2479BF882B621CB70014A01D /* Preview Assets.xcassets */; };
2479BF912B621CCA0014A01D /* wordpress-api in Frameworks */ = {isa = PBXBuildFile; productRef = 2479BF902B621CCA0014A01D /* wordpress-api */; };
2479BF912B621CCA0014A01D /* WordPressAPI in Frameworks */ = {isa = PBXBuildFile; productRef = 2479BF902B621CCA0014A01D /* WordPressAPI */; };
2479BF932B621E9B0014A01D /* UserListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2479BF922B621E9B0014A01D /* UserListViewModel.swift */; };
24A3C32F2BA8F96F00162AD1 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A3C32E2BA8F96F00162AD1 /* LoginView.swift */; };
24A3C3362BAA874C00162AD1 /* LoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24A3C3352BAA874C00162AD1 /* LoginManager.swift */; };
Expand All @@ -34,7 +34,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2479BF912B621CCA0014A01D /* wordpress-api in Frameworks */,
2479BF912B621CCA0014A01D /* WordPressAPI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -97,7 +97,7 @@
);
name = Example;
packageProductDependencies = (
2479BF902B621CCA0014A01D /* wordpress-api */,
2479BF902B621CCA0014A01D /* WordPressAPI */,
);
productName = Example;
productReference = 2479BF7D2B621CB60014A01D /* Example.app */;
Expand Down Expand Up @@ -388,9 +388,9 @@
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
2479BF902B621CCA0014A01D /* wordpress-api */ = {
2479BF902B621CCA0014A01D /* WordPressAPI */ = {
isa = XCSwiftPackageProductDependency;
productName = "wordpress-api";
productName = "WordPressAPI";
};
/* End XCSwiftPackageProductDependency section */
};
Expand Down
2 changes: 1 addition & 1 deletion native/swift/Example/Example/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftUI
import wordpress_api
import WordPressAPI

struct ContentView: View {

Expand Down
2 changes: 1 addition & 1 deletion native/swift/Example/Example/LoginManager.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import wordpress_api_wrapper
import WordPressAPIInternal

class LoginManager: NSObject, ObservableObject {

Expand Down
2 changes: 1 addition & 1 deletion native/swift/Example/Example/LoginView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import SwiftUI
import wordpress_api
import WordPressAPI
import AuthenticationServices

struct LoginView: View {
Expand Down
2 changes: 1 addition & 1 deletion native/swift/Example/Example/UserListViewModel.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import SwiftUI
import wordpress_api
import WordPressAPI

extension SparseUser.ViewContext: Identifiable {}

Expand Down
2 changes: 1 addition & 1 deletion native/swift/Sources/wordpress-api/Endpoints/Users.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import wordpress_api_wrapper
import WordPressAPIInternal

extension SparseUser: Contextual {
public typealias ID = UserId
Expand Down
12 changes: 6 additions & 6 deletions native/swift/Sources/wordpress-api/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// We could export all of them using `@_exported import`, but that probably puts
// us in a position where we need to make major releases due to Rust code changes.

import wordpress_api_wrapper
import WordPressAPIInternal

public typealias WpApiError = wordpress_api_wrapper.WpApiError
public typealias WpApiError = WordPressAPIInternal.WpApiError

// MARK: - Users

public typealias SparseUser = wordpress_api_wrapper.SparseUser
public typealias UserWithViewContext = wordpress_api_wrapper.UserWithViewContext
public typealias UserWithEditContext = wordpress_api_wrapper.UserWithEditContext
public typealias UserWithEmbedContext = wordpress_api_wrapper.UserWithEmbedContext
public typealias SparseUser = WordPressAPIInternal.SparseUser
public typealias UserWithViewContext = WordPressAPIInternal.UserWithViewContext
public typealias UserWithEditContext = WordPressAPIInternal.UserWithEditContext
public typealias UserWithEmbedContext = WordPressAPIInternal.UserWithEmbedContext
6 changes: 3 additions & 3 deletions native/swift/Sources/wordpress-api/Login/API+Login.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import wordpress_api_wrapper
import WordPressAPIInternal

#if canImport(FoundationNetworking)
import FoundationNetworking
Expand All @@ -11,11 +11,11 @@ public extension WordPressAPI {
let ephemeralClient = WordPressAPI(urlSession: session, baseUrl: url, authenticationStategy: .none)
let response = try await ephemeralClient.perform(request: request)

return wordpress_api_wrapper.getLinkHeader(response: response, name: "https://api.w.org/")?.asUrl()
return WordPressAPIInternal.getLinkHeader(response: response, name: "https://api.w.org/")?.asUrl()
}

func getRestAPICapabilities(forApiRoot url: URL, using session: URLSession) async throws -> WpapiDetails {
let wpResponse = try await self.perform(request: WpNetworkRequest(method: .get, url: url, headerMap: [:]))
return try wordpress_api_wrapper.parseApiDetailsResponse(response: wpResponse)
return try WordPressAPIInternal.parseApiDetailsResponse(response: wpResponse)
}
}
18 changes: 9 additions & 9 deletions native/swift/Sources/wordpress-api/Namespace.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import wordpress_api_wrapper
import WordPressAPIInternal

public protocol Namespace {
associatedtype T
Expand Down Expand Up @@ -51,8 +51,8 @@ public protocol ContextualNamespace: Namespace where T: Contextual {

var context: WpContext { get }

func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> R
func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> [R]
func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> R
func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> [R]
}

public struct ViewNamespace<T: Contextual>: ContextualNamespace {
Expand All @@ -63,11 +63,11 @@ public struct ViewNamespace<T: Contextual>: ContextualNamespace {
parent.api
}

public func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> T.ViewContext {
public func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> T.ViewContext {
try T.parseResponse(response)
}

public func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> [T.ViewContext] {
public func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> [T.ViewContext] {
try T.parseResponse(response)
}
}
Expand All @@ -80,11 +80,11 @@ public struct EditNamespace<T: Contextual>: ContextualNamespace {
parent.api
}

public func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> T.EditContext {
public func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> T.EditContext {
try T.parseResponse(response)
}

public func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> [T.EditContext] {
public func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> [T.EditContext] {
try T.parseResponse(response)
}
}
Expand All @@ -97,11 +97,11 @@ public struct EmbedNamespace<T: Contextual>: ContextualNamespace {
parent.api
}

public func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> T.EmbedContext {
public func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> T.EmbedContext {
try T.parseResponse(response)
}

public func parseResponse(_ response: wordpress_api_wrapper.WpNetworkResponse) throws -> [T.EmbedContext] {
public func parseResponse(_ response: WordPressAPIInternal.WpNetworkResponse) throws -> [T.EmbedContext] {
try T.parseResponse(response)
}
}
Expand Down
4 changes: 2 additions & 2 deletions native/swift/Sources/wordpress-api/WordPressAPI.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import wordpress_api_wrapper
import WordPressAPIInternal

#if os(Linux)
import FoundationNetworking
Expand Down Expand Up @@ -71,7 +71,7 @@ public struct WordPressAPI {
}

public static func extractLoginDetails(from url: URL) -> WpapiApplicationPasswordDetails? {
return wordpress_api_wrapper.extractLoginDetailsFromUrl(url: url.asRestUrl())
return WordPressAPIInternal.extractLoginDetailsFromUrl(url: url.asRestUrl())
}
}

Expand Down
4 changes: 2 additions & 2 deletions native/swift/Tests/wordpress-api/WordPressAPITests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest
import Foundation
import wordpress_api
import wordpress_api_wrapper
import WordPressAPI
import WordPressAPIInternal

final class WordPressAPITests: XCTestCase {

Expand Down
2 changes: 1 addition & 1 deletion scripts/xcodebuild-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ device_id=$(xcrun simctl list --json devices available | jq -re ".devices.\"com.
export NSUnbufferedIO=YES

xcodebuild \
-scheme wordpress \
-scheme WordPress \
-derivedDataPath DerivedData \
-destination "id=${device_id}" \
test \
Expand Down