diff --git a/.github/workflows/ios-compile-test.yml b/.github/workflows/ios-compile-test.yml new file mode 100644 index 00000000..07b6a373 --- /dev/null +++ b/.github/workflows/ios-compile-test.yml @@ -0,0 +1,81 @@ +name: iOS App Compilation & Packaging + +on: + push: + branches: [ main, dev ] + pull_request: + +jobs: + build-ipa: + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compile and Run Tilemap Generator + run: | + # 1. Compile tilemap.c natively on the runner host + cd nethack/win + gcc -I../include -I../src -Wp,-w share/tilemap.c -o tilemap_generator + + # 2. Execute the generator to output the missing tile mapping files + ./tilemap_generator + + # 3. Verify the generated file exists in the expected path + cd .. + ls -la src/ + cd .. + + - name: Force Xcode Version + run: sudo xcode-select -s /Applications/Xcode.app + + - name: Fix Misplaced Entitlements Warning + run: | + sed -i '' '/Entitlements.pbxproj/d' iNetHack.xcodeproj/project.pbxproj || true + sed -i '' '/Entitlements.plist/d' iNetHack.xcodeproj/project.pbxproj || true + + - name: "Step 1: Initialize Source and Sandbox Mock Assets" + run: | + mkdir -p dat lib nethack/dat nethack/lib + echo "mock data" > dat/nhdat + echo "mock library" > lib/placeholder.txt + echo "mock data" > nethack/dat/nhdat + echo "mock library" > nethack/lib/placeholder.txt + + # Pre-build target structure for the real phone deployment path + mkdir -p build_output/Build/Products/Debug-iphoneos/iNetHack2.app/lib + echo "mock data" > build_output/Build/Products/Debug-iphoneos/iNetHack2.app/nhdat + echo "mock library" > build_output/Build/Products/Debug-iphoneos/iNetHack2.app/lib/placeholder.txt + + - name: "Step 2: Compile App for Physical iPhone Hardware" + run: | + # We change the SDK to 'iphoneos' and target generic iOS devices + # so Xcode generates an arm64 binary for real phone processors. + xcodebuild build \ + -project "iNetHack.xcodeproj" \ + -scheme "iNetHack2" \ + -configuration Debug \ + -sdk iphoneos \ + -destination "generic/platform=iOS" \ + -derivedDataPath "build_output" \ + ONLY_ACTIVE_ARCH=NO \ + ARCHS="arm64" \ + CODE_SIGNING_ALLOWED=NO \ + CODE_SIGNING_REQUIRED=NO \ + COMPILER_INDEX_STORE_ENABLE=NO \ + XCODE_BUILD_SYSTEM_ENABLE_EAGER_LINKING=NO + + - name: "Step 3: Package App Layout into an .ipa Installer" + run: | + # iOS requires the .app folder to live inside a folder named 'Payload' + # inside the zip archive to recognized it as an installable app (.ipa) + mkdir -p Payload + cp -r build_output/Build/Products/Debug-iphoneos/iNetHack2.app Payload/ + zip -r iNetHack2.ipa Payload + + - name: "Step 4: Upload Installer to GitHub Actions" + uses: actions/upload-artifact@v4 + with: + name: iNetHack2-iPhone-Installer + path: iNetHack2.ipa diff --git a/Classes/iNethackAppDelegate.m b/Classes/iNethackAppDelegate.m index 2f985ade..68cf7ca2 100644 --- a/Classes/iNethackAppDelegate.m +++ b/Classes/iNethackAppDelegate.m @@ -35,34 +35,29 @@ @implementation iNethackAppDelegate @synthesize window; -- (void) loggingTest { - NSString *tmpFile = [FileLogger tmpFileName]; - NSLog(@"tmpFile %@", tmpFile); - for (int i = 0; i < 500; ++i) { - FileLogger *logger = [[FileLogger alloc] initWithFile:tmpFile maxSize:250]; - for (int j = 0; j < 1000; ++j) { - [logger logString:[NSString stringWithFormat:@"This is some logged line #%04d", j]]; - } - [logger release]; - } - [[NSFileManager defaultManager] removeItemAtPath:tmpFile error:NULL]; -} - - (void)applicationDidFinishLaunching:(UIApplication *)application { -// [self loggingTest]; -// return; - + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + BOOL startAsBlind = [defaults boolForKey:@"blind"]; + BOOL startAsNudist = [defaults boolForKey:@"nudist"]; + NSMutableArray *activeOptions = [NSMutableArray array]; + + if (startAsBlind) { + [activeOptions addObject:@"blind"]; + } + if (startAsNudist) { + [activeOptions addObject:@"nudist"]; + } + if ([activeOptions count] > 0) { + NSString *optionsString = [activeOptions componentsJoinedByString:@","]; + setenv("NETHACKOPTIONS", [optionsString UTF8String], 1); + } else { + unsetenv("NETHACKOPTIONS"); + } BOOL badBonesSeen = [self checkNetHackDirectories]; - //iNethack2: UPDATE: iOS9 the below fix actually causese issues. commenting out. - // [application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; // prevent start orientation bug [application setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; // use mainNavigationController.view to skip main menu - - //iNethack2 commented out below, added line after, to get rid of "Application windows are expected to have a root view controller at the end of application launch" message - // [window addSubview:mainNavigationController.view]; [self.window setRootViewController:mainNavigationController]; - //[window addSubview:mainMenuViewController.view]; [window makeKeyAndVisible]; self.window.frame = [UIScreen mainScreen].bounds; //iNethack2 [application setStatusBarHidden:YES]; @@ -74,9 +69,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application { } - (void) applicationDidEnterBackground:(UIApplication *)application { - // 2.0.8 and earlier we used to run the routine when app was about to terminate to do a save. - // return [self applicationWillTerminate:application]; - // Save the zoom level [[NSUserDefaults standardUserDefaults] setFloat:[(MainView *) [[MainViewController instance] view] tileSize].width forKey:kKeyTileSize]; @@ -159,9 +151,6 @@ - (BOOL) checkNetHackDirectories { for (NSString *filename in filelist) { NSLog(@"file %@", filename); } - - // simple test case for UI interaction with bad bones - //[self createTestBadBonesFile]; filelist= [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"." error:nil]; diff --git a/Settings.bundle/advancedgameplay.plist b/Settings.bundle/advancedgameplay.plist index 9da07d6d..fa462f1e 100644 --- a/Settings.bundle/advancedgameplay.plist +++ b/Settings.bundle/advancedgameplay.plist @@ -29,6 +29,26 @@ DefaultValue + + Type + PSToggleSwitchSpecifier + Title + Blind + Key + blind + DefaultValue + + + + Type + PSToggleSwitchSpecifier + Title + Nudist + Key + nudist + DefaultValue + +