My React Native Expo IOS -приложение работает полностью, чем Expo. К сожалению, при выполнении сборки разработки или через тестовый рейс я получаю белый экран. Я изо всех сил пытаюсь отладить это, так как в Testflight я не имею доступа к консоли.
Я могу увеличивать и выходить на увеличение (как указано появляющимися стержнями), однако весь контент является простым белым экраном. < /p>
Мой обычный рабочий процесс, чтобы попасть на Testflight, указан ниже:
npx expo prebuild
eas build -platform ios
eas Отправить -p ios -latest < /p>
Нет ошибок консоли или сборки на выставке, поэтому отладить довольно сложно. ! < /p>
import React, { useRef } from 'react';
import { View, StyleSheet, StatusBar } from 'react-native';
import { WebView } from 'react-native-webview';
import * as FileSystem from 'expo-file-system';
import * as MediaLibrary from 'expo-media-library';
import * as Clipboard from 'expo-clipboard';
import * as Sharing from 'expo-sharing';
import { script } from './assets/constants';
const HTML_CONTENT = require('./assets/body.html');
export default function App() {
const webViewRef = useRef(null);
const styles = StyleSheet.create({
container: {
flex: 1,
},
webView: {
flex: 1,
},
});
const handleMessage = async (event) => {
const message = JSON.parse(event.nativeEvent.data);
console.log('Message from WebView:', message);
switch (message.type) {
case 'copyToClipboard':
try {
await Clipboard.setStringAsync(message.data);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'clipboardResponse', success: true })
}));
true;
`);
} catch (error) {
console.error('Error copying to clipboard:', error);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({
type: 'clipboardResponse',
success: false,
error: ${JSON.stringify(error.message)}
})
}));
true;
`);
}
break;
case 'log':
console.log('WebView log:', message.message);
break;
case 'error':
console.error('WebView error:', message.message);
break;
case 'exportPNG':
try {
const { status } = await MediaLibrary.requestPermissionsAsync();
if (status === 'granted') {
const filename = FileSystem.documentDirectory + 'color_palette.png';
await FileSystem.writeAsStringAsync(filename, message.data.split(',')[1], { encoding: FileSystem.EncodingType.Base64 });
await MediaLibrary.saveToLibraryAsync(filename);
// Send success message back to WebView
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportSuccess' })
}));
// Reset button text
document.getElementById('exportPngBtn').textContent = 'Export to PNG';
true;
`);
} else {
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportError', error: 'Permission denied' })
}));
document.getElementById('exportPngBtn').textContent = 'Export to PNG';
true;
`);
}
} catch (error) {
console.error('Error saving image:', error);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportError', error: ${JSON.stringify(error.message)} })
}));
document.getElementById('exportPngBtn').textContent = 'Export to PNG';
true;
`);
}
break;
case 'exportProcreate':
try {
const { status } = await MediaLibrary.requestPermissionsAsync();
if (status === 'granted') {
const timestamp = Date.now();
const tempDir = FileSystem.cacheDirectory;
const acoPath = `${tempDir}my_palette.aco`;
await FileSystem.writeAsStringAsync(
acoPath,
message.data.aco,
{ encoding: FileSystem.EncodingType.Base64 }
);
await Sharing.shareAsync(acoPath, {
mimeType: 'application/octet-stream',
dialogTitle: 'Save Color Palette',
UTI: 'public.data',
filename: 'my_palette.aco' // Set default filename for sharing
});
try {
await FileSystem.deleteAsync(acoPath);
} catch (cleanupError) {
console.warn('Cleanup error:', cleanupError);
}
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportSuccess' })
}));
document.getElementById('exportProcreateBtn').textContent = 'Export to Procreate';
true;
`);
}
} catch (error) {
console.error('Error saving palette file:', error);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({
type: 'exportError',
error: ${JSON.stringify(error.message)}
})
}));
document.getElementById('exportProcreateBtn').textContent = 'Export to Procreate';
true;
`);
}
break;
default:
console.warn('Unknown message type from WebView:', message.type);
}
};
const injectedJavaScript = `
console = {
log: function(message) {
window.ReactNativeWebView.postMessage(JSON.stringify({type: 'log', message: message}));
},
error: function(message) {
window.ReactNativeWebView.postMessage(JSON.stringify({type: 'error', message: message}));
}
};
${script}
`;
return (
);
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... e-expo-app
Белый экран в Testflight для приложения React Native Expo ⇐ IOS
Программируем под IOS
-
Anonymous
1740117904
Anonymous
My React Native Expo IOS -приложение работает полностью, чем Expo. К сожалению, при выполнении сборки разработки или через тестовый рейс я получаю белый экран. Я изо всех сил пытаюсь отладить это, так как в Testflight я не имею доступа к консоли.
Я могу увеличивать и выходить на увеличение (как указано появляющимися стержнями), однако весь контент является простым белым экраном. < /p>
Мой обычный рабочий процесс, чтобы попасть на Testflight, указан ниже:
npx expo prebuild
eas build -platform ios
eas Отправить -p ios -latest < /p>
Нет ошибок консоли или сборки на выставке, поэтому отладить довольно сложно. ! < /p>
import React, { useRef } from 'react';
import { View, StyleSheet, StatusBar } from 'react-native';
import { WebView } from 'react-native-webview';
import * as FileSystem from 'expo-file-system';
import * as MediaLibrary from 'expo-media-library';
import * as Clipboard from 'expo-clipboard';
import * as Sharing from 'expo-sharing';
import { script } from './assets/constants';
const HTML_CONTENT = require('./assets/body.html');
export default function App() {
const webViewRef = useRef(null);
const styles = StyleSheet.create({
container: {
flex: 1,
},
webView: {
flex: 1,
},
});
const handleMessage = async (event) => {
const message = JSON.parse(event.nativeEvent.data);
console.log('Message from WebView:', message);
switch (message.type) {
case 'copyToClipboard':
try {
await Clipboard.setStringAsync(message.data);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'clipboardResponse', success: true })
}));
true;
`);
} catch (error) {
console.error('Error copying to clipboard:', error);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({
type: 'clipboardResponse',
success: false,
error: ${JSON.stringify(error.message)}
})
}));
true;
`);
}
break;
case 'log':
console.log('WebView log:', message.message);
break;
case 'error':
console.error('WebView error:', message.message);
break;
case 'exportPNG':
try {
const { status } = await MediaLibrary.requestPermissionsAsync();
if (status === 'granted') {
const filename = FileSystem.documentDirectory + 'color_palette.png';
await FileSystem.writeAsStringAsync(filename, message.data.split(',')[1], { encoding: FileSystem.EncodingType.Base64 });
await MediaLibrary.saveToLibraryAsync(filename);
// Send success message back to WebView
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportSuccess' })
}));
// Reset button text
document.getElementById('exportPngBtn').textContent = 'Export to PNG';
true;
`);
} else {
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportError', error: 'Permission denied' })
}));
document.getElementById('exportPngBtn').textContent = 'Export to PNG';
true;
`);
}
} catch (error) {
console.error('Error saving image:', error);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportError', error: ${JSON.stringify(error.message)} })
}));
document.getElementById('exportPngBtn').textContent = 'Export to PNG';
true;
`);
}
break;
case 'exportProcreate':
try {
const { status } = await MediaLibrary.requestPermissionsAsync();
if (status === 'granted') {
const timestamp = Date.now();
const tempDir = FileSystem.cacheDirectory;
const acoPath = `${tempDir}my_palette.aco`;
await FileSystem.writeAsStringAsync(
acoPath,
message.data.aco,
{ encoding: FileSystem.EncodingType.Base64 }
);
await Sharing.shareAsync(acoPath, {
mimeType: 'application/octet-stream',
dialogTitle: 'Save Color Palette',
UTI: 'public.data',
filename: 'my_palette.aco' // Set default filename for sharing
});
try {
await FileSystem.deleteAsync(acoPath);
} catch (cleanupError) {
console.warn('Cleanup error:', cleanupError);
}
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({ type: 'exportSuccess' })
}));
document.getElementById('exportProcreateBtn').textContent = 'Export to Procreate';
true;
`);
}
} catch (error) {
console.error('Error saving palette file:', error);
webViewRef.current.injectJavaScript(`
window.dispatchEvent(new MessageEvent('message', {
data: JSON.stringify({
type: 'exportError',
error: ${JSON.stringify(error.message)}
})
}));
document.getElementById('exportProcreateBtn').textContent = 'Export to Procreate';
true;
`);
}
break;
default:
console.warn('Unknown message type from WebView:', message.type);
}
};
const injectedJavaScript = `
console = {
log: function(message) {
window.ReactNativeWebView.postMessage(JSON.stringify({type: 'log', message: message}));
},
error: function(message) {
window.ReactNativeWebView.postMessage(JSON.stringify({type: 'error', message: message}));
}
};
${script}
`;
return (
);
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79456460/white-screen-in-testflight-for-react-native-expo-app[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия