Giter Site home page Giter Site logo

Comments (13)

killerchip avatar killerchip commented on May 6, 2024 3

@stovmascript I did a bit search and I found out there's not a full-proof way to understand if a RN expo project is ejected (or bare flow) or not.

What I think of creating as PR is to have an additional option in CLI to force updating of native files even if expo has been detected. And leave it up to the user to fix his situation.

Or something like --ignore-expo totally.

from react-native-version.

stovmascript avatar stovmascript commented on May 6, 2024 3

I'm actually more inclined to do it the other way around and introduce some --expo option for Expo projects. That way, there wouldn't be a need for any "isExpoProject" logic. On the other hand, it would be a breaking change, but I guess it's not that big of a deal for people to add a flag to their setups.

from react-native-version.

IjzerenHein avatar IjzerenHein commented on May 6, 2024 3

As a workaround, you may convert your app.json to a app.config.js file, which prevents react-native-version from detecting it as a managed Expo project.

from react-native-version.

nexorianus avatar nexorianus commented on May 6, 2024 2

@stovmascript if the Pullrequest could be accepted it would be awesome!
I'm having the same problems with an ejected expo app, not actually updating the version numbers.

from react-native-version.

crolly avatar crolly commented on May 6, 2024 2

I would absolutely love an --expo option. As of now, I am still using app.json information even though the project is ejected, so simply deleting does not do the trick.
In the meantime I am just bypassing the problem by adding sth. like this in my package.json scripts for example:

"bump:build": "yarn react-native-version -b && mv app.json app--.json && yarn react-native-version -b && mv app--.json app.json"

from react-native-version.

jarell4 avatar jarell4 commented on May 6, 2024 2

As a workaround, you may convert your app.json to a app.config.js file, which prevents react-native-version from detecting it as a managed Expo project.

I just tried this workaround and got it to work. Minor correction for future searchers. You'll want to convert your app.json into an app.config.json file.

from react-native-version.

yaeda avatar yaeda commented on May 6, 2024 1

@stovmascript Even if expo is ejected, there are modules that use expo key in app.json. I think it is a good idea to introduce --ignore-expo option.

ex.) expo-updates - npm

from react-native-version.

stovmascript avatar stovmascript commented on May 6, 2024

@jeremybdk Sorry for not replying earlier, I'm pretty busy atm, also in the middle of moving.

Seems like that could work. Would you like to submit a PR? The check whether the app is an Expo app or plain RN is here:

function isExpoProject(projPath) {
try {
let module = resolveFrom(projPath, "expo");
let appInfo = require(`${projPath}/app.json`);
return !!(module && appInfo.expo);
} catch (err) {
return false;
}
}

It should be pretty easy to test. Maybe some other tweaks will be required to update both the Expo config and the RN app, when ejected - if that's what we want.

from react-native-version.

stovmascript avatar stovmascript commented on May 6, 2024

@killerchip What about removing the expo key from app.json after ejecting? Is it needed for usage with the Expo SDK after ejecting? (Sorry, I don't use Expo.)

from react-native-version.

killerchip avatar killerchip commented on May 6, 2024

@stovmascript I'm using expo but not an expo expert myself.

My tests showed:

  • Using expo-cli to initiate an expo-bare workflow, it does create the expo key in app.json. Removing it has not issue. The app run fine.

  • Using the expo-cli to initial an expo-managed workflow, and then eject, cannot compile my app at all. So I could not tested it at atm.

Anyway, the solution I'm proposing is not obtrusive. It's an opt-in and removes the concern of managing edge cases with expo from your package, and gives this flexibility to user.

But it's your call in the end :-)

from react-native-version.

cjthompson avatar cjthompson commented on May 6, 2024

Another option would be to include instructions on how to update the Android and iOS build steps to READ the version information from the "app.json" file.

Here's an easy way to do it in Android:

android/app/build.gradle

def appJson = new groovy.json.JsonSlurper().parse(new File("$rootDir/../app.json"))

// ...
    defaultConfig {
        // ...
        versionCode appJson.expo.android.versionCode
        versionName appJson.expo.version

for iOS I found this suggested solution

from react-native-version.

summerkiflain avatar summerkiflain commented on May 6, 2024

for iOS I found this suggested solution

@cjthompson I have tried below for iOS but its not working for me, version and buildNumber doesn't change.

// iOSVersioning.js, placed inside ios folder
/** @format */

const { exec } = require('child_process')

const APP_VERSION = process.env.APP_VERSION
const app = require('../app.json')
const versionName = app.version
const buildNumber = app.ios.buildNumber

if (APP_VERSION === versionName) {
  process.exit()
}

exec(
  `/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${versionName}" -c "Set :CFBundleVersion ${buildNumber}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"`,
  (err, stdout, stderr) => {
    if (err) {
      console.log('Failed to apply the app version.')
      process.exit(1)
    }

    console.log(`Applied app version: ${versionName}, build number: ${buildNumber}`)
  }
)

and changed my Bundle React Native code and images build phase to:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
AppVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}")
APP_VERSION="$AppVersion" node ${PROJECT_DIR}/../iOSVersioning.js
export NODE_BINARY=$(which node)
../node_modules/react-native/scripts/react-native-xcode.sh
../node_modules/expo-constants/scripts/get-app-config-ios.sh
../node_modules/expo-updates/scripts/create-manifest-ios.sh

can you share how you configured it for iOS?

from react-native-version.

agape-apps avatar agape-apps commented on May 6, 2024

Please apply one of these two PR's which would fix the issue:

--ignore-expo cli option by killerchip ยท Pull Request #150

Adds two CLI options: --is-bare-expo-workflow and --is-self-hosting-bundles by zibs ยท Pull Request #243

from react-native-version.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.