bitkit icon indicating copy to clipboard operation
bitkit copied to clipboard

build: regtest app variant

Open ovitrif opened this issue 1 year ago • 9 comments

Description

This PR adds support to build an app variant having regtest as default bitcoin network.

Aside to the default network, the regtest variant has:

  • a different name: Bitkit Regtest
  • a different id:
    • Android: to.synonym.bitkit.wallet.regtest
    • iOS to.synonym.bitkit.regtest
  • a monochrome icon

Considerations

  • It is expected have a .env.production file with the corresponding configurations.

To Test

1️⃣ Regtest Android

  1. Run yarn regtest:set
  2. Run yarn bundle:regtest
  3. Run yarn regtest:unset
  4. Install the app on an emulator
  5. Expect to have the app Bitkit Regtest installed with the default Bitcoin Network Regtest.

2️⃣ Mainnet Android

  1. Run yarn bundle then install the app
  2. Install the app
  3. Expect to have the app Bitkit installed with the default Bitcoin Network Mainnet.

3️⃣ Regtest iOS

  1. Run yarn regtest:set
  2. Open the workspace in Xcode, switch to the bitkit.regtest scheme

    Note (maybe optional if building via Xcode) Additional 1-time setup is required as described in this medium post

    • need to register the new bundle id, get certificates, etc
    • also might need to create a separate app in TestFlight App Store Connect
  3. Build the app for release
  4. Expect to have the app Bitkit Regtest installed with the default Bitcoin Network Regtest.
  5. Run yarn regtest:unset

2️⃣ Mainnet iOS

  1. Close Xcode, run yarn clean, reopen project and switch to bitkit scheme
  2. Build the app for release
  3. Expect to have the app Bitkit installed with the default Bitcoin Network Mainnet.

➕ Other configurations

  • Ensure yarn start can still run build and run the app on Android / iOS
  • Ensure yarn android & yarn ios still works

Linked Issues/Tasks

https://app.asana.com/0/0/1205821036778041/f

Type of change

  • [x] Refactoring (improving code without creating new functionality)

Tests

  • [x] No test

Screenshot / Video

N/a - build setup.

QA Notes

N/a - build setup.

ovitrif avatar Jan 04 '24 20:01 ovitrif

Just making sure that normal development workflow works as expected and seems to be the case 👍

pwltr avatar Jan 04 '24 20:01 pwltr

Followed instructions and Android is working for me, when building for iOS I get:

Unable to load contents of file list: '/Users/phil/Dev/synonymdev/bitkit/ios/Pods/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks-Debug.Regtest-input-files.xcfilelist'

@ovitrif Any ideas? Could have to do with the regtest assets

pwltr avatar Jan 08 '24 14:01 pwltr

Followed instructions and Android is working for me, when building for iOS I get:

Unable to load contents of file list: '/Users/phil/Dev/synonymdev/bitkit/ios/Pods/Target Support Files/Pods-bitkit/Pods-bitkit-frameworks-Debug.Regtest-input-files.xcfilelist'

@ovitrif Any ideas? Could have to do with the regtest assets

@pwltr Can you try a yarn clean:ios beforehand? 🤔

Honestly I'm not sure which one of the commands have fixed it in my case, but I do recall having to resolve the same issue.

clean:ios seems to tap into the iOS dependencies, but it might have bean clean itself.

Xcode build issues feel very unstable to me, for example I couldn't get the app to build via Xcode for 2 days, then randomly it started to work 🤷🏻

ovitrif avatar Jan 08 '24 14:01 ovitrif

@pwltr Can you try a yarn clean:ios beforehand? 🤔

Yeah that works! Should have known 🤷‍♂️. It's stuck on the splash screen now though:

No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
*** Terminating app due to uncaught exception 'RCTFatalException: No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.', reason: 'No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000180491128 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018008412c objc_exception_throw + 56
	2   Bitkit Regtest                      0x0000000104b03d10 RCTGetFatalHandler + 0
	3   Bitkit Regtest                      0x0000000104b19ea4 __28-[RCTCxxBridge handleError:]_block_invoke + 516
	4   libdispatch.dylib                   0x0000000107c200f0 _dispatch_call_block_and_release + 24
	5   libdispatch.dylib                   0x0000000107c2193c _dispatch_client_callout + 16
	6   libdispatch.dylib                   0x0000000107c315e4 _dispatch_main_queue_drain + 1228
	7   libdispatch.dylib                   0x0000000107c31108 _dispatch_main_queue_callback_4CF + 40
	8   CoreFoundation                      0x00000001803f1a30 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
	9   CoreFoundation                      0x00000001803ec148 __CFRunLoopRun + 1936
	10  CoreFoundation                      0x00000001803eb5a4 CFRunLoopRunSpecific + 572
	11  GraphicsServices                    0x000000018e9fbae4 GSEventRunModal + 160
	12  UIKitCore                           0x00000001852f02e4 -[UIApplication _run] + 868
	13  UIKitCore                           0x00000001852f3f5c UIApplicationMain + 124
	14  Bitkit Regtest                      0x000000010494c74c main + 96
	15  dyld                                0x0000000106aa1544 start_sim + 20
	16  ???                                 0x0000000106bb20e0 0x0 + 4407894240
	17  ???                                 0x2962000000000000 0x0 + 2981945903272689664
)
libc++abi: terminating due to uncaught exception of type NSException

Xcode build issues feel very unstable to me, for example I couldn't get the app to build via Xcode for 2 days, then randomly it started to work 🤷🏻

I doubt this was the issue in your case but I find myself having to delete ios/.xcode.env.local often times.

pwltr avatar Jan 08 '24 14:01 pwltr

Yeah that works! Should have known 🤷‍♂️. It's stuck on the splash screen now though:

No bundle URL present.

Thank you @pwltr for testing and sharing this.

I tried again in a fresh clone and I got the same issue when running the bitkit.regtest scheme via Xcode.

The thing is, this won't work anyways to set the default network to regtest, because it takes configuration from .env.development. But I do agree for testing purposes it makes sense to be able to actually run the regtest app, not only install it.

After a lot of trial & error, I found a fix that got it working for me.


It's important mention that the release configuration works differently, and I can't test it given I don't have the certificates, so I personally can't tell for sure if it will work right.

I'd really appreciate if @Jasonvdb could check if the setup works for iOS Regtest.Release, since that's the main problem the PR is trying to solve.

ovitrif avatar Jan 10 '24 20:01 ovitrif

Note: if we can't get the current setup to work for iOS release builds, this might be an alternative, though it would take some time to set-up fastlane:

ovitrif avatar Jan 16 '24 12:01 ovitrif

Updated with:

  • rebase on master d62e7a2d
  • squash into 2 commits:
    1. Android build
    2. iOS build

ovitrif avatar Jan 30 '24 17:01 ovitrif

Put on hold until we can build iOS releases using the self-hosted build machine. This way it will enable me to troubleshoot and verify it on iOS as well

ovitrif avatar Feb 13 '24 12:02 ovitrif

@Jasonvdb I revisited this changeset and made the setup much simpler, also now I'm pretty sure the iOS regtest app should build correctly.

I also updated the testing steps in PR description as well as build instructions for regtest app in BUILD.md.

Happy to get your feedback when you can check this again 🙏🏻

ovitrif avatar Feb 28 '24 18:02 ovitrif

Closing this for now, given it's stale for a long time. We can always reopen if we reassess its priority.

ovitrif avatar Apr 30 '24 18:04 ovitrif