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

Build iOS from source #6353

Closed
wants to merge 14 commits into from
Closed
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
47 changes: 6 additions & 41 deletions .github/workflows/pr-realm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ jobs:
- { os: android, runner: ubuntu-latest, arch: x86, artifact-path: packages/realm/react-native/android/src/main/jniLibs }
- { os: darwin, runner: macos-latest, arch: x64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: darwin, runner: macos-latest, arch: arm64, artifact-path: packages/realm/prebuilds, test-node: true, test-electron: true }
- { os: ios, runner: macos-latest-xlarge, arch: simulator, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest-xlarge, arch: catalyst, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest-xlarge, arch: ios, artifact-path: packages/realm/react-native/ios/realm-js-ios.xcframework }
- { os: ios, runner: macos-latest-xlarge, arch: simulator, artifact-path: packages/realm/react-native/shared/jsi_init.cpp }
- { os: ios, runner: macos-latest-xlarge, arch: catalyst, artifact-path: packages/realm/react-native/shared/jsi_init.cpp }
- { os: ios, runner: macos-latest-xlarge, arch: ios, artifact-path: packages/realm/react-native/shared/jsi_init.cpp }
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -177,15 +177,9 @@ jobs:
if: ${{ (matrix.variant.os != 'ios') && (matrix.variant.os != 'android') }}
run: npm run build:node:prebuild:${{matrix.variant.arch}} --workspace realm

# build the c++ library for IOS
# the Info.plist needs to be regenerated with all libraries in place
- name: Build iOS
if: ${{ (matrix.variant.os == 'ios') }}
- name: Generate JSI
run: |
npm run build:ios --workspace realm
rm -vf ${{ matrix.variant.artifact-path }}/Info.plist
env:
PLATFORMS: ${{ matrix.variant.arch }}
npm run bindgen:generate:jsi --workspace realm

# build the c++ library for Android
- name: Build Android
Expand All @@ -202,38 +196,9 @@ jobs:
README.md
${{ matrix.variant.artifact-path }}

ios-xcframework:
name: Generate Info.plist with all frameworks in place
needs: [build]
if: ${{ success() || failure() }}
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: "recursive"

- name: Download prebuilds
uses: actions/download-artifact@v3
with:
name: realm-js-prebuilds

- name: Regenerate Info.plist
run: scripts/regen-info-plist.sh packages/realm/react-native/ios/realm-js-ios.xcframework

# Due to a limitation in upload-artifact a redundant file is needed to force
# preserving paths (https://github.com/actions/upload-artifact/issues/174)
- name: Upload prebuild artifact
uses: actions/upload-artifact@v3
with:
name: realm-js-prebuilds
path: |
README.md
packages/realm/react-native/ios/realm-js-ios.xcframework/Info.plist

integration-tests:
name: Test ${{ matrix.variant.environment }} on ${{ matrix.variant.os }} (${{matrix.variant.target}})
needs: [bundle, build, ios-xcframework]
needs: [bundle, build]
if: ${{ success() || failure() }}
env:
REALM_DISABLE_ANALYTICS: 1
Expand Down
15 changes: 6 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ yarn.lock

# Android/IJ
/android
/react-native/android/src/main/jni/core
/react-native/android/.cxx/
/build-android/
/packages/realm/react-native/android/src/main/jni/core
/packages/realm/react-native/android/.cxx/
/packages/realm/build-android/
.idea
.gradle
local.properties
Expand Down Expand Up @@ -97,14 +97,9 @@ coverage/
**/realm-config

#Ignore symlinked directories (otherwise on Windows they are shown as untracked files)
/react-native/android/src/main/jni/vendor/
/react-native/android/src/main/jni/src/
/build-tmp*/
/cmakebuild/
/react-native/android/src/main/java/io/realm/react/Version.java
/react-native/android/src/main/jniLibs/
/realm*.tgz
/react-native/ios/realm-js-ios.xcframework/

# Ignore template package-lock.json files
/templates/*/package-lock.json
Expand All @@ -119,7 +114,9 @@ coverage/
/packages/realm/prebuilds/
/packages/realm/react-native/android/src/main/java/io/realm/react/Version.java
/packages/realm/react-native/android/src/main/jniLibs/
/packages/realm/react-native/ios/realm-js-ios.xcframework/
/packages/realm/react-native/ios/lib/
/packages/realm/react-native/ios/input-files.xcfilelist
/packages/realm/react-native/shared/

# Wireit repo caches
.wireit
Expand Down
99 changes: 0 additions & 99 deletions CMakeLists.txt

This file was deleted.

13 changes: 0 additions & 13 deletions Realm.xcworkspace/contents.xcworkspacedata

This file was deleted.

31 changes: 0 additions & 31 deletions Realm.xcworkspace/xcshareddata/Realm.xcscmblueprint

This file was deleted.

1 change: 0 additions & 1 deletion compile_commands.json

This file was deleted.

9 changes: 2 additions & 7 deletions contrib/debug-rn-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,9 @@ Since we want to keep the simplicity for our users, changes made in order to deb

## Common Issues

### Android or iOS doesn't find Realm.
### Android doesn't find Realm.

Make sure to build binaries for Android and iOS in packages/realm by running:

```
npm run build:ios --workspace=realm
```
or
Make sure to build binaries for Android in packages/realm by running:

```
npm run build:android --workspace=realm
Expand Down
13 changes: 8 additions & 5 deletions contrib/debugging-react-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ In your realm-js project, run the following commands to prepare for debug mode:
```
# install js dependencies, but skip building the node binaries
$ npm install --ignore-scripts
```

When running `pod install` for iOS, be sure to set the environment variable `BUILD_REALM_CORE=1`. This will flag core to be built from source with the Debug configuration.

# build the xcframework
$ ./scripts/build-ios.sh -c Debug -s
```
BUILD_REALM_CORE=1 npx pod-install
```

You are now prepared to either use the [ReactTestApp](#setup-reacttestapp) or [prepare a custom project](#setup-custom-react-native-project)
Expand All @@ -30,7 +33,7 @@ There is a test application in `tests/ReactTestApp` which will run all the unit
$ cd tests
$ npm install

# install the test app dependencies and copy realm and realm tests into node_modules using `install-local`
# install the test app dependencies and copy realm and realm tests into node_modules using `install-local`
$ cd ReactTestApp
$ npm install
$ npx install-local
Expand All @@ -41,8 +44,8 @@ $ open ios/ReactTestApp.xcworkspace
```

You should now be able to move onto
- [Debugging Javascript](#debugging-javascript)
- [Debugging C++](#debugging-c++)
- [Debugging Javascript](#debugging-javascript)
- [Debugging C++](#debugging-c++)

## Setup Custom React Native Project

Expand Down
2 changes: 0 additions & 2 deletions integration-tests/environments/react-native/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ target 'RealmReactNativeTests' do
# Applying https://github.com/facebook/folly/issues/1470#issuecomment-943123653
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FOLLY_HAVE_CLOCK_GETTIME=1']
end
config.build_settings['CC'] = "../../../../../scripts/ccache-clang.sh"
config.build_settings['CXX'] = "../../../../../scripts/ccache-clang++.sh"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,11 @@
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
);
OTHER_LDFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../../node_modules/react-native";
SDKROOT = iphoneos;
};
Expand Down Expand Up @@ -674,7 +678,11 @@
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
);
OTHER_LDFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../../../../node_modules/react-native";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
</dict>
</plist>
Loading
Loading