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
4 changes: 4 additions & 0 deletions .buildkite/basic/react-native-android-full-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we drop 0.72 from the matrix yet? I can't remember what the decision was on the support matrix, but 0.76 is now unsupported by react native.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can drop 0.72 - our test matrix policy is the latest 3 versions, plus even versions back to 0.72

retry:
automatic:
- exit_status: "*"
Expand Down Expand Up @@ -133,6 +134,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"

- label: ':android: Build react-native-navigation {{matrix}} test fixture APK (Old Arch)'
key: "build-react-native-navigation-android-fixture-old-arch"
Expand Down Expand Up @@ -293,6 +295,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"

# current latest version (v7.40.1) of react-native-navigation's autolinking tool doesn't support RN 0.73+,
# causing a build failure - see https://github.com/wix/react-native-navigation/issues/7821
Expand Down Expand Up @@ -335,6 +338,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"

- label: ":bitbar: :android: react-native-navigation {{matrix}} Android 12 (Old Arch) end-to-end tests"
depends_on: "build-react-native-navigation-android-fixture-old-arch"
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/basic/react-native-android-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ steps:
- "bundle install"
- "node scripts/generate-react-native-fixture.js"
matrix:
- "0.78"
- "0.79"
retry:
automatic:
- exit_status: "*"
Expand Down Expand Up @@ -51,7 +51,7 @@ steps:
- exit_status: "*"
limit: 1
matrix:
- "0.78"
- "0.79"

#
# End-to-end tests
Expand Down Expand Up @@ -90,7 +90,7 @@ steps:
concurrency_group: "bitbar"
concurrency_method: eager
matrix:
- "0.78"
- "0.79"

- label: ":bitbar: :android: RN {{matrix}} Android 12 (New Arch) end-to-end tests"
depends_on: "build-react-native-android-fixture-new-arch"
Expand Down Expand Up @@ -126,5 +126,5 @@ steps:
concurrency_group: "bitbar"
concurrency_method: eager
matrix:
- "0.78"
- "0.79"

16 changes: 8 additions & 8 deletions .buildkite/basic/react-native-cli-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ steps:
- "bundle install"
- "bundle exec maze-runner features/build-app-tests/build-android-app.feature"
matrix:
- "0.79"
- "0.78"
- "0.77"
- "0.76"
- "0.75"
retry:
automatic:
- exit_status: "*"
Expand All @@ -54,9 +54,9 @@ steps:
- "bundle install"
- "bundle exec maze-runner features/build-app-tests/build-ios-app.feature"
matrix:
- "0.79"
- "0.78"
- "0.77"
- "0.76"
- "0.75"
retry:
automatic:
- exit_status: "*"
Expand Down Expand Up @@ -92,9 +92,9 @@ steps:
concurrency_group: "browserstack-app"
concurrency_method: eager
matrix:
- "0.79"
- "0.78"
- "0.77"
- "0.76"
- "0.75"

- label: ":browserstack: :mac: RN CLI - {{matrix}} iOS end-to-end tests"
depends_on: "build-react-native-cli-ios-fixture"
Expand Down Expand Up @@ -123,6 +123,6 @@ steps:
concurrency_group: "browserstack-app"
concurrency_method: eager
matrix:
- "0.79"
- "0.78"
- "0.77"
- "0.76"
- "0.75"
4 changes: 4 additions & 0 deletions .buildkite/basic/react-native-ios-full-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"
retry:
automatic:
- exit_status: "*"
Expand Down Expand Up @@ -94,6 +95,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"
retry:
automatic:
- exit_status: "*"
Expand Down Expand Up @@ -254,6 +256,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"

- label: ":bitbar: :mac: RN {{matrix}} iOS (New Arch) end-to-end tests"
depends_on: "build-react-native-ios-fixture-new-arch-full"
Expand Down Expand Up @@ -292,6 +295,7 @@ steps:
- "0.74"
- "0.76"
- "0.77"
- "0.78"

