Closed chanphiromsok closed 9 months ago
Don't put comments, it' not valid JSON. https://github.com/zoontek/react-native-permissions/commit/d36e0349f9b8b2a82c72acb5e2bff1d30da1d9ee
@zoontek, I don't have comments in app.json, but I'm facing the same problem.
Basically, when I run npx expo prebuild, it adds some settings to the Podfile:
# @generated begin require - expo prebuild (DO NOT MODIFY) sync-0b3d11245f758d271ec25750612913aa85ad0f45
require File.join(File.dirname(`node --print ‘require.resolve(’react-native-permissions/package.json‘)’`), ‘scripts/setup’)
# @generated end require
# @generated begin setup - expo prebuild (DO NOT MODIFY) sync-aef63821df58f3f9287e46b77c11c725ef295e89
setup_permissions([
‘Camera’,
‘Microphone’,
‘Contacts’,
‘Notifications’,
])
# Final configuration of @generated
and when I run the npx expo prebuild again it gives the following error:
ERROR: Cannot add react-native-permissions to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.
my app.json looks like this:
{
"expo": {
"name": "MyApp",
"slug": "myapp",
"version": "1.6.0",
"scheme": "com.company.myapp",
"orientation": "portrait",
"owner": "company",
"icon": "./assets/app_icon.png",
"backgroundColor": "#ffffff",
"splash": {
"image": "./assets/splash_bluebackground.png",
"backgroundColor": "#117AF7",
"resizeMode": "cover"
},
"jsEngine": "hermes",
"assetBundlePatterns": [
"**/*"
],
"android": {
"package": "com.company.myapp",
"googleServicesFile": "./google-services.json",
"adaptiveIcon": {
"foregroundImage": "./assets/app_icon.png",
"backgroundColor": "#ffffff"
},
"allowBackup": false,
"versionCode": 173,
"permissions": [
"BIND_TELECOM_CONNECTION_SERVICE",
"ACTION_MANAGE_OVERLAY_PERMISSION",
"CALL_PHONE",
"FOREGROUND_SERVICE",
"READ_PHONE_STATE",
"FOREGROUND_SERVICE_DATA_SYNC",
"FOREGROUND_SERVICE_MICROPHONE",
"CAPTURE_AUDIO_HOTWORD",
"CAPTURE_AUDIO_OUTPUT",
"CAPTURE_MEDIA_OUTPUT",
"CAPTURE_TUNER_AUDIO_INPUT",
"CAPTURE_VOICE_COMMUNICATION_OUTPUT"
]
},
"ios": {
"bundleIdentifier": "com.company.myapp",
"googleServicesFile": "./GoogleService-Info.plist",
"supportsTablet": true,
"infoPlist": {
"UIBackgroundModes": [
"fetch",
"processing",
"remote-notification",
"voip",
"audio"
],
"BGTaskSchedulerPermittedIdentifiers": [
"com.company.myapp"],
"OS_ACTIVITY_MODE": "disable",
"NSMicrophoneUsageDescription": "[REASON]",
"NSContactsUsageDescription": "[REASON]",
"NSCameraUsageDescription": "[REASON]",
"NSPhotoLibraryUsageDescription": "[REASON]",
},
"config": {
"usesNonExemptEncryption": false
}
},
"plugins": [
[
"@config-plugins/react-native-webrtc"
],
[
"expo-build-properties",
{
"android": {
"compileSdkVersion": 34,
"targetSdkVersion": 34,
"buildToolsVersion": "33.0.0",
"minSdkVersion": 26,
"kotlinVersion": "1.8.10"
},
"ios": {
"deploymentTarget": "13.0",
"useFrameworks": "static"
}
}
],
[
"expo-contacts",
{
"contactsPermission": "[REASON]",
}
],
[
"@react-native-firebase/app"
],
[
"expo-image-picker"
],
[
"react-native-permissions",
{
"iosPermissions": [
"Camera",
"Microphone",
"Contacts",
"Notifications"
]
}
]
]
}
}
and here's my Podfile:
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
# @generated begin require - expo prebuild (DO NOT MODIFY) sync-0b3d11245f758d271ec25750612913aa85ad0f45
require File.join(File.dirname(`node --print "require.resolve('react-native-permissions/package.json')"`), "scripts/setup")
# @generated end require
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")
require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
:deterministic_uuids => false
prepare_react_native_project!
# @generated begin setup - expo prebuild (DO NOT MODIFY) sync-aef63821df58f3f9287e46b77c11c725ef295e89
setup_permissions([
'Camera',
'Microphone',
'Contacts',
'Notifications',
])
# @generated end setup
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...), which will be excluded. To fix this,
# you can also exclude `react-native-flipper` in `react-native.config.js`
#
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# }
# }
# ```
flipper_config = FlipperConfiguration.disabled
if ENV['NO_FLIPPER'] == '1' then
# Explicitly disabled through environment variables
flipper_config = FlipperConfiguration.disabled
elsif podfile_properties.key?('ios.flipper') then
# Configure Flipper in Podfile.properties.json
if podfile_properties['ios.flipper'] == 'true' then
flipper_config = FlipperConfiguration.enabled(["Debug", "Release"])
elsif podfile_properties['ios.flipper'] != 'false' then
flipper_config = FlipperConfiguration.enabled(["Debug", "Release"], { 'Flipper' => podfile_properties['ios.flipper'] })
end
end
target 'myapp' do
use_expo_modules!
config = use_native_modules!
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/..",
# Note that if you have use_frameworks! enabled, Flipper will not work if enabled
:flipper_configuration => flipper_config
)
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
# This is necessary for Xcode 14, because it signs resource bundles by default
# when building for devices.
installer.target_installation_results.pod_target_installation_results
.each do |pod_name, target_installation_result|
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = podfile_properties['ios.deploymentTarget']
end
end
end
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end
@chanphiromsok @zoontek @pierguinzani I am facing the same issue in my project. Does anyone have any solution?
@vishva-simform Your Podfile is incorrect
@zoontek My podfile is auto generating with prebuild ios command npx expo prebuild and I've added pluging in app.json file
Still malformed, or you are using a version of Expo that is too old.
I am using Expo version 51 but still facing the same error with malformed
Another plugin might mess with it.
I am using Expo version 51 but still facing the same error with malformed
I think you must double to make sure your code does not have a comment on the code check this commit https://github.com/zoontek/react-native-permissions/commit/d36e0349f9b8b2a82c72acb5e2bff1d30da1d9ee try to clean and run expo prebuild incase your code not generate new
Any updates on this? I'm having the same issues.
If I clear the auto-generated lines on Podfile from expo prebuild, and run npx expo prebuild
again, I don't get the error (the lines are added to the Podfile). This only happens when react-native-permissions added the lines to the file, and doesn't seem to know how to properly handle updating them.
I tried using the newly released version (5.0.0), but the problem is the same.
@pelinche By:
If I clear the auto-generated lines on Podfile from expo prebuild
You mean "I run npx expo prebuild --clean
? Or are you updating the files manually?
Manually
and when i run npx expo prebuild
,
✔ Created native directories | reusing /android, /ios
✔ Updated package.json | no changes
✔ Finished prebuild
✨ Done in 2.45s.
But if I run again npx expo prebuild
$ npx expo prebuild
✔ Created native directories | reusing /android, /ios
✔ Updated package.json | no changes
ERROR: Cannot add react-native-permissions to the project's ios/Podfile because it's malformed. Please report this with a copy of your project Podfile.
✔ Finished prebuild
✨ Done in 2.32s.
@zoontek , If I comment out the code that causes the error (results of withSetup.didMerge or withRequire.didMerge = false), the Podfile is updated.
This way, I can say that the problem must be in the _generateCode.mergeContents
function.
@pelinche It's highly recommanded not to perform manual updates in prebuilt files (instead, local plugins to perform the updates is the way to go), but I allowed it in 5.0.1.
Thanks @zoontek . This worked for me.
Before submitting a new issue
Bug summary
error in app.config.ts when run
yarn expo prebuild
{ "name": "My awesome app", "plugins": [ [ "react-native-permissions", { // uncomment wanted permissions "iosPermissions": [ // "AppTrackingTransparency", // "Bluetooth" // "Calendars", // "CalendarsWriteOnly", // "Camera", // "Contacts", // "FaceID", // "LocationAccuracy", // "LocationAlways", // "LocationWhenInUse", // "MediaLibrary", // "Microphone", // "Motion", // "Notifications", // "PhotoLibrary", // "PhotoLibraryAddOnly", // "Reminders", // "Siri", // "SpeechRecognition", // "StoreKit" ] } ] ] }running
Library version
4.1.0
Environment info
Steps to reproduce
yarn expo prebuild
got an error plugin can not plugReproducible sample code