diff --git a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj index fd609a73e8c..6ca5e888b5a 100644 --- a/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj +++ b/misc/dist/ios_xcode/godot_ios.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 1F1575721F582BE20003B888 /* dylibs in Resources */ = {isa = PBXBuildFile; fileRef = 1F1575711F582BE20003B888 /* dylibs */; }; - DEADBEEF2F582BE20003B888 /* $binary.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DEADBEEF1F582BE20003B888 /* $binary.a */; }; + DEADBEEF2F582BE20003B888 /* $binary.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEADBEEF1F582BE20003B888 /* $binary.xcframework */; }; $modules_buildfile 1FF8DBB11FBA9DE1009DE660 /* dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */; }; D07CD44E1C5D589C00B7FB28 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D07CD44D1C5D589C00B7FB28 /* Images.xcassets */; }; @@ -33,7 +33,7 @@ /* Begin PBXFileReference section */ 1F1575711F582BE20003B888 /* dylibs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = dylibs; path = "$binary/dylibs"; sourceTree = ""; }; - DEADBEEF1F582BE20003B888 /* $binary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = godot; path = "$binary.a"; sourceTree = ""; }; + DEADBEEF1F582BE20003B888 /* $binary.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = godot; path = "$binary.xcframework"; sourceTree = ""; }; $modules_fileref 1FF4C1881F584E6300A41E41 /* $binary.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "$binary.entitlements"; sourceTree = ""; }; 1FF8DBB01FBA9DE1009DE660 /* dummy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = dummy.cpp; sourceTree = ""; }; @@ -52,7 +52,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - DEADBEEF2F582BE20003B888 /* $binary.a */, + DEADBEEF2F582BE20003B888 /* $binary.xcframework */, $modules_buildphase $additional_pbx_frameworks_build ); @@ -84,7 +84,7 @@ D0BCFE3618AEBDA2004A7AAE /* Frameworks */ = { isa = PBXGroup; children = ( - DEADBEEF1F582BE20003B888 /* $binary.a */, + DEADBEEF1F582BE20003B888 /* $binary.xcframework */, $modules_buildgrp $additional_pbx_frameworks_refs ); diff --git a/misc/dist/ios_xcode/libgodot.iphone.debug.fat.a b/misc/dist/ios_xcode/libgodot.iphone.debug.fat.a deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/Info.plist b/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/Info.plist new file mode 100644 index 00000000000..846533594fd --- /dev/null +++ b/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/Info.plist @@ -0,0 +1,40 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + libgodot.a + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + libgodot.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64/empty b/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64_x86_64-simulator/empty b/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64_x86_64-simulator/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/ios_xcode/libgodot.iphone.debug.xcframework/ios-arm64_x86_64-simulator/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/ios_xcode/libgodot.iphone.release.fat.a b/misc/dist/ios_xcode/libgodot.iphone.release.fat.a deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/Info.plist b/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/Info.plist new file mode 100644 index 00000000000..846533594fd --- /dev/null +++ b/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/Info.plist @@ -0,0 +1,40 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + libgodot.a + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + libgodot.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/ios-arm64/empty b/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/ios-arm64/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/ios-arm64/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/ios-arm64_x86_64-simulator/empty b/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/ios-arm64_x86_64-simulator/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/ios_xcode/libgodot.iphone.release.xcframework/ios-arm64_x86_64-simulator/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/iphone-mono-libs/libmono-native.xcframework/Info.plist b/misc/dist/iphone-mono-libs/libmono-native.xcframework/Info.plist new file mode 100644 index 00000000000..afb8cdc88a8 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmono-native.xcframework/Info.plist @@ -0,0 +1,40 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + libmono-native.a + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + libmono-native.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/misc/dist/iphone-mono-libs/libmono-native.xcframework/ios-arm64/empty b/misc/dist/iphone-mono-libs/libmono-native.xcframework/ios-arm64/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmono-native.xcframework/ios-arm64/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/iphone-mono-libs/libmono-native.xcframework/ios-arm64_x86_64-simulator/empty b/misc/dist/iphone-mono-libs/libmono-native.xcframework/ios-arm64_x86_64-simulator/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmono-native.xcframework/ios-arm64_x86_64-simulator/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/Info.plist b/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/Info.plist new file mode 100644 index 00000000000..be39af11428 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/Info.plist @@ -0,0 +1,40 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + libmono-profiler-log.a + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + libmono-profiler-log.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/ios-arm64/empty b/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/ios-arm64/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/ios-arm64/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/ios-arm64_x86_64-simulator/empty b/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/ios-arm64_x86_64-simulator/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmono-profiler-log.xcframework/ios-arm64_x86_64-simulator/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/Info.plist b/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/Info.plist new file mode 100644 index 00000000000..6eb5feb91cf --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/Info.plist @@ -0,0 +1,40 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + libmonosgen.a + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + libmonosgen.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + + diff --git a/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/ios-arm64/empty b/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/ios-arm64/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/ios-arm64/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/ios-arm64_x86_64-simulator/empty b/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/ios-arm64_x86_64-simulator/empty new file mode 100644 index 00000000000..bd3e8943336 --- /dev/null +++ b/misc/dist/iphone-mono-libs/libmonosgen-2.0.xcframework/ios-arm64_x86_64-simulator/empty @@ -0,0 +1 @@ +Dummy file to make dylibs folder exported diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index 68696278736..2d9d59ff9f8 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -86,7 +86,7 @@ def configure(env, env_mono): is_android = env["platform"] == "android" is_javascript = env["platform"] == "javascript" is_ios = env["platform"] == "iphone" - is_ios_sim = is_ios and env["arch"] in ["x86", "x86_64"] + is_ios_sim = is_ios and env["ios_simulator"] tools_enabled = env["tools"] mono_static = env["mono_static"] @@ -271,9 +271,20 @@ def configure(env, env_mono): arch = env["arch"] def copy_mono_lib(libname_wo_ext): - copy_file( - mono_lib_path, "#bin", libname_wo_ext + ".a", "%s.iphone.%s.a" % (libname_wo_ext, arch) - ) + if is_ios_sim: + copy_file( + mono_lib_path, + "#bin", + libname_wo_ext + ".a", + "%s.iphone.%s.simulator.a" % (libname_wo_ext, arch), + ) + else: + copy_file( + mono_lib_path, + "#bin", + libname_wo_ext + ".a", + "%s.iphone.%s.a" % (libname_wo_ext, arch), + ) # Copy Mono libraries to the output folder. These are meant to be bundled with # the export templates and added to the Xcode project when exporting a game. diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs index f9eb405ce6c..372cccc46ec 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs @@ -340,9 +340,14 @@ MONO_AOT_MODE_LAST = 1000, string MonoLibFromTemplate(string libFileName) => Path.Combine(Internal.FullTemplatesDir, "iphone-mono-libs", MonoLibFile(libFileName)); - exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmonosgen-2.0")); + string MonoFrameworkFile(string frameworkFileName) => frameworkFileName + ".xcframework"; - exporter.AddIosProjectStaticLib(MonoLibFromTemplate("libmono-native")); + string MonoFrameworkFromTemplate(string frameworkFileName) => + Path.Combine(Internal.FullTemplatesDir, "iphone-mono-libs", MonoFrameworkFile(frameworkFileName)); + + exporter.AddIosProjectStaticLib(MonoFrameworkFromTemplate("libmonosgen-2.0")); + + exporter.AddIosProjectStaticLib(MonoFrameworkFromTemplate("libmono-native")); if (aotOpts.UseInterpreter) { @@ -366,7 +371,7 @@ MONO_AOT_MODE_LAST = 1000, // functions in System.Native/libmono-native). Instead, we should use cecil to search for // DllImports in assemblies and pass them to 'ld' as '-u/--undefined {pinvoke_symbol}'. exporter.AddIosLinkerFlags("-rdynamic"); - exporter.AddIosLinkerFlags($"-force_load \"$(SRCROOT)/{MonoLibFile("libmono-native")}\""); + exporter.AddIosLinkerFlags($"-force_load \"$(SRCROOT)/{MonoFrameworkFile("libmono-native")}\""); } /// Converts an assembly name to a valid symbol name in the same way the AOT compiler does diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index de3493f1895..288dafb6c3e 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -33,6 +33,7 @@ def get_opts(): "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain", ), ("IPHONESDK", "Path to the iPhone SDK", ""), + BoolVariable("ios_simulator", "Build for iOS Simulator", False), BoolVariable("ios_exceptions", "Enable exceptions", False), ("ios_triple", "Triple for ios toolchain", ""), ] @@ -106,26 +107,35 @@ def configure(env): ## Compile flags - if env["arch"] == "x86" or env["arch"] == "x86_64": + if env["ios_simulator"]: detect_darwin_sdk_path("iphonesimulator", env) + env.Append(CCFLAGS=["-mios-simulator-version-min=10.0"]) + env.Append(LINKFLAGS=["-mios-simulator-version-min=10.0"]) + env.extra_suffix = ".simulator" + env.extra_suffix + else: + detect_darwin_sdk_path("iphone", env) + env.Append(CCFLAGS=["-miphoneos-version-min=10.0"]) + env.Append(LINKFLAGS=["-miphoneos-version-min=10.0"]) + + if env["arch"] == "x86" or env["arch"] == "x86_64": env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9" arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append( CCFLAGS=( "-arch " + arch_flag - + " -fobjc-arc -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0" + + " -fobjc-arc -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK" ).split() ) elif env["arch"] == "arm": detect_darwin_sdk_path("iphone", env) env.Append( - CCFLAGS='-fobjc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies'.split() + CCFLAGS='-fobjc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -MMD -MT dependencies'.split() ) elif env["arch"] == "arm64": detect_darwin_sdk_path("iphone", env) env.Append( - CCFLAGS="-fobjc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=10.0 -isysroot $IPHONESDK".split() + CCFLAGS="-fobjc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -isysroot $IPHONESDK".split() ) env.Append(CPPDEFINES=["NEED_LONG_INT"]) env.Append(CPPDEFINES=["LIBYUV_DISABLE_NEON"]) @@ -148,7 +158,6 @@ def configure(env): LINKFLAGS=[ "-arch", arch_flag, - "-mios-simulator-version-min=10.0", "-isysroot", "$IPHONESDK", "-Xlinker", @@ -159,9 +168,9 @@ def configure(env): ] ) elif env["arch"] == "arm": - env.Append(LINKFLAGS=["-arch", "armv7", "-Wl,-dead_strip", "-miphoneos-version-min=10.0"]) + env.Append(LINKFLAGS=["-arch", "armv7", "-Wl,-dead_strip"]) if env["arch"] == "arm64": - env.Append(LINKFLAGS=["-arch", "arm64", "-Wl,-dead_strip", "-miphoneos-version-min=10.0"]) + env.Append(LINKFLAGS=["-arch", "arm64", "-Wl,-dead_strip"]) env.Append( LINKFLAGS=[ diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 7cdfd6f16de..0674ee68b0f 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -1504,9 +1504,9 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p return ERR_SKIP; } - String library_to_use = "libgodot.iphone." + String(p_debug ? "debug" : "release") + ".fat.a"; + String library_to_use = "libgodot.iphone." + String(p_debug ? "debug" : "release") + ".xcframework"; - print_line("Static library: " + library_to_use); + print_line("Static framework: " + library_to_use); String pkg_name; if (p_preset->get("application/name") != "") { pkg_name = p_preset->get("application/name"); // app_name @@ -1592,7 +1592,7 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p if (files_to_parse.has(file)) { _fix_config_file(p_preset, data, config_data, p_debug); } else if (file.begins_with("libgodot.iphone")) { - if (file != library_to_use) { + if (!file.begins_with(library_to_use) || file.ends_with(String("/empty"))) { ret = unzGoToNextFile(src_pkg_zip); continue; //ignore! } @@ -1600,7 +1600,7 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p #if defined(OSX_ENABLED) || defined(X11_ENABLED) is_execute = true; #endif - file = "godot_ios.a"; + file = file.replace(library_to_use, binary_name + ".xcframework"); } if (file == project_file) { @@ -1670,7 +1670,9 @@ Error EditorExportPlatformIOS::export_project(const Ref &p_p for (int j = 0; j < project_static_libs.size(); j++) { const String &static_lib_path = project_static_libs[j]; String dest_lib_file_path = dest_dir + static_lib_path.get_file(); - Error lib_copy_err = tmp_app_path->copy(static_lib_path, dest_lib_file_path); + + bool dir_exists = tmp_app_path->dir_exists(static_lib_path); + Error lib_copy_err = dir_exists ? tmp_app_path->copy_dir(static_lib_path, dest_lib_file_path) : tmp_app_path->copy(static_lib_path, dest_lib_file_path); if (lib_copy_err != OK) { ERR_PRINTS("Can't copy '" + static_lib_path + "'."); memdelete(tmp_app_path);