App rejected by apple appstore
I am using this plugin in my Expo React native project. all works in Native cli project development version. But when i deployed the app in apple testflight it got rejected with 5 issues.
here is my code
import { SQIPCore, SQIPCardEntry } from 'react-native-square-in-app-payments';
SQIPCore.setSquareApplicationId('sandbox-sq0idb-88yVghwpOp1hSmaA5v1e2w');
const ConsultationBooking = () => {
const handleBooking = async () => {
try {
const cardEntryConfig = {
collectPostalCode: true
};
await SQIPCardEntry.startCardEntryFlow(
cardEntryConfig,
async (cardDetails) => {
// Handle payment success
await SQIPCardEntry.completeCardEntry(() => {
// console.log(JSON.stringify(cardDetails));
confirmBooking({
date: selected,
time: time,
foundItem: foundItem?._id,
nonce: cardDetails.nonce
}).unwrap().then((res) => {
// console.log(res);
Toast.show({
type: 'success',
text1: res?.message,
});
});
});
},
() => {
// Handle payment failure
console.log("cardEntryError");
}
);
} catch (ex) {
console.log(ex);
}
}
...
}
App Details:
- platform: iOS
- OS and version: iOS15.5
- dev environment: MacOS
- In-App Payments Plugin version: 1.7.6
- Expo : 51
- RN: 0.74
Hey @aargon007, I am in a similar situation. Have you found any solution yet? Thanks
Hey @aargon007, I am in a similar situation. Have you found any solution yet? Thanks
yeah!! do you solved this issues? maybe i can help you
Did anyone manage to solve this?
Hey @aargon007, I am in a similar situation. Have you found any solution yet? Thanks
yeah!! do you solved this issues? maybe i can help you
Looking for a resolution as well
@hmirza1 @Ocean572 you have to create a build script to solve the issue. Let me show you how i have done this.
- create reorderSquareIAPBuildPhase.rb in root folder
#!/usr/bin/env ruby
require 'xcodeproj'
require 'set'
project_file, target_name = ARGV
puts "Sorting sources in #{project_file} for target #{target_name}"
project = Xcodeproj::Project.open(project_file)
target = project.targets.select { |t| t.name == target_name }.first
square_framework_run_script_index = target.build_phases.index { |b|
name = b.name if b.respond_to? :name
name == "Square Framework Run Script - InAppPaymentsSDK" #name of build phase you have given in plugin below
}
puts "Square Framework Run Script index: #{square_framework_run_script_index} Total build phases: #{target.build_phases.count - 1}"
if square_framework_run_script_index.nil? == false
puts "Moving Square Framework Run Script from #{square_framework_run_script_index} to the #{target.build_phases.count - 1} index"
target.build_phases.move_from(square_framework_run_script_index, target.build_phases.count - 1) # move to the last indexs
end
project.save
- then create squareIOSBuildPhasePlugin.js in the root directory
const { withXcodeProject } = require('@expo/config-plugins');
const addBuildPhaseForSquareIOS = config => {
return withXcodeProject(config, async conf => {
const project = conf.modResults;
project.addBuildPhase(
[],
'PBXShellScriptBuildPhase',
'Square Framework Run Script - InAppPaymentsSDK', // build phase name
project.getFirstTarget().uuid,
{
shellPath: '/bin/sh',
shellScript:
'FRAMEWORKS="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}" && "${FRAMEWORKS}/SquareInAppPaymentsSDK.framework/setup"',
}
);
return conf;
});
};
module.exports = addBuildPhaseForSquareIOS;
- now create eas-build-post-install.sh in root directory of the project. set the actual project name in the mentioned ProjectName (here is HerbFitz)
#!/usr/bin/env bash
# This is a file called "pre-install" in the root of the project
if [[ "$EAS_BUILD_PLATFORM" == "ios" ]]; then
./reorderSquareIAPBuildPhase.rb ios/HerbFitz.xcodeproj HerbFitz
fi
- add this script in package.json
"eas-build-post-install": "chmod +x ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb && ./eas-build-post-install.sh"
- now add the plugin in app.json
"plugins": [["./squareIOSBuildPhasePlugin.js"]]
Hi @aargon007 would this also work on expo projects
Hi @aargon007 would this also work on expo projects
Yes. but you have to make a development build to run the app
Okay thanks @aargon007, so if I get you clearly I have to
- In my expo project in the root folder, create the
reorderSquareIAPBuildPhase.rbor is that supposed to be in the ios root folder?
Same way run through to step 5 and then run npx expo run:ios before then running eas build -p ios
Please could you help clarify me on this. Thank you.
Okay thanks @aargon007, so if I get you clearly I have to
- In my expo project in the root folder, create the
reorderSquareIAPBuildPhase.rbor is that supposed to be in the ios root folder?Same way run through to step 5 and then run
npx expo run:iosbefore then runningeas build -p iosPlease could you help clarify me on this. Thank you.
reorderSquareIAPBuildPhase.rb is a ruby file, will be in your root project folder. after all 5 step you can make dev or prod build
if it failed during build you can paste the log, i can help you
So I have completed from step 1 through 5. then ran npx expo prebuild --clean worked just fine. But when I ran eas build -p ios, I ran into this error.
Script 'eas-build-post-install' is present in package.json, running it...
yarn run v1.22.22
$ chmod +x ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb && ./eas-build-post-install.sh
./reorderSquareIAPBuildPhase.rb:12:in `<main>': undefined method `build_phases' for nil:NilClass (NoMethodError)
square_framework_run_script_index = target.build_phases.index { |b|
^^^^^^^^^^^^^
Sorting sources in ios/PluritonguesApp.xcodeproj for target HerbFitz
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run eas-build-post-install exited with non-zero code: 1```
So I have completed from step 1 through 5. then ran
npx expo prebuild --cleanworked just fine. But when I raneas build -p ios, I ran into this error.Script 'eas-build-post-install' is present in package.json, running it... yarn run v1.22.22 $ chmod +x ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb && ./eas-build-post-install.sh ./reorderSquareIAPBuildPhase.rb:12:in `<main>': undefined method `build_phases' for nil:NilClass (NoMethodError) square_framework_run_script_index = target.build_phases.index { |b| ^^^^^^^^^^^^^ Sorting sources in ios/PluritonguesApp.xcodeproj for target HerbFitz error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. yarn run eas-build-post-install exited with non-zero code: 1```
HerbFitz was my app name. instead of it use your app name in eas-build-post-install.sh
Ahhh, thanks a lot. realized that mistake immediately after I sent the comment. Fixed it now, and it worked, and submitted to TestFlight.