Add USE_IAP option to b-appstore.sh

This commit is contained in:
Henrik Rydgård
2025-05-25 11:04:40 +02:00
parent 164dd53a89
commit ddc5ec6611
4 changed files with 60 additions and 9 deletions
+17 -1
View File
@@ -134,10 +134,24 @@ endif()
if(GOLD) if(GOLD)
add_compile_definitions(GOLD) add_compile_definitions(GOLD)
message("Gold Build") message("Gold Build")
if(IOS_APP_STORE)
message("WARNING: Gold build for iOS is deprecated")
endif()
else() else()
message("Non-gold Build") message("Non-gold Build")
endif() endif()
if(USE_IAP)
if(GOLD)
message(FATAL_ERROR "USE_IAP and GOLD can't be enabled together")
endif()
if(NOT IOS_APP_STORE)
message(FATAL_ERROR "USE_IAP can only be enabled in app store builds")
endif()
message("USE_IAP for iOS enabled")
add_compile_definitions(USE_IAP)
endif()
if(IOS_APP_STORE) if(IOS_APP_STORE)
add_compile_definitions(PPSSPP_PLATFORM_IOS_APP_STORE) add_compile_definitions(PPSSPP_PLATFORM_IOS_APP_STORE)
add_compile_definitions(GLES_SILENCE_DEPRECATION) add_compile_definitions(GLES_SILENCE_DEPRECATION)
@@ -191,6 +205,8 @@ option(USE_ASAN "Use address sanitizer" OFF)
option(USE_UBSAN "Use undefined behaviour sanitizer" OFF) option(USE_UBSAN "Use undefined behaviour sanitizer" OFF)
option(USE_CCACHE "Use ccache if detected" ON) option(USE_CCACHE "Use ccache if detected" ON)
option(USE_NO_MMAP "Disable mmap usage" OFF) option(USE_NO_MMAP "Disable mmap usage" OFF)
option(USE_IAP "IAP enabled" OFF)
option(GOLD "Gold build" OFF)
if(USE_CCACHE) if(USE_CCACHE)
include(ccache) include(ccache)
@@ -2970,7 +2986,7 @@ if(IOS AND NOT LIBRETRO)
set(DISPLAY_NAME "PPSSPP") set(DISPLAY_NAME "PPSSPP")
endif() endif()
if(IOS_APP_STORE) if(IOS_APP_STORE)
message(STATUS "DevTeam: ${DEVELOPMENT_TEAM_ID} Icon: ${ICON_NAME} Target: ${TargetBin}") message(STATUS "DevTeam: ${DEVELOPMENT_TEAM_ID} Icon: ${ICON_NAME} Target: ${TargetBin} Gold: ${GOLD} IAP: ${USE_IAP}")
message(STATUS "CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") message(STATUS "CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
# This is for injecting the version into the plist, and also copying resources. # This is for injecting the version into the plist, and also copying resources.
+17 -2
View File
@@ -14,6 +14,11 @@ if [[ -z "${GOLD}" ]]; then
exit 1 exit 1
fi fi
if [[ -z "${USE_IAP}" ]]; then
echo "USE_IAP is not set (should be YES or NO), exiting"
exit 1
fi
FOLDER_NAME="build-ios" FOLDER_NAME="build-ios"
if [[ "$GOLD" = "YES" ]]; then if [[ "$GOLD" = "YES" ]]; then
@@ -23,6 +28,16 @@ else
echo "Non-GOLD build." echo "Non-GOLD build."
fi fi
if [[ "$USE_IAP" = "YES" ]]; then
if [[ "$GOLD" = "YES" ]]; then
echo "IAP and GOLD are both set to YES, which is invalid"
exit 1
fi
echo "IAP on."
else
echo "IAP off."
fi
echo "Clearing and re-creating output directory" echo "Clearing and re-creating output directory"
rm -rf $FOLDER_NAME rm -rf $FOLDER_NAME
mkdir $FOLDER_NAME mkdir $FOLDER_NAME
@@ -31,7 +46,7 @@ pushd $FOLDER_NAME
BUILD_TYPE=Release BUILD_TYPE=Release
cmake .. -DIOS_APP_STORE=ON -DGOLD=$GOLD -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake -DDEVELOPMENT_TEAM_ID=${DEVTEAM} -DIOS_PLATFORM=OS -GXcode cmake .. -DIOS_APP_STORE=ON -DGOLD=$GOLD -DUSE_IAP=$USE_IAP -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake -DDEVELOPMENT_TEAM_ID=${DEVTEAM} -DIOS_PLATFORM=OS -GXcode
# TODO: Get a MoltenVK somewhere. # TODO: Get a MoltenVK somewhere.
#cp ../MoltenVK/iOS/Frameworks/libMoltenVK.dylib PPSSPP.app/Frameworks #cp ../MoltenVK/iOS/Frameworks/libMoltenVK.dylib PPSSPP.app/Frameworks
popd popd
@@ -45,4 +60,4 @@ echo "*** Done. Now run the following command to open in XCode, then run or arch
echo " open $FOLDER_NAME/PPSSPP.xcodeproj" echo " open $FOLDER_NAME/PPSSPP.xcodeproj"
# To open the xcode project: # To open the xcode project:
# open build-ios/PPSSPP.xcodeproj # open build-ios/PPSSPP.xcodeproj
+24 -4
View File
@@ -6,11 +6,11 @@
#include "../ppsspp_config.h" #include "../ppsspp_config.h"
#if PPSSPP_PLATFORM(IOS_APP_STORE)
// Only one operation can be in progress at once. // Only one operation can be in progress at once.
@implementation IAPManager { @implementation IAPManager {
#ifdef USE_IAP
SKProduct *_goldProduct; SKProduct *_goldProduct;
#endif
int _pendingRequestID; int _pendingRequestID;
} }
@@ -24,21 +24,30 @@
} }
- (instancetype)init { - (instancetype)init {
#ifdef USE_IAP
if (self = [super init]) { if (self = [super init]) {
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
} }
#endif
return self; return self;
} }
- (void)startObserving { - (void)startObserving {
#ifdef USE_IAP
[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
#endif
} }
- (BOOL)isGoldUnlocked { - (BOOL)isGoldUnlocked {
#ifdef USE_IAP
return [[NSUserDefaults standardUserDefaults] boolForKey:@"isGold"]; return [[NSUserDefaults standardUserDefaults] boolForKey:@"isGold"];
#else
return false;
#endif
} }
- (void)buyGoldWithRequestID:(int)requestID { - (void)buyGoldWithRequestID:(int)requestID {
#ifdef USE_IAP
if (_pendingRequestID) { if (_pendingRequestID) {
ERROR_LOG(Log::IAP, "A transaction is pending. Failing the new request."); ERROR_LOG(Log::IAP, "A transaction is pending. Failing the new request.");
g_requestManager.PostSystemFailure(requestID); g_requestManager.PostSystemFailure(requestID);
@@ -55,9 +64,13 @@
NSLog(@"[IAPManager] In-App Purchases are disabled (requestID: %d)", requestID); NSLog(@"[IAPManager] In-App Purchases are disabled (requestID: %d)", requestID);
g_requestManager.PostSystemFailure(requestID); g_requestManager.PostSystemFailure(requestID);
} }
#else
g_requestManager.PostSystemFailure(requestID);
#endif
} }
- (void)restorePurchasesWithRequestID:(int)requestID { - (void)restorePurchasesWithRequestID:(int)requestID {
#ifdef USE_IAP
if (_pendingRequestID) { if (_pendingRequestID) {
ERROR_LOG(Log::IAP, "A transaction is pending. Failing the new request."); ERROR_LOG(Log::IAP, "A transaction is pending. Failing the new request.");
g_requestManager.PostSystemFailure(requestID); g_requestManager.PostSystemFailure(requestID);
@@ -68,8 +81,13 @@
// NOTE: This is deprecated, but StoreKit 2 is swift only. We'll keep using it until // NOTE: This is deprecated, but StoreKit 2 is swift only. We'll keep using it until
// there's a replacement. // there's a replacement.
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
#else
g_requestManager.PostSystemFailure(requestID);
#endif
} }
#ifdef USE_IAP
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
NSLog(@"Restore completed successfully (requestID: %d)", _pendingRequestID); NSLog(@"Restore completed successfully (requestID: %d)", _pendingRequestID);
g_requestManager.PostSystemSuccess(_pendingRequestID, "", 0); g_requestManager.PostSystemSuccess(_pendingRequestID, "", 0);
@@ -122,7 +140,10 @@
} }
} }
#endif
- (void)unlockGold { - (void)unlockGold {
#ifdef USE_IAP
INFO_LOG(Log::UI, "Unlocking gold reward!"); INFO_LOG(Log::UI, "Unlocking gold reward!");
// Write to user defaults to store the status. // Write to user defaults to store the status.
@@ -134,6 +155,7 @@
}); });
NSLog(@"[IAPManager] Gold unlocked!"); NSLog(@"[IAPManager] Gold unlocked!");
#endif
} }
static bool SafeStringEqual(NSString *a, NSString *b) { static bool SafeStringEqual(NSString *a, NSString *b) {
@@ -185,6 +207,4 @@ static bool SafeStringEqual(NSString *a, NSString *b) {
} }
} }
#endif
@end @end
+2 -2
View File
@@ -373,17 +373,17 @@ bool System_GetPropertyBool(SystemProperty prop) {
// If a hardware keyboard is connected, and we add support, we could return false here. // If a hardware keyboard is connected, and we add support, we could return false here.
return true; return true;
case SYSPROP_APP_GOLD: case SYSPROP_APP_GOLD:
// TODO: Check the IAP status.
#ifdef GOLD #ifdef GOLD
// This is deprecated. // This is deprecated.
return true; return true;
#elif PPSSPP_PLATFORM(IOS_APP_STORE) #elif PPSSPP_PLATFORM(IOS_APP_STORE)
// Check the IAP status.
return [[IAPManager sharedIAPManager] isGoldUnlocked]; return [[IAPManager sharedIAPManager] isGoldUnlocked];
#else #else
return false; return false;
#endif #endif
case SYSPROP_USE_IAP: case SYSPROP_USE_IAP:
#if PPSSPP_PLATFORM(IOS_APP_STORE) && !defined(GOLD) #if PPSSPP_PLATFORM(IOS_APP_STORE) && defined(USE_IAP)
return true; return true;
#else #else
return false; return false;