Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CocoaPods near-term followup #4028

Merged
merged 6 commits into from
Apr 10, 2020
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
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ persisted data.

In general most of the work will be inside of the `/src` directory. The only
reason to touch the `/ios` or `/android` directories would be to add native
modules (which we aren't using at the moment).
modules.

### Top-level files
* `package.json` - specifies `yarn` / NPM dependencies and scripts for the project
Expand Down
20 changes: 16 additions & 4 deletions docs/howto/build-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ Native upstream on
You want the tab "React Native CLI Quickstart"; the "Expo CLI Quickstart" does
not apply.

If you're starting with iOS development, be sure to install CocoaPods,
as the guide instructs. After you've done that, run
`cd ios && pod install && cd ..`.
If you're starting with iOS development, be sure to [install
CocoaPods](https://guides.cocoapods.org/using/getting-started.html),
as the guide instructs, then rerun `yarn`.

Continue those instructions until you can run the Zulip Mobile app
with either `react-native run-android` or `react-native run-ios`.
with one of the following:

- `react-native run-android`
- `react-native run-ios`
- in Xcode, if on macOS (see [iOS tips](ios-tips.md))
- in Android Studio (see "Android tips", below)

You'll want to be able to use both an emulator and a physical device; but
for starting out, just get either one working so you can play with the app.

Expand Down Expand Up @@ -499,3 +505,9 @@ Optionally, reset iOS simulator:
```
iOS Menu > Simulator > Reset Content and Settings…
```

If you get other iOS build failures and you haven't changed anything
in the `ios` folder yourself, and you're on the latest version of
Xcode, there might be residue from a previous build interfering in
this one. So, try cleaning the build folder, following the
instructions at [iOS tips](ios-tips.md#clearing-the-build-folder)
22 changes: 18 additions & 4 deletions docs/howto/ios-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ this tab.

## Other commands

* `cd ios && pod install && cd ..` - if you've already run `yarn`,
installs native iOS dependencies to match the Podfile.lock

* `yarn ios-min` - runs in an iOS simulator in the minimally supported device
(currently iPhone 5S)

Expand All @@ -27,7 +24,9 @@ device name in package.json

## Running on an iOS device
1. Connect your iOS device
2. Within the repo, `$ open ios/ZulipMobile.xcworkspace/` to open Xcode
2. Within the repo, `$ open ios/ZulipMobile.xcworkspace/` to open
Xcode. Make sure you choose the one that ends in .xcworkspace,
not .xcodeproj.
3. Change BundleIdentifier for both ZulipMobile and ZulipMobileTests to a
unique string, e.g. `<username>ZulipMobile` in the 'General Tab' of your project.
4. Select your device as the `build target` (from [this guide](https://facebook.github.io/react-native/docs/running-on-device.html))
Expand Down Expand Up @@ -58,3 +57,18 @@ unstaged. Later, you can always [squash that commit with other
commits][fixing-commits], if appropriate.

[fixing-commits]: https://zulip.readthedocs.io/en/latest/git/fixing-commits.html

## Clearing the build folder

If you get build failures on iOS and you haven't changed anything in
the `ios` folder yourself, and you're on the latest version of Xcode,
there might be residue from a previous build interfering with this
one. So, try cleaning the build folder with `rm -rf`. A different
folder is used for command-line builds and builds through Xcode.
- If building from the command line with `react-native run-ios`, run
`rm -rf ios/build`.
- If building in Xcode, the build folder is at a path like
`~/Library/Developer/Xcode/DerivedData/ZulipMobile-diuocloqwafvdpeozujwphdrhalf`
(the hash at the end will be different) by default, but if it's not
there, you can find it in Xcode at File > Workspace Settings > Build
Location.
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- boost-for-react-native (1.63.0)
- DoubleConversion (1.1.6)
- EXApplication (2.1.0):
- EXApplication (2.1.1):
- UMCore
- EXAppLoaderProvider (7.0.0)
- EXConstants (7.0.1):
Expand Down Expand Up @@ -292,7 +292,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
DoubleConversion: bb338842f62ab1d708ceb63ec3d999f0f3d98ecd
EXApplication: 777c2f1742b381725b3e8c1da41f0113ebfd4694
EXApplication: 7cf81de6fafccff42f5d1caa5c24a159db6b9437
EXAppLoaderProvider: 5d348813a9cf09b03bbe5b8b55437bc1bfbddbd1
EXConstants: 857aa7b1c84e2878f8402d712061860bca16a697
EXFileSystem: 7e53a2c30a2eb6987ba6d5158ab908f947523228
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"private": true,
"scripts": {
"postinstall": "tools/postinstall",
"start": "react-native start",
"ios": "react-native run-ios",
"ios-min": "react-native run-ios --simulator 'iPhone 5s'",
Expand Down Expand Up @@ -34,13 +35,14 @@
"@react-native-community/async-storage": "^1.6.3",
"@react-native-community/netinfo": "^3.2.1",
"@sentry/react-native": "^1.0.9",
"@unimodules/core": "~4.0.0",
"@zulip/shared": "^0.0.2",
"base-64": "^0.1.0",
"blueimp-md5": "^2.10.0",
"color": "^3.0.0",
"date-fns": "^1.29.0",
"expo-application": "^2.1.1",
"katex": "^0.11.1",
"expo-application": "^2.1.0",
"lodash.escape": "^4.0.1",
"lodash.isequal": "^4.4.0",
"lodash.omit": "^4.5.0",
Expand Down
1 change: 0 additions & 1 deletion tools/ios
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ archive_path="${rootdir}"/ios/build/ZulipMobile.xcarchive

do_build() {
yarn
pod install
echo >&2

mkdir -p build
Expand Down
26 changes: 26 additions & 0 deletions tools/postinstall
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -eu

Copy link
Member

Choose a reason for hiding this comment

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

Write set -eu at the top.

A couple of useful sources with discussion:
https://sipb.mit.edu/doc/safe-shell/
https://jvns.ca/blog/2017/03/26/bash-quirks/

(One of those recommends also set -o pipefail, but I recall concluding at some point that that could introduce its own hard-to-avoid kinds of bugs.)

ROOT_DIR=$(git rev-parse --show-toplevel)

pod_install() {
[[ "$OSTYPE" == "darwin"* ]] \
|| return 0

if ! hash pod 2>/dev/null; then
cat >&2 <<EOF
The Zulip mobile app requires CocoaPods for its iOS build. Please
install it, following the instructions at
https://guides.cocoapods.org/using/getting-started.html.

Then, rerun yarn.
EOF
exit 1
fi

pod install --project-directory="$ROOT_DIR/ios"
}

pod_install

echo "tools/postinstall finished with no errors!"
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3627,10 +3627,10 @@ expo-app-loader-provider@~7.0.0:
resolved "https://registry.yarnpkg.com/expo-app-loader-provider/-/expo-app-loader-provider-7.0.0.tgz#9bfff831a204d0a8896e0120bce2209c4304ef03"
integrity sha512-C+5zpZN2T7PCj7weLs/ZgAC+y9dvu0VdTXD00Jf9Wo7Pxu/lsLh6ljg9JL91c+2tYDzMEODPNmT+JOUIxAr5zQ==

expo-application@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/expo-application/-/expo-application-2.1.0.tgz#ce5b13f025643e26478e5f7e4a89f21e96b2f908"
integrity sha512-JuWpToRjx81mNwJCL80Rf7wbEcNgyapqcfB3Iz1kqDSK8mF7ZmLL05dmdvPrqfGdhJImbMlDS4MTZU9ArUTZuQ==
expo-application@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/expo-application/-/expo-application-2.1.1.tgz#7cd61ccc53d7a0c85c8aac64b5ea59b20a1cb803"
integrity sha512-iq24Zgd4EmbFakHL2saVdA2zexhRX80RSbAtrWrp3BaVDd7yFNAtcwjW4r1Oyhm00YEREWp70sTaXrWs6jKHQA==

expo-asset@~7.0.0:
version "7.0.0"
Expand Down