How to Build mushroom-observer-mobile for iPhone and Android #70
mo-nathan
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Pre-requisites
This section depends on the operating system of the computer you plan on working on.
Download Build Environments: MacOSX iPhone
xcode-select --install
into the Terminal window to install the Xcode command line tools.Download Build Environment: Android
Create Your Local mushroom-observer-mobile Code Repo
If you are an experienced GitHub user you can just clone the public repo with:
git clone [email protected]:MushroomObserver/mushroom-observer-mobile.git
and go to the next section.Otherwise, if you are using Xcode you can do the following:
git
has been installed. You can do that in your Terminal window with the commandgit --version
. It should respond with something likegit version 2.39.3 (Apple Git-145)
. There version of git should not matter.If you are not using Xcode, go to https://github.com and sign up for an account. You will need to install some sort of local
git
client. Many IDEs support git and there is an easy to use command line version that may already be on your system. You will need to setup an SSH key in GitHub which is discussed on the GitHub website. Once you have the account and local access to git you will want to clone the MushroomObserver/mushroom-observer-mobile repository. Again from the command line the command is:git clone [email protected]:MushroomObserver/mushroom-observer-mobile.git
Getting the Right Version of Node Installed
First install the latest version of Node.js. On a Mac I recommend using Homebrew for this. On other systems there may be other package managers you want to use for this. You can also download it from the Node.js website (https://nodejs.org/en/download). The downside of downloading it yourself is maintaining it can be more of pain.
To install Node using Homebrew:
cd ~/mushroom-observer-mobile
.brew install node
.echo 'eval $($HOMEBREW_PREFIX/bin/brew shellenv)' >> ~/.zprofile
.which node
andwhich npm
return something.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
.nvm list
. This should give you something like:cd ~/mushroom-observer-mobile
) install version 16.20.2 withnvm install 16.20.2
. Now runningnvm list
should give you something like:cd ~/mushroom-observer-mobile
. Now runnpm install
. You should see some deprecation warnings, some vulnerability warnings, and a recommendation to upgrade npm. Don't worry about any of those.Setting Up Your .env Files
cp .env.template .env.production; cp .env.template .en.development
. You need the .env.production to support a current "Run pre-action" in Xcode which should probably not be what it is. (To find this, after loading MushroomObserver.xcworkspace I had to click on the Mushroom Observer drop down in the top bar, select "Edit Scheme...", expand "Build" on the left side of Edit Scheme dialog, and click "Pre actions".)MUSHROOM_OBSERVER_API_URL
to behttp://10.0.2.2:3000
. Otherwise, you can usehttps://mushroomobserver.org
to go to the live website.MUSHROOM_OBSERVER_API_KEY
to one you create on your local development server or the live sitemushroom-observer-mobile Setup for the iPhone Build
ios
directory runbundle install --path vendor/bundle
.Both of these commands required
sudo
to run for me, but that might be something weird in how something got setup previously.7. Install cocoapods:
sudo gem install cocoapods
. Takes a while. Address any errors8. Run
pod install
9. From the Finder now open (double-click) on the file "MushroomObserver.xcworkspace". This should be under the mushroom-observer-mobile directory created when you cloned the GitHub repo in the ios subdirectory. I created this directory in my home directory. You should also be able to find it with Spotlight (Cmd-Space, type in the name).
11. Click the triangular arrow button at the top of the window.
12. Currently this fails with the error: "Yoga: Use of bitwise '|' with boolean operands". This is a known issue with the version of the Yoga layout manager we're using when compiled against the latest compiler in Xcode. It should show you the file with the issue and recommend that you replace '|' with '||'. This is the correct fix. This problem should go away when we get to a more recent version of React Native. Make the fix and ensure the file is saved. Click the run arrow again.
13. The next failure is "No template named 'unary_function' in namespace 'std'" in hash.hpp. This is due to another Xcode change. This can be solved by replacing "unary_function" with "__unary_function".
14. The simulator should now launch. It may request access to your working folder for "watchman". Allow this access. Xcode will launch metro in a terminal window.
mushroom-observer-mobile Setup for the Android Build
cd ~/mushroom-observer-mobile
). The runadb reverse tcp:8081 tcp:8081
, followed bynpx react-native start
to create the Metro process. This should allow Android Studio to automatically connect to the Metro process.mkdir android/app/src/main/assets
. Then runreact-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
. Once that's done you should be able to click the run triangle in the top toolbar (next to "app") and it should start up the app for you in your emulated cell phone.You should get to the login screen and be able to see the "Register" page. However, I have not been able to get it to actually talk to the website. I'm thinking it has something to do with the information (keys) in the .env file not getting read.
Beta Was this translation helpful? Give feedback.
All reactions