Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CR] feat: iOS build #77197

Draft
wants to merge 53 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
61975c2
ios build
sonphantrung Nov 2, 2024
fa4d9ee
dealing with the mess
sonphantrung Nov 2, 2024
5a4f6b2
add missing file include
sonphantrung Nov 2, 2024
a25e1f8
goofy ahh shenanigans
sonphantrung Nov 3, 2024
4e338cd
ok
sonphantrung Nov 3, 2024
b1b14d9
typo
sonphantrung Nov 3, 2024
ac2c50e
clipboard mistake
sonphantrung Nov 3, 2024
b0b9b54
mind boggling
sonphantrung Nov 3, 2024
63d8e77
Update sdltiles.cpp
sonphantrung Nov 3, 2024
44824bd
temporarily axing ifdefs
sonphantrung Nov 3, 2024
f410b98
more axing
sonphantrung Nov 3, 2024
1c37b59
remove ifdefs, for now
sonphantrung Nov 3, 2024
945e2b9
build and run
sonphantrung Nov 3, 2024
9b954ce
ios is not ready for this
sonphantrung Nov 3, 2024
f10cd4c
it shucks
sonphantrung Nov 3, 2024
fd031ad
tweakin'
sonphantrung Nov 4, 2024
4a47ade
moar tweaks
sonphantrung Nov 4, 2024
0e7ee92
hmmm
sonphantrung Nov 5, 2024
dcd4437
re-add
sonphantrung Nov 6, 2024
7908e7a
edit
sonphantrung Nov 7, 2024
7cb8d37
hmmm
sonphantrung Nov 8, 2024
cfad50d
huh
sonphantrung Nov 8, 2024
ede4b71
experiment
sonphantrung Nov 8, 2024
e4eb36d
tf
sonphantrung Nov 8, 2024
dbb4f61
dunno
sonphantrung Nov 8, 2024
9879949
pain
sonphantrung Nov 8, 2024
6481e5c
a
sonphantrung Nov 9, 2024
8b6fec4
a
sonphantrung Nov 9, 2024
305e6bb
b
sonphantrung Nov 9, 2024
db4485a
c
sonphantrung Nov 9, 2024
8a33973
d
sonphantrung Nov 9, 2024
47c6263
experimenting
sonphantrung Nov 10, 2024
d99c169
track down the current display problem
sonphantrung Nov 11, 2024
834514b
debug the problem
sonphantrung Nov 12, 2024
5cebed8
umm
sonphantrung Nov 12, 2024
80e133e
Merge branch 'CleverRaven:master' into ios-build
sonphantrung Nov 13, 2024
8da85dc
investigating touch problems
sonphantrung Nov 13, 2024
f60aa6f
diagnosing touch not functioning
sonphantrung Nov 15, 2024
67b2b42
more debugging
sonphantrung Nov 16, 2024
95924b9
Use SDL_GetRenderOutputSize instead
sonphantrung Nov 17, 2024
d002847
add missing header
sonphantrung Nov 18, 2024
a3fd06b
Update sdltiles.cpp
sonphantrung Nov 18, 2024
02c66c5
Merge branch 'CleverRaven:master' into ios-build
sonphantrung Nov 19, 2024
6d44119
Merge branch 'CleverRaven:master' into ios-build
sonphantrung Nov 22, 2024
8cae75a
temporarily culling the ifdef
sonphantrung Nov 22, 2024
882fbce
more debugging
sonphantrung Nov 23, 2024
34efe38
Update sdltiles.cpp
sonphantrung Nov 25, 2024
9e02b65
hunt down the problem
sonphantrung Nov 26, 2024
8f13bf0
ik
sonphantrung Nov 27, 2024
51b5b46
hunt down the touch
sonphantrung Nov 29, 2024
1a28f27
Merge branch 'master' into ios-build
sonphantrung Dec 7, 2024
9b26760
Merge branch 'CleverRaven:master' into ios-build
sonphantrung Dec 22, 2024
75f1547
desperate for finding the fix
sonphantrung Dec 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ stage

# Apple Xcode IDE
Xcode/
*.xcodeproj

# gdb
.gdb_history
Expand Down Expand Up @@ -245,5 +246,8 @@ weather.output
.jekyll-metadata
Gemfile.lock

# xcodegen developer id file
xcode_dev_id.yml

