反应本机应用程序可在调试模式下使用,但不适用于ios上的发布模式

时间:2018-09-09 17:42:14

标签: ios reactjs react-native react-redux saga

我有一个关于本机响应的应用程序。调试模式适用于ios。但是发布模式不起作用。我尝试更改优化级别,但没有帮助。我没有看到任何错误的问题。只是不起作用某些功能。而且我无法调试应用的发行版本。如何解决这个问题?

作为最后的更改,我们在传奇之后添加了一个名称,当我们删除该传奇时,便可以使用

import { select, take, takeLatest, call, put, fork, race } from 'redux-saga/effects';
import R from 'ramda';
import V from 'o-validator';
import * as actionCreators from './actions';
import { redirectTo, showModalError, showModal, showOtp, closeOtp, errorOtp, loader, keychainSet } from '../../../actions/app-actions';
import { storeSession, refreshSession } from '../../../actions/session-actions';
import I18n from 'react-native-i18n';
import {
  KEYCHAIN_RESET,
  KEYCHAIN_GET,
  KEYCHAIN_RESULT
} from '../../../constants/action-types';


import { validatePassword, createCustomError, serverError } from '../../../services/utils';

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))


export function * ChangePasswordWatcher( api, action ) {
        yield fork( ChangePasswordFormWatcher, api, action );
}

export function * ChangePasswordFormWatcher(api, action){
  while (true) {
    yield race({
      changePasswordProcess: call(ChangePasswordStart, api),
      cancel: take(['CHANGE_PASSWORD_PASSWORD_RESET'])
    });
    //yield put( loader('hide') );
        yield put( loader('hide') );


  }
}




/**
 * Change Password Sagas starter
 *
 * @param {function} api - api object
 * @param {object} action - action from dispatch
 * @returns
 */
export function * ChangePasswordStart(api, action) {
    try {
            while (true) {
                const { formData } = yield take('CHANGE_PASSWORD_FORM_SUBMIT');
                                let oldPassword = formData.oldPassword;
                                let newPassword = formData.newPassword;
                                let newPasswordConfirmation = formData.newPasswordConfirmation;


                                yield put({
                                type: 'CHANGE_PASSWORD_FORM_VALID'
                              });

                                const validate = validateForm( 'changePasswordForm', formData );
                                if ( validate.valid ) {
                                        yield put( actionCreators.submitChangePasswordFormValid() );
                                        yield put( loader('show') );


                                        let newPasswordResponse = yield call( api.setChangePassword, oldPassword, newPassword);
                    yield put( loader('hide') );
                    if ( !newPasswordResponse.ok ) {

                                            let errors = serverError(newPasswordResponse);
                                            console.log(errors);
                                      console.log('errors newPasswordResponse');

                                      yield put( showModalError({ error: errors }));
                                      yield put( actionCreators.submitNewPasswordFormFailed( errors ) );

                                        //  return false;
                                        }
                                        else {


                                        yield put({
                                            type: KEYCHAIN_GET,
                                            // resultAction: ''
                                        });


                                        const keychain = yield take(KEYCHAIN_RESULT);

                    // Save to Keychain
                                        yield put( keychainSet({
                                            login: keychain.login || false,
                                            password: keychain.password || false
                                        }) );

                            // final screen
                                        yield put( redirectTo('thankyou') );
                                        yield call( delay, 300 );
                                        yield put( actionCreators.changePasswordResetState() );
                                    }

                                }
                                else {
                                    yield put( showModalError({ error: validate.errors }));
                                    yield put( actionCreators.submitChangePasswordFormFailed( validate.errors ));
                                    yield put( actionCreators.changePasswordFailed() );


                    //                      yield put( actionCreators.submitFinFormFailed( ret.errors ) );
                //                      yield put( actionCreators.registrationFailed());
                              }
          // Reset login
         //  yield call( delay, 300 );
        //  yield put( actionCreators.resetState() );

        }

    } catch (e) {
            console.log(e);
    }


}




export function validateForm( formKey, formData ) {
  let
  ret = {
    valid: true,
    errors: false
  },
  schema: {};

  switch ( formKey ) {
    case 'changePasswordForm':
        schema = {
                    oldPassword: V.required( validatePassword ),
                    newPassword: V.required( validatePassword ),
                    newPasswordConfirmation: V.required( R.equals( formData.newPassword ) )
                };
      break;

    default:
      break;
  }

  ret.valid = V.validate( schema, formData );

  if ( !ret.valid ) {
    ret.errors = V.getErrors( schema, formData );
    ret.errors = R.zipObj( R.pluck('property', ret.errors), ret.errors );
  }

  console.log('isValid: ' + ret.valid.toString());

  return ret;
}

要评论所有Console.log语句没有帮助

import { select, take, takeLatest, call, put, fork, race } from 'redux-saga/effects';
import R from 'ramda';
import V from 'o-validator';
import * as actionCreators from './actions';
import { redirectTo, showModalError, showModal, showOtp, closeOtp, errorOtp, loader, keychainSet } from '../../../actions/app-actions';
import { storeSession, refreshSession } from '../../../actions/session-actions';
import I18n from 'react-native-i18n';
import {
  KEYCHAIN_RESET,
  KEYCHAIN_GET,
  KEYCHAIN_RESULT
} from '../../../constants/action-types';


