Memmy-App / memmy

An Apollo inspired open-source iOS and Android client for Lemmy built with React-Native. Find us on the App Store and Google Play!
GNU Affero General Public License v3.0
548 stars 58 forks source link

[Bug]: Latest version won't start on emulator #863

Closed dsl101 closed 1 year ago

dsl101 commented 1 year ago

Check for open issues

Minimal reproducible example

Download & build the current branch in ios Simulator. On launch, Metro logs:

 ERROR  TypeError: Cannot read property 'username' of undefined

There are several places in the code that reference currentAccount.username, but before login this is undefined and throws errors.

Expected Behavior

Able to log in

Version

main branch

App Store or TestFlight?

TestFlight

iOS Version

16.x

Device

ios Simulator

gkasdorf commented 1 year ago

Let me look now and see if it's the issue I suspect.

gkasdorf commented 1 year ago

Hmm, so I wiped the simulator and tested and things seem to work fine on my end. Can you verify this is still an issue after having set up the environment?

dsl101 commented 1 year ago

I will go from scratch today and document fully. Did you have to log in on Memmy when you started up the simulator?

gkasdorf commented 1 year ago

Yea I had to sign in. I was thinking maybe it was an issue with there not being an account yet, but doesn't seem to be at least on my end. If you have any issues i'll be around on Discord now (been gone for a bit) so we can discuss.

dsl101 commented 1 year ago

OK, here's my rundown. My build env is this:

And the command sequence I used was this:

$ git clone https://github.com/Memmy-App/memmy.git memmy_clean
$ yarn install
$ cd ios && npx pod-install && cd ..
$ npx react-native run-ios

On first run, that last command fails with this error:

2023-07-28 10:13:20.195 xcodebuild[2073:20341] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
** BUILD FAILED **

The following build commands failed:
  PhaseScriptExecution [Expo]\ Configure\ project /Users/davidl/Library/Developer/Xcode/DerivedData/Memmy-aysjeuovkbbejrdsdcedaugpkbxi/Build/Intermediates.noindex/Memmy.build/Debug-iphonesimulator/Memmy.build/Script-107810AFB63196538F89F4BB.sh (in target 'Memmy' from project 'Memmy')
(1 failure)

This appears to be caused by the blank line in ios/.xcode.env, and removing it clears that error. On the second run, the Metro terminal window opens, and the simulator starts up at the Metro home screen:

Simulator Screenshot - iPhone SE (3rd generation) - 2023-07-28 at 10 28 59

Clicking on the localhost link builds the app in the Metro window, which errors with:

 BUNDLE  ./index.js 

 LOG  Running "main" with {"rootTag":31,"initialProps":{}}
 LOG  [CodePush] Checking for update.
 ERROR  TypeError: Cannot read property 'username' of undefined

Simulator Screenshot - iPhone SE (3rd generation) - 2023-07-28 at 10 30 16

This is in Stack.tsx in the root of the project. I put a guard in there, but the error just moved further down the chain, and as you say isn't really the solution anyway.

dsl101 commented 1 year ago

After investigation, this turned out to be probably an expired JWT from a lemmy.world account that was logged in on the simulator. The app should have asked for re-authentication, but didn't. Removing the app from the simulator (clearing data) and relaunching) solved this error. So, I'm closing this and opening one about the JWT instead.