# VERSION.txt generated by our CMakeLists.txt
VERSION.txt
Binary file added build-data/ios/resources/AppIcon.icns
Binary file not shown.
Binary file added build-data/ios/resources/LaunchScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions build-data/ios/resources/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="ipad11_0rounded" orientation="landscape" layout="fullscreen" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="1194" height="834"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" image="LaunchScreen.png" translatesAutoresizingMaskIntoConstraints="NO" id="jgb-MO-6eD">
<rect key="frame" x="0.0" y="0.0" width="1194" height="834"/>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="jgb-MO-6eD" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="FjW-en-yZJ"/>
<constraint firstAttribute="bottom" secondItem="jgb-MO-6eD" secondAttribute="bottom" id="noI-PU-2X1"/>
<constraint firstAttribute="trailing" secondItem="jgb-MO-6eD" secondAttribute="trailing" id="q5b-zf-rlf"/>
<constraint firstItem="jgb-MO-6eD" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="qPb-Yb-9bz"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52.763819095477388" y="374.8201438848921"/>
</scene>
</scenes>
<resources>
<image name="LaunchScreen.png" width="1024" height="1024"/>
</resources>
</document>
51 changes: 51 additions & 0 deletions build-scripts/ios-xcode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
# adapted from https://marcelbraghetto.github.io/a-simple-triangle/

# Given the name of a Homebrew formula, check if its installed and if not, install it.
fetch_brew_dependency() {
FORMULA_NAME=$1

echo "Checking for Brew dependency: '$FORMULA_NAME'."

if brew ls --versions $FORMULA_NAME > /dev/null; then
echo "Dependency '$FORMULA_NAME' is already installed, continuing ..."
else
echo "Dependency '$FORMULA_NAME' is not installed, installing via Homebrew ..."
brew install $FORMULA_NAME
fi
}

fetch_brew_dependency "xcodegen"

echo "Checking for build folder ..."
if [ ! -d "../build" ]; then
mkdir ../build
fi

echo "Checking for libs folder ..."
if [ ! -d "../build/libs" ]; then
echo "ERROR: Static SDL libraries not found at /build/libs ..."
echo "Reffer to /doc/COMPILING/COMPILING-XCODE.md for instructions on how to build the static libraries."
exit
fi


if [ ! -f "xcode_dev_id.yml" ]; then
echo "xcode_dev_id.yml not found -"
echo " You will need to manually specify your Development Team for signing in Xcode."
echo " See the following link for details:"
echo " https://help.apple.com/xcode/mac/current/#/dev23aab79b4"
echo ""
echo "To avoid this message in the future see the xcode_dev_id_example.yml file."
fi
# Invoke the xcodegen tool to create our project file.
echo "Generating Xcode project"
xcodegen -s xcodegen-cataclysm.yml -p ../build

if [ ! -f "../build/CataclysmExperimental.xcodeproj" ]; then
echo "Project built successfully. Launching Xcode..."
open ../build/CataclysmExperimental.xcodeproj
exit
else
echo "Error in project creation process. Review output above for errors."
fi
5 changes: 5 additions & 0 deletions build-scripts/xcode_dev_id_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For more information on setting up a development team see:
# https://help.apple.com/developer-account/#/devf2eb157f8

settings:
DEVELOPMENT_TEAM: XXXXXXXXXX
149 changes: 149 additions & 0 deletions build-scripts/xcodegen-cataclysm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CataclysmExperimental

include:
# see xcode_dev_id_example.yml
- xcode_dev_id.yml

options:
bundleIdPrefix: com.cataclysmdda.en.cataclysm
groupOrdering:
- order: [Sources, Resources, Frameworks, Products]
usesTabs: false
indentWidth: 4
tabWidth: 4
deploymentTarget:
iOS: "15.0"

schemes:
CataclysmExperimental:
build:
targets:
CataclysmExperimental: all

