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

Build for ios #3612

Merged
merged 5 commits into from
Dec 6, 2021
Merged

Build for ios #3612

merged 5 commits into from
Dec 6, 2021

Conversation

AJenbo
Copy link
Member

@AJenbo AJenbo commented Nov 26, 2021

For testing using the simulator:

cmake -S. -Bbuild -G Xcode -DCMAKE_TOOLCHAIN_FILE=../CMake/ios.toolchain.cmake -DPLATFORM=SIMULATOR64

For running on a real device:

cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/ios.toolchain.cmake  -DENABLE_BITCODE=0 -DPLATFORM=OS64
cmake --build build -j $(sysctl -n hw.physicalcpu) --config Release
cd build
mkdir Payload
mv devilutionx.app Payload
zip -r devilutionx.ipa Payload

Open the generated Xcode project.

Add the MPQ files

image

image

  • Add CI build

@JoBergeron
Copy link
Contributor

To distribute the iOS version, you could package a .IPA and hand that out. After people install it using something like AltServer, you could simply have the user copy the .MPQ to a folder on their phone.

@AJenbo
Copy link
Member Author

AJenbo commented Nov 26, 2021

@JoBergeron do you know how the app would then locate or gain access to the mpq file?

@JoBergeron
Copy link
Contributor

Launching the app could create a local folder where it would look for the file. You could inform the user to simply copy the file there. iOS apps can create a local folder on the user's device.

@AJenbo
Copy link
Member Author

AJenbo commented Nov 26, 2021

Launching the app could create a local folder where it would look for the file. You could inform the user to simply copy the file there. iOS apps can create a local folder on the user's device.

That sounds perfect. Do you have any references for that?

@JoBergeron
Copy link
Contributor

JoBergeron commented Nov 26, 2021

I know RetroArch does stuff like that. https://github.com/libretro/RetroArch

I found this code from an example somewhere that could help as well

do
{
// Find Application Support directory
let fileManager = FileManager.default
let appSupportURL = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
// Create subdirectory
let directoryURL = appSupportURL.appendingPathComponent("com.myCompany.myApp")
try fileManager.createDirectory (at: directoryURL, withIntermediateDirectories: true, attributes: nil)
// Create document
let documentURL = directoryURL.appendingPathComponent ("MyFile.test")
try document.write (to: documentURL, ofType: "com.myCompany.test")
}
catch
{
print("An error occured")
}

@MaxDesiatov
Copy link
Contributor

In my previous local builds I just embedded .mpq into the Xcode project, as a resource file. This made it much easier to run things, without a need to point to these resources after launch. Should be possible with CMake too, but may not be practical for .ipa re-distribution.

@JoBergeron
Copy link
Contributor

Distributing an .ipa file would also let people who don't have a Mac "sideload" the game. (Assuming they have a Windows PC)

@bubio
Copy link
Contributor

bubio commented Nov 26, 2021

@AJenbo
I think you can use this to transfer mpq file.

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20

@JoBergeron
Copy link
Contributor

@AJenbo I think you can use this to transfer mpq file.

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20

That's one way to do it I guess. I simply put stuff on icloud or dropbox or even sometimes just on a network share.

@AJenbo
Copy link
Member Author

AJenbo commented Nov 26, 2021

That's another good method we should also support 👍

@bubio
Copy link
Contributor

bubio commented Nov 26, 2021

Like this!
スクリーンショット 2021-11-27 8 48 34

@bubio
Copy link
Contributor

bubio commented Nov 26, 2021

It would be more convenient to be able to read from cloud storage.

If you can use this, you can access iCloud.
https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller

@bubio
Copy link
Contributor

bubio commented Nov 27, 2021

@AJenbo
You may need the T option to build with the new Xcode.

cmake .. -G Xcode -T buildsystem=1 -DCMAKE_TOOLCHAIN_FILE=../../ios-cmake/ios.toolchain.cmake -DPLATFORM=SIMULATOR64

https://cmake.org/cmake/help/latest/generator/Xcode.html#xcode-build-system-selection

@AJenbo
Copy link
Member Author

AJenbo commented Nov 27, 2021

Atm I only have Xcode 10.1 available to me :)

@bubio
Copy link
Contributor

