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
5 changes: 5 additions & 0 deletions .nx/version-plans/version-plan-1792418983966.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
__default__: patch
---

Use @react-native-harness/ui in iOS apps built with React Native SwiftPM integration without a local package patch.
40 changes: 40 additions & 0 deletions packages/ui/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// swift-tools-version: 6.0

import PackageDescription

// React Native resolves these dependencies from
// build/generated/autolinking/libs/HarnessUI in the app's iOS directory.
let package = Package(
name: "HarnessUI",
platforms: [.iOS("15.1")],
products: [
.library(name: "HarnessUI", targets: ["HarnessUI"]),
],
dependencies: [
.package(name: "ReactNative", path: "../../../../xcframeworks"),
.package(name: "React-GeneratedCode", path: "../../../ios"),
],
targets: [
.target(
name: "HarnessUI",
dependencies: [
.product(name: "ReactHeaders", package: "ReactNative"),
.product(name: "ReactNativeHeaders", package: "ReactNative"),
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
.product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
],
path: "ios",
publicHeadersPath: ".",
cxxSettings: [
.define("DEBUG", .when(configuration: .debug)),
.define("NDEBUG", .when(configuration: .release)),
],
linkerSettings: [
.linkedFramework("UIKit"),
.linkedFramework("Foundation"),
.linkedFramework("CoreGraphics"),
]
),
],
cxxLanguageStandard: .cxx20
)
7 changes: 7 additions & 0 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ pnpm add @react-native-harness/ui
yarn add @react-native-harness/ui
```

### iOS with Swift Package Manager

For apps using React Native's SwiftPM integration, run `npx react-native spm` from
the app directory after installing this package. The package includes the
`HarnessUI` SwiftPM manifest and autolinking metadata; no local manifest patch is
needed. Apps using CocoaPods can continue to use `pod install`.

## Usage

Import the UI testing utilities in your test files:
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/ios/HarnessUI.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <HarnessUISpec/HarnessUISpec.h>

@interface HarnessUI : NSObject <NativeHarnessUISpec>
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dist",
"android",
"ios",
"Package.swift",
"*.podspec",
"react-native.config.js",
"!ios/build",
Expand Down Expand Up @@ -52,6 +53,9 @@
"javaPackageName": "com.harnessui"
}
},
"swiftpmConfig": {
"name": "HarnessUI"
},
"author": {
"name": "Szymon Chmal",
"email": "szymon.chmal@callstack.com"
Expand Down
2 changes: 2 additions & 0 deletions website/src/docs/guides/ui-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ To enable UI testing in your project, install the UI testing package:

<PackageManagerTabs command="install --save-dev @react-native-harness/ui" />

On iOS, resolve native dependencies before rebuilding. For apps using React Native's SwiftPM integration, run `npx react-native spm` from the app directory. `@react-native-harness/ui` ships its own `HarnessUI` package manifest and autolinking metadata. For CocoaPods apps, run `pod install` in the iOS directory.

After installation, **rebuild your app** since this package contains native code that needs to be compiled and linked.

## Screen API
Expand Down
Loading