# current latest version (v7.40.1) of react-native-navigation's autolinking tool doesn't currently support RN 0.73+,
# causing a build failure - see https://github.com/wix/react-native-navigation/issues/7821
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/basic/react-native-ios-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ steps:
- "bundle install"
- "node scripts/generate-react-native-fixture.js"
matrix:
- "0.78"
- "0.79"
retry:
automatic:
- exit_status: "*"
Expand All @@ -51,7 +51,7 @@ steps:
- "bundle install"
- "node scripts/generate-react-native-fixture.js"
matrix:
- "0.78"
- "0.79"
retry:
automatic:
- exit_status: "*"
Expand Down Expand Up @@ -92,7 +92,7 @@ steps:
concurrency_group: "bitbar"
concurrency_method: eager
matrix:
- "0.78"
- "0.79"

- label: ":bitbar: :mac: RN {{matrix}} iOS (New Arch) end-to-end tests"
depends_on: "build-react-native-ios-fixture-new-arch"
Expand Down Expand Up @@ -127,5 +127,5 @@ steps:
concurrency_group: "bitbar"
concurrency_method: eager
matrix:
- "0.78"
- "0.79"

5 changes: 4 additions & 1 deletion .buildkite/package_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@
{
"pipeline": ".buildkite/basic/react-native-cli-pipeline.yml",
"block": ".buildkite/block/react-native-cli-pipeline.block.yml",
"paths": []
"paths": [
"test/react-native-cli",
"packages/react-native-cli"
]
Comment on lines +141 to +144
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

},
{
"pipeline": ".buildkite/basic/expo-pipeline.yml",
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]

