-
-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to Expo 50 and Fix to Rive Crashing (#2049)
* Update Mobile App to Expo SDK 50 + Fix to Rive Crashing * Added `metro-react-native-babel-transformer` to fix CI
- Loading branch information
1 parent
2ff1ffc
commit 58f9305
Showing
6 changed files
with
1,617 additions
and
1,563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
- Make sure to run `pnpm i` if you make any change to the `package` mobile uses like `assets`. | ||
- If iOS build fails with `node not found` error, run `echo "export NODE_BINARY=$(command -v node)" >> .xcode.env.local` on `mobile/ios/` directory. | ||
- If XCode can't find node, run `ln -s "$(which node)" /usr/local/bin/node` | ||
- To view the logs from the Spacedrive Core API, run `xcrun simctl launch --console booted com.spacedrive.app` with the app built in debug mode. | ||
- If Rive Assets have been updated, run `pnpm mobile prebuild` to import the latest version of the `.riv` files into the project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,8 @@ | |
"deploymentTarget": "14.0" | ||
} | ||
} | ||
] | ||
], | ||
["./withRiveAssets.js"] | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* If you add an asset you need to run `npx expo prebuild` | ||
* If you rename or delete an asset you need to run `npx expo prebuild --clean` to delete them in your android and ios folder as well. | ||
*/ | ||
|
||
const { | ||
withDangerousMod, | ||
withXcodeProject, | ||
IOSConfig, | ||
} = require("@expo/config-plugins"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
// Specify the source directory of your assets | ||
const ASSET_SOURCE_DIR = "assets/rive"; | ||
|
||
const IOS_GROUP_NAME = "Rivassets"; | ||
|
||
const withRiveAssets = (config) => { | ||
config = addAndroidResources(config); | ||
config = addIOSResources(config); | ||
return config; | ||
}; | ||
|
||
// Code inspired by https://github.com/rive-app/rive-react-native/issues/185#issuecomment-1593396573 | ||
function addAndroidResources(config) { | ||
return withDangerousMod(config, [ | ||
"android", | ||
async (config) => { | ||
// Get the path to the Android project directory | ||
const projectRoot = config.modRequest.projectRoot; | ||
|
||
// Get the path to the Android resources directory | ||
const resDir = path.join( | ||
projectRoot, | ||
"android", | ||
"app", | ||
"src", | ||
"main", | ||
"res" | ||
); | ||
|
||
// Create the 'raw' directory if it doesn't exist | ||
const rawDir = path.join(resDir, "raw"); | ||
fs.mkdirSync(rawDir, { recursive: true }); | ||
|
||
// Get the path to the assets directory | ||
const assetSourcePath = path.join(projectRoot, ASSET_SOURCE_DIR); | ||
|
||
// Retrieve all files in the assets directory | ||
const assetFiles = fs.readdirSync(assetSourcePath); | ||
|
||
// Move each asset file to the resources 'raw' directory | ||
for (const assetFile of assetFiles) { | ||
const srcAssetPath = path.join(assetSourcePath, assetFile); | ||
const destAssetPath = path.join(rawDir, assetFile); | ||
fs.copyFileSync(srcAssetPath, destAssetPath); | ||
} | ||
|
||
return config; | ||
}, | ||
]); | ||
} | ||
|
||
// Code inspired by https://github.com/expo/expo/blob/61f8cf8d4b3cf5f8bf61f346476ebdb4aff40545/packages/expo-font/plugin/src/withFontsIos.ts | ||
function addIOSResources(config) { | ||
return withXcodeProject(config, async (config) => { | ||
const project = config.modResults; | ||
const platformProjectRoot = config.modRequest.platformProjectRoot; | ||
|
||
// Create Assets group in project | ||
IOSConfig.XcodeUtils.ensureGroupRecursively(project, IOS_GROUP_NAME); | ||
|
||
// Get riv filepaths | ||
const projectRoot = config.modRequest.projectRoot; | ||
const assetSourcePath = path.join(projectRoot, ASSET_SOURCE_DIR); | ||
const assetFiles = fs.readdirSync(assetSourcePath); | ||
const assetFilesPaths = assetFiles.map( | ||
(assetFile) => `${assetSourcePath}/${assetFile}` | ||
); | ||
|
||
// Add assets to group | ||
addIOSResourceFile(project, platformProjectRoot, assetFilesPaths); | ||
|
||
return config; | ||
}); | ||
|
||
function addIOSResourceFile(project, platformRoot, assetFilesPaths) { | ||
for (const riveFile of assetFilesPaths) { | ||
const riveFilePath = path.relative(platformRoot, riveFile); | ||
IOSConfig.XcodeUtils.addResourceFileToGroup({ | ||
filepath: riveFilePath, | ||
groupName: IOS_GROUP_NAME, | ||
project, | ||
isBuildFile: true, | ||
verbose: true, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
module.exports = withRiveAssets; |
Oops, something went wrong.