targets:
CataclysmExperimental:
type: application
platform: iOS
info:
path: ../build/Info.plist
properties:
LSRequiresIPhoneOS: true
UIRequiredDeviceCapabilities: [arm64]
UIRequiresFullScreen: true
UIStatusBarHidden: true
UISupportedInterfaceOrientations:
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
UILaunchStoryboardName: LaunchScreen
CFBundleIconFile: AppIcon.icns
UIApplicationSupportsIndirectInputEvents: true
UIFileSharingEnabled: true
LSSupportsOpeningDocumentsInPlace: true
sources:
- path: ../src
name: Sources
buildPhase: sources
includes:
- "**/swift/*.swift"
- "**/third-party/imgui/*.cpp"
- "**/third-party/imgui/*.h"
- "*.cpp"
- "*.h"
excludes:
- "*.txt"
- "*.in"
- "*.rc"
- "*.cmake"
- "**/third-party/flatbuffers/**"
- "**/third-party/ghc/**"
- "**/third-party/imtui/**"
- "**/third-party/pinyin/**"
- "**/chkjson/**"
- path: ../build-data/ios/resources/LaunchScreen.storyboard
group: Resources
- path: ../build-data/ios/resources/AppIcon.icns
group: Resources
buildPhase: resources
- path: ../build-data/ios/resources/LaunchScreen.png
group: Resources
buildPhase: resources
# TODO: Imitate cmake selection for data and gfx
- path: ../data
type: folder
group: Resources
buildPhase: resources
- path: ../gfx
type: folder
group: Resources
buildPhase: resources
- path: ../ios
type: folder
group: Resources
buildPhase: resources
settings:
base:
CLANG_CXX_LANGUAGE_STANDARD: c++17
CMAKE_CXX_STANDARD: 17
CMAKE_CXX_STANDARD_REQUIRED: ON
CMAKE_CXX_EXTENSIONS: OFF
CLANG_WARN_DOCUMENTATION_COMMENTS: false
CLANG_ENABLE_MODULES: YES
GCC_WARN_64_TO_32_BIT_CONVERSION: No
SWIFT_OBJC_INTEROP_MODE: objcxx
HEADER_SEARCH_PATHS:
- ../src/third-party/**
- ../build/libs/headers
LIBRARY_SEARCH_PATHS:
- ../build/libs/
- $(inherited)
GCC_PREPROCESSOR_DEFINITIONS:
- GIT_VERSION
- TILES
- BACKTRACE
- SDL_SOUND
- $(inherited)
OTHER_CPLUSPLUSFLAGS:
#- "-Werror"
- "-Wall -Wextra -Wformat-signedness -Wlogical-op -Wmissing-declarations -Wmissing-noreturn"
- "-Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wpedantic -Wsuggest-override"
- "-Wunused-macros -Wzero-as-null-pointer-constant -Wno-unknown-warning-option -Wno-nullability-extension -Wredundant-decls"
- "-fsigned-char"
OTHER_LDFLAGS:
- "-Wl,-ld_classic"
Debug:
OTHER_CPLUSPLUSFLAGS:
- "-Og -pthread '-std=c++17'"
Release:
GCC_PREPROCESSOR_DEFINITIONS:
- RELEASE
OTHER_CPLUSPLUSFLAGS:
- "-Os -DNDEBUG -pthread '-std=c++17'"
dependencies:
# TODO: build libcataclysm-tiles-common.a as it's own step again. Currently rolled in to single build
# - framework: libs/libcataclysm-tiles-common.a
- framework: ../build/libs/libSDL2.a
- framework: ../build/libs/libSDL2_image.a
- framework: ../build/libs/libSDL2_mixer.a
- framework: ../build/libs/libSDL2_ttf.a
- sdk: libllvm-flatbuffers.tbd
- sdk: libz.tbd
- sdk: libncurses.tbd
- sdk: MobileCoreServices.framework
- sdk: CoreMotion.framework
- sdk: CoreGraphics.framework
- sdk: CoreHaptics.framework
- sdk: AudioToolbox.framework
- sdk: CoreAudio.framework
- sdk: QuartzCore.framework
- sdk: GameController.framework
- sdk: Foundation.framework
- sdk: OpenGLES.framework
- sdk: UIKit.framework
- sdk: AVFoundation.framework
- sdk: ImageIO.framework
- sdk: Metal.framework
configs:
Debug:
DEBUG_MODE: YES
Release:
DEBUG_MODE: NO
2 changes: 1 addition & 1 deletion data/json/construction/walls.json
Original file line number Diff line number Diff line change
Expand Up @@ -1408,4 +1408,4 @@
"pre_terrain": "t_wall_wood",
"post_terrain": "t_wood_wall_y"
}
]
]
56 changes: 56 additions & 0 deletions doc/COMPILING_XCODE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Disclaimer

**WARNING**: Xcode build should be used for _iOS builds only_. This can only be done on OS X.

To build CataclysmDDA for other OS, see:

- [COMPILING.md](COMPILING.md)

# Prerequisites

The project will build for tiles and sound by default.

_Note: At this time there is no specific guidance on minimum versioning, all testing has been done on iOS 15.0+_

### Get the tools

- Xcode on the AppStore - https://apps.apple.com/us/app/xcode/id497799835.
- Install Brew - https://brew.sh/
Or in a terminal window run:
`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`

### Build SDL libs for iOS

You will need to download the SDL source code and build static libraries for iOS (ARM64). The source code is available [here](https://github.com/libsdl-org/SDL). Directions on building the SDL for iOS in Xcode is available [here](https://github.com/libsdl-org/SDL/blob/main/docs/README-ios.md). The project setup will expect to find the static libraries in `/build/libs` and related header files in `/build/libs/headers`.

### (Optional) Apple Developer ID pre-configuration

If you already know you developer ID, you can add it to the file `xcode_dev_id_example.yml`, and rename the file to `xcode_dev_id.yml`.

Additional details are in the example file.

### Run the script

Open terminal window to the build-scripts directory and run:
`./ios-xcode.sh`

If the Xcode project builds successfully Xcode will try to open automatically.

### Xcode Steps

If you have not already set the developer ID you will need to set it in the Project settings in the section "Signing & Capabilities"

Product->Run will build for debugging
Product->Archive will build a release version.

### Play!

Configuration and save files are accessible in your documents folder via the Files app. This should allow you to import and export data from other places. For now there is no auto-synchronization with any cloud based data services.

### Notes

I appreciate the many folks in the community who have contributed to making such a wonderful game, and my intent was to make sure that everyone had access to an iPad version that was freely available and built to integrate with the existing codebase, making it inclusive of experimental builds.

If there are other setup related steps needed, please update accordingly or find me on Discord with questions or issues (smileynet on both Official and Community servers) understanding that my support of this build is at-will and may be intermittent. (Written on 10/26/2022, if you are unable to @ me on either server, I have likely wandered on down the road or been ill prepared for an encounter with a Kevlar Hulk o.O)

My use case for this build is playing on an iPad with an attached magic keyboard, so while I've tested the soft keyboard's basic functionality, at this point I have not done any of the UI enhancements found in the other ports found on the AppStore (or the Android build, but with any luck that will be reasonable to reuse in this case).
2 changes: 1 addition & 1 deletion doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4731,4 +4731,4 @@ Combination of values work as `and`, no matter how they are arranged. This two n
```
```json
"search_data": [ { "category": "weapons", "wielded_only": true } ]
```
```
Binary file added ios/joystick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3717,4 +3717,4 @@ bool try_fuel_fire( player_activity &act, Character &you, const bool starting_fi
}
}
return true;
}
}
2 changes: 1 addition & 1 deletion src/advanced_inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#include "units_utility.h"
#include "vehicle.h"

#if defined(__ANDROID__)
#if defined(__ANDROID__) || defined(__IPHONEOS__)
# include <SDL_keyboard.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/advanced_inv_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class item_category;

#if defined(__ANDROID__)
#if defined(__ANDROID__) || defined(__IPHONEOS__)
# include <SDL_keyboard.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/bionics_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ void avatar::power_bionics()
scroll_position = clamp( scroll_position, 0, max_scroll_position );
cursor = clamp<int>( cursor, 0, current_bionic_list->size() );

#if defined(__ANDROID__)
#if defined(__ANDROID__) || defined(__IPHONEOS__)
ctxt.get_registered_manual_keys().clear();
for( size_t i = 0; i < current_bionic_list->size(); i++ ) {
ctxt.register_manual_key( ( *current_bionic_list )[i]->invlet,
Expand Down
2 changes: 1 addition & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ void cata_tiles::draw( const point &dest, const tripoint &center, int width, int
return;
}

#if defined(__ANDROID__)
#if defined(__ANDROID__) || defined(__IPHONEOS__)
// Attempted bugfix for Google Play crash - prevent divide-by-zero if no tile
// width/height specified
if( tile_width == 0 || tile_height == 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ std::string game_info::operating_system()
#if TARGET_IPHONE_SIMULATOR == 1
/* iOS in Xcode simulator */
return "iOS Simulator";
#elif TARGET_OS_IPHONE == 1
#elif TARGET_OS_IPHONE == 1 || defined(__IPHONEOS__)
/* iOS on iPhone, iPad, etc. */
return "iOS";
#elif TARGET_OS_MAC == 1
Expand Down
Loading
Loading