- (react-native-cli) Update insert command for 0.79 projects [#2410](https://github.com/bugsnag/bugsnag-js/pull/2410)

## [8.3.1] - 2025-04-09

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-cli/src/lib/Insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const COCOA_OBJ_C_APP_LAUNCH_REGEX = /(-\s*\(BOOL\)\s*application:\s*\(UIApplica

const BUGSNAG_COCOA_SWIFT_IMPORT = 'import Bugsnag'
const BUGSNAG_COCOA_SWIFT_INIT = 'Bugsnag.start()'
const COCOA_SWIFT_APP_LAUNCH_REGEX = /(override func application\s*\(\s*_ application:\s*UIApplication,\s*didFinishLaunchingWithOptions launchOptions:\s*\[UIApplication\.LaunchOptionsKey\s*:\s*Any\]\?\s*=\s*nil\)\s*->\s*Bool\s*\{\s)/
const COCOA_SWIFT_APP_LAUNCH_REGEX = /((?:override )?func application\s*\(\s*_\s+application:\s*UIApplication,\s*didFinishLaunchingWithOptions\s+launchOptions:\s*\[UIApplication\.LaunchOptionsKey\s*:?\s*Any\]\?\s*(?:=\s*nil)?\s*\)\s*->\s*Bool\s*\{\s)/

const BUGSNAG_JAVA_IMPORT = 'import com.bugsnag.android.Bugsnag;'
const BUGSNAG_JAVA_INIT = 'Bugsnag.start(this);'
Expand Down
56 changes: 51 additions & 5 deletions packages/react-native-cli/src/lib/__test__/Insert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ test('insertIos(): success', async () => {
)
})

test('insertIos(): success (swift)', async () => {
test('insertIos(): success (swift 0.78)', async () => {
type readdir = (path: string) => Promise<string[]>
const readdirMock = fs.readdir as unknown as jest.MockedFunction<readdir>

readdirMock
.mockResolvedValueOnce(['BugsnagReactNativeCliTest.xcodeproj'])
.mockResolvedValueOnce(['a', 'b', 'AppDelegate.swift', 'c', 'd'])

const appDelegate = await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-before.swift'))
const appDelegate = await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-before-078.swift'))
const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
readFileMock.mockResolvedValue(appDelegate)

Expand All @@ -113,7 +113,31 @@ test('insertIos(): success (swift)', async () => {
expect(readFileMock).toHaveBeenCalledWith('/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift', 'utf8')
expect(writeFileMock).toHaveBeenCalledWith(
'/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift',
await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-after.swift')),
await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-after-078.swift')),
'utf8'
)
})

test('insertIos(): success (swift 0.79+)', async () => {
type readdir = (path: string) => Promise<string[]>
const readdirMock = fs.readdir as unknown as jest.MockedFunction<readdir>

readdirMock
.mockResolvedValueOnce(['BugsnagReactNativeCliTest.xcodeproj'])
.mockResolvedValueOnce(['a', 'b', 'AppDelegate.swift', 'c', 'd'])

const appDelegate = await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-before-079.swift'))
const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
readFileMock.mockResolvedValue(appDelegate)

const writeFileMock = fs.writeFile as jest.MockedFunction<typeof fs.writeFile>
writeFileMock.mockResolvedValue()

await insertIos('/random/path', logger)
expect(readFileMock).toHaveBeenCalledWith('/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift', 'utf8')
expect(writeFileMock).toHaveBeenCalledWith(
'/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift',
await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-after-079.swift')),
'utf8'
)
})
Expand All @@ -140,15 +164,37 @@ test('insertIos(): already present', async () => {
expect(logger.warn).toHaveBeenCalledWith('Bugsnag is already included, skipping')
})

test('insertIos(): already present (swift)', async () => {
test('insertIos(): already present (swift 0.78)', async () => {
type readdir = (path: string) => Promise<string[]>
const readdirMock = fs.readdir as unknown as jest.MockedFunction<readdir>

readdirMock
.mockResolvedValueOnce(['BugsnagReactNativeCliTest.xcodeproj'])
.mockResolvedValueOnce(['a', 'b', 'AppDelegate.swift', 'c', 'd'])

const appDelegate = await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-after-078.swift'))
const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
readFileMock.mockResolvedValue(appDelegate)

const writeFileMock = fs.writeFile as jest.MockedFunction<typeof fs.writeFile>
writeFileMock.mockResolvedValue()

await insertIos('/random/path', logger)
expect(readFileMock).toHaveBeenCalledWith('/random/path/ios/BugsnagReactNativeCliTest/AppDelegate.swift', 'utf8')
expect(writeFileMock).not.toHaveBeenCalled()

expect(logger.warn).toHaveBeenCalledWith('Bugsnag is already included, skipping')
})

test('insertIos(): already present (swift 0.79+)', async () => {
type readdir = (path: string) => Promise<string[]>
const readdirMock = fs.readdir as unknown as jest.MockedFunction<readdir>

readdirMock
.mockResolvedValueOnce(['BugsnagReactNativeCliTest.xcodeproj'])
.mockResolvedValueOnce(['a', 'b', 'AppDelegate.swift', 'c', 'd'])

const appDelegate = await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-after.swift'))
const appDelegate = await loadFixture(path.join(__dirname, 'fixtures', 'AppDelegate-after-079.swift'))
const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
readFileMock.mockResolvedValue(appDelegate)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Bugsnag
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm, this is the only change between these versions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also the Bugsnag.start call on line 18.

The reason we need new before/after fixture files is because the whole AppDelegate.swift template has changed in 0.79 with the introduction of RCTReactNativeFactory

import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
Bugsnag.start()

let delegate = ReactNativeDelegate()
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()

reactNativeDelegate = delegate
reactNativeFactory = factory

window = UIWindow(frame: UIScreen.main.bounds)

factory.startReactNative(
withModuleName: "reactnative",
in: window,
launchOptions: launchOptions
)

return true
}
}

class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}

override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
let delegate = ReactNativeDelegate()
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()

reactNativeDelegate = delegate
reactNativeFactory = factory

window = UIWindow(frame: UIScreen.main.bounds)

factory.startReactNative(
withModuleName: "reactnative",
in: window,
launchOptions: launchOptions
)

return true
}
}

class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}

override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}
Loading