import { validatePassword, createCustomError, serverError } from '../../../services/utils';

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))


export function * changePasswordScreenWatcher( api, action ) {
        yield fork( ChangePasswordFormWatcher, api, action );
}

export function * ChangePasswordFormWatcher(api, action){
  while (true) {
    yield race({
      changePasswordProcess: call(ChangePasswordStart, api),
      cancel: take(['CHANGE_PASSWORD_PASSWORD_RESET'])
    });
    //yield put( loader('hide') );
        yield put( loader('hide') );


  }
}




/**
 * Change Password Sagas starter
 *
 * @param {function} api - api object
 * @param {object} action - action from dispatch
 * @returns
 */
export function * ChangePasswordStart(api, action) {
    try {
            while (true) {
                const { formData } = yield take('CHANGE_PASSWORD_FORM_SUBMIT');
                                let oldPassword = formData.oldPassword;
                                let newPassword = formData.newPassword;
                                let newPasswordConfirmation = formData.newPasswordConfirmation;


                                yield put({
                                type: 'CHANGE_PASSWORD_FORM_VALID'
                              });

                                const validate = validateForm( 'changePasswordForm', formData );
                                if ( validate.valid ) {
                                        yield put( actionCreators.submitChangePasswordFormValid() );
                                        yield put( loader('show') );


                                        let newPasswordResponse = yield call( api.setChangePassword, oldPassword, newPassword);
                    yield put( loader('hide') );
                    if ( !newPasswordResponse.ok ) {

                                            let errors = serverError(newPasswordResponse);
                                            //console.log(errors);
                                      //console.log('errors newPasswordResponse');

                                      yield put( showModalError({ error: errors }));
                                      yield put( actionCreators.submitNewPasswordFormFailed( errors ) );

                                        //  return false;
                                        }
                                        else {


                                        yield put({
                                            type: KEYCHAIN_GET,
                                            // resultAction: ''
                                        });


                                        const keychain = yield take(KEYCHAIN_RESULT);

                    // Save to Keychain
                                        yield put( keychainSet({
                                            login: keychain.login || false,
                                            password: keychain.password || false
                                        }) );

                            // final screen
                                        yield put( redirectTo('thankyou') );
                                        yield call( delay, 300 );
                                        yield put( actionCreators.changePasswordResetState() );
                                    }

                                }
                                else {
                                    yield put( showModalError({ error: validate.errors }));
                                    yield put( actionCreators.submitChangePasswordFormFailed( validate.errors ));
                                    yield put( actionCreators.changePasswordFailed() );


                    //                      yield put( actionCreators.submitFinFormFailed( ret.errors ) );
                //                      yield put( actionCreators.registrationFailed());
                              }
          // Reset login
         //  yield call( delay, 300 );
        //  yield put( actionCreators.resetState() );

        }

    } catch (e) {
            //console.log(e);
    }


}




export function validateForm( formKey, formData ) {
  let ret = {
    valid: true,
    errors: false
  };

  switch ( formKey ) {
    case 'changePasswordForm':
        schema = {
                    oldPassword: V.required( validatePassword ),
                    newPassword: V.required( validatePassword ),
                    newPasswordConfirmation: V.required( R.equals( formData.newPassword ) )
                };
      break;

    default:
      break;
  }

  ret.valid = V.validate( schema, formData );

  if ( !ret.valid ) {
    ret.errors = V.getErrors( schema, formData );
    ret.errors = R.zipObj( R.pluck('property', ret.errors), ret.errors );
  }

  //console.log('isValid: ' + ret.valid.toString());

  return ret;
}

3 个答案:

答案 0 :(得分:0)

根据提供的信息,似乎在调试发布模式之间切换时,您正在加载不同的捆绑软件。

确保在发布模式下将应用配置为use a static bundle

然后,您的应用将在两种模式下呈现相同的包,其行为可能与您期望的一样。

答案 1 :(得分:0)

它必须是与您的iOS版本的应用程序冲突的库。尝试一个一个地删除库,看看它是否能在每次尝试中起作用。

一种快捷方式是检查您正在使用的库的代码,并查看是否已弃用该库正在使用的任何API。

我遇到了类似的问题,在我的情况下,导致问题的是动画动画。希望您能够解决它。

答案 2 :(得分:-3)

好像您在代码中进行console.log一样。由于您的真实电话环境没有console全局变量,因此请确保在编译为正式版之前将其清除。

编辑

先前的陈述并不完全正确。即使我自己遇到了一些极端的情况,其中console.log可能会在不以调试模式运行时使您的应用程序崩溃,这似乎并非总是如此,生产构建将在适当的情况下运行。无论采用哪种方式,都可以通过删除它们来提高性能,https://facebook.github.io/react-native/docs/performance.html#performance