bubio commented Nov 27, 2021

I tried it with Xcode 13, but if I didn't specify an old build system in the T option, the build failed.

@JoBergeron
Copy link
Contributor

It would be more convenient to be able to read from cloud storage.

If you can use this, you can access iCloud.

https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller

Can you pick more than 1 file though? What if you want to load the hellfire mpq files as well?

@AJenbo
Copy link
Member Author

AJenbo commented Nov 27, 2021

I tried it with Xcode 13, but if I didn't specify an old build system in the T option, the build failed.

Could you let me know what error you got, I have to patch 3 files in SDL because of my old Xcode.

@bubio
Copy link
Contributor

bubio commented Nov 27, 2021

I'm out now, so I'll check it when I get home.
Sorry.

@bubio
Copy link
Contributor

bubio commented Nov 27, 2021

@AJenbo
Is it too late?
Errors are as follows.


CMake Error in CMakeLists.txt:
The custom command generating

/Users/bubio/dev/etc/devilutionX_iOS/iOS/bg.gmo

is attached to multiple targets:

pofiles_1
devilutionx_copied_assets

but none of these is a common dependency of the other(s). This is not
allowed by the Xcode "new build system".

CMake Error in iOS/_deps/fmt-src/CMakeLists.txt:
The custom command generating

/Users/bubio/dev/etc/devilutionX_iOS/iOS/bg.gmo

is attached to multiple targets:

pofiles_1
devilutionx_copied_assets

but none of these is a common dependency of the other(s). This is not
allowed by the Xcode "new build system".

CMake Error in iOS/_deps/sdl2-src/CMakeLists.txt:
The custom command generating

/Users/bubio/dev/etc/devilutionX_iOS/iOS/bg.gmo

is attached to multiple targets:

pofiles_1
devilutionx_copied_assets

but none of these is a common dependency of the other(s). This is not
allowed by the Xcode "new build system".

CMake Error in iOS/_deps/sdl_audiolib-src/CMakeLists.txt:
The custom command generating

/Users/bubio/dev/etc/devilutionX_iOS/iOS/bg.gmo

is attached to multiple targets:

pofiles_1
devilutionx_copied_assets

but none of these is a common dependency of the other(s). This is not
allowed by the Xcode "new build system".


@bubio
Copy link
Contributor

bubio commented Nov 27, 2021

@AJenbo

I tried to build it in the following environment:
macOS: 12.0.1(21A559)
Xcode: Version 13.1 (13A1030d)


ld: building for iOS Simulator, but linking in dylib built for macOS, file '/usr/X11R6/lib/libpng.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

スクリーンショット 2021-11-27 18 24 03

I do the following:
copy it from _deps/sdl2-build/Debug-iphonesimulator/ to Debug-iphonesimulator/
edit of line 33 in _deps/sdl2-src/src/stdlib/SDL_iconv.c: #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -> #if 0

@glebm
Copy link
Collaborator

glebm commented Nov 27, 2021

libpng stuff may be fixed by #3618

.github/workflows/iOS.yml Outdated Show resolved Hide resolved
.github/workflows/iOS.yml Outdated Show resolved Hide resolved
.github/workflows/iOS.yml Outdated Show resolved Hide resolved
@AJenbo AJenbo marked this pull request as ready for review December 6, 2021 12:28
@AJenbo AJenbo requested a review from glebm December 6, 2021 12:31
@AJenbo
Copy link
Member Author

AJenbo commented Dec 6, 2021

Note: Install instructions will be added along side #3612 as that will change the procedure.

@bubio
Copy link
Contributor

bubio commented Dec 6, 2021

@AJenbo
Cmake passed.
I got the following error in Xcode.

/Users/bubio/dev/etc/devilutionX_iOS/build/_deps/png-build/DevilutionX.build/Release-iphonesimulator/png_static.build/Script-DEBF280E599DF4F3E619FBFF.sh: line 8: cd: /Users/bubio/dev/etc/devilutionX_iOS/build/_deps/png-build/Release${EFFECTIVE_PLATFORM_NAME}: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code

@AJenbo AJenbo merged commit f312584 into master Dec 6, 2021
@AJenbo AJenbo deleted the ios branch December 6, 2021 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants