Skip to content

Commit

Permalink
extra ios export configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Sep 25, 2019
1 parent 9bd6d33 commit 2dfcce0
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 31 deletions.
12 changes: 10 additions & 2 deletions doc/conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ appid_ios = "com.example.mygameid"
icon_ios_ = "assets/icon.png"
launch_image = "assets/launch_image.png"
orientation = "portrait"
ios_cert_identity = "XXXX123456"
ios_dev_cert_identity = "XXXX123456"
ios_appstore_cert_identity = "XXXX123456"
ios_code_sign_identity = "Apple Distribution"
ios_dev_prov_profile_name = "MyGame Dev Profile"
ios_dist_prov_profile_name = "MyGame App Store Profile"
game_center_enabled = true
icloud_enabled = true
~~~

The above metadata is used when the `-ios-xcode-proj` export option is
Expand All @@ -86,10 +90,14 @@ given to generate an Xcode project for iOS. All the data is required.
`orientation` can be `"portrait"`, `"landscape"`, `"any"` or
`"hybrid"` (portrait on iPhone, but landscape on iPad).

`ios_cert_identity` is the code that appears in parenthesis in your certificate name
`ios_dev_cert_identity` and `ios_appstore_cert_identity` is the code that appears in parenthesis in your certificate name
(e.g. if you certificate name in Key Access is "iPhone Distribution: Your Name (XXXX123456)",
then this value should be `"XXXX123456"`.

`ios_code_sign_identity` is the part that comes before the colon in your distribution certificate
name. Typically this is either `"iPhone Distribution"` or `"Apple Distribution"`. (Use the Keychain Access application in
Utilities to view your certificates.)

`ios_dev_prov_profile_name` and `ios_dist_prov_profile_name` are the names
of your installed development and distribution provisioning profiles respectively.
You can install a provisioning profile by downloading and double clicking it.
Expand Down
11 changes: 8 additions & 3 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3337,12 +3337,17 @@ <h2 id="ios-settings">iOS settings</h2>
icon_ios_ <span class="ot">=</span> <span class="st">&quot;assets/icon.png&quot;</span>
launch_image <span class="ot">=</span> <span class="st">&quot;assets/launch_image.png&quot;</span>
orientation <span class="ot">=</span> <span class="st">&quot;portrait&quot;</span>
ios_cert_identity <span class="ot">=</span> <span class="st">&quot;XXXX123456&quot;</span>
ios_dev_cert_identity <span class="ot">=</span> <span class="st">&quot;XXXX123456&quot;</span>
ios_appstore_cert_identity <span class="ot">=</span> <span class="st">&quot;XXXX123456&quot;</span>
ios_code_sign_identity <span class="ot">=</span> <span class="st">&quot;Apple Distribution&quot;</span>
ios_dev_prov_profile_name <span class="ot">=</span> <span class="st">&quot;MyGame Dev Profile&quot;</span>
ios_dist_prov_profile_name <span class="ot">=</span> <span class="st">&quot;MyGame App Store Profile&quot;</span></code></pre></div>
ios_dist_prov_profile_name <span class="ot">=</span> <span class="st">&quot;MyGame App Store Profile&quot;</span>
game_center_enabled <span class="ot">=</span> <span class="kw">true</span>
icloud_enabled <span class="ot">=</span> <span class="kw">true</span></code></pre></div>
<p>The above metadata is used when the <code>-ios-xcode-proj</code> export option is given to generate an Xcode project for iOS. All the data is required.</p>
<p><code>orientation</code> can be <code>&quot;portrait&quot;</code>, <code>&quot;landscape&quot;</code>, <code>&quot;any&quot;</code> or <code>&quot;hybrid&quot;</code> (portrait on iPhone, but landscape on iPad).</p>
<p><code>ios_cert_identity</code> is the code that appears in parenthesis in your certificate name (e.g. if you certificate name in Key Access is &quot;iPhone Distribution: Your Name (XXXX123456)&quot;, then this value should be <code>&quot;XXXX123456&quot;</code>.</p>
<p><code>ios_dev_cert_identity</code> and <code>ios_appstore_cert_identity</code> is the code that appears in parenthesis in your certificate name (e.g. if you certificate name in Key Access is &quot;iPhone Distribution: Your Name (XXXX123456)&quot;, then this value should be <code>&quot;XXXX123456&quot;</code>.</p>
<p><code>ios_code_sign_identity</code> is the part that comes before the colon in your distribution certificate name. Typically this is either <code>&quot;iPhone Distribution&quot;</code> or <code>&quot;Apple Distribution&quot;</code>. (Use the Keychain Access application in Utilities to view your certificates.)</p>
<p><code>ios_dev_prov_profile_name</code> and <code>ios_dist_prov_profile_name</code> are the names of your installed development and distribution provisioning profiles respectively. You can install a provisioning profile by downloading and double clicking it.</p>
<h2 id="android-settings">Android settings</h2>
<div class="sourceCode"><pre class="sourceCode lua"><code class="sourceCode lua">display_name <span class="ot">=</span> <span class="st">&quot;My Game&quot;</span>
Expand Down
15 changes: 15 additions & 0 deletions src/am_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ const char *am_conf_mac_application_cert_identity = NULL;
const char *am_conf_mac_installer_cert_identity = NULL;

const char *am_conf_ios_cert_identity = NULL;
const char *am_conf_ios_dev_cert_identity = NULL;
const char *am_conf_ios_appstore_cert_identity = NULL;
const char *am_conf_ios_code_sign_identity = NULL;
const char *am_conf_ios_dev_prov_profile_name = NULL;
const char *am_conf_ios_dist_prov_profile_name = NULL;

bool am_conf_game_center_enabled = true;
bool am_conf_icloud_enabled = true;

const char *am_conf_google_play_services_id = NULL;
const char *am_conf_android_app_version_code = NULL;

Expand Down Expand Up @@ -131,6 +137,9 @@ static void free_config() {
free_if_not_null((void**)&am_conf_mac_application_cert_identity);
free_if_not_null((void**)&am_conf_mac_installer_cert_identity);
free_if_not_null((void**)&am_conf_ios_cert_identity);
free_if_not_null((void**)&am_conf_ios_dev_cert_identity);
free_if_not_null((void**)&am_conf_ios_appstore_cert_identity);
free_if_not_null((void**)&am_conf_ios_code_sign_identity);
free_if_not_null((void**)&am_conf_ios_dev_prov_profile_name);
free_if_not_null((void**)&am_conf_ios_dist_prov_profile_name);
free_if_not_null((void**)&am_conf_google_play_services_id);
Expand Down Expand Up @@ -199,9 +208,15 @@ bool am_load_config() {
read_string_setting(eng->L, "mac_installer_cert_identity", &am_conf_mac_installer_cert_identity, NULL);

read_string_setting(eng->L, "ios_cert_identity", &am_conf_ios_cert_identity, NULL);
read_string_setting(eng->L, "ios_dev_cert_identity", &am_conf_ios_dev_cert_identity, am_conf_ios_cert_identity);
read_string_setting(eng->L, "ios_appstore_cert_identity", &am_conf_ios_appstore_cert_identity, am_conf_ios_cert_identity);
read_string_setting(eng->L, "ios_code_sign_identity", &am_conf_ios_code_sign_identity, "iPhone Destribution");
read_string_setting(eng->L, "ios_dev_prov_profile_name", &am_conf_ios_dev_prov_profile_name, NULL);
read_string_setting(eng->L, "ios_dist_prov_profile_name", &am_conf_ios_dist_prov_profile_name, NULL);

read_bool_setting(eng->L, "game_center_enabled", &am_conf_game_center_enabled);
read_bool_setting(eng->L, "icloud_enabled", &am_conf_icloud_enabled);

read_string_setting(eng->L, "google_play_services_id", &am_conf_google_play_services_id, "0");
read_string_setting(eng->L, "android_app_version_code", &am_conf_android_app_version_code, "1");

Expand Down
6 changes: 6 additions & 0 deletions src/am_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ extern const char *am_conf_mac_application_cert_identity;
extern const char *am_conf_mac_installer_cert_identity;

extern const char *am_conf_ios_cert_identity;
extern const char *am_conf_ios_dev_cert_identity;
extern const char *am_conf_ios_appstore_cert_identity;
extern const char *am_conf_ios_code_sign_identity;
extern const char *am_conf_ios_dev_prov_profile_name;
extern const char *am_conf_ios_dist_prov_profile_name;

extern bool am_conf_game_center_enabled;
extern bool am_conf_icloud_enabled;

extern const char *am_conf_google_play_services_id;
extern const char *am_conf_android_app_version_code;

Expand Down
47 changes: 41 additions & 6 deletions src/am_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,26 @@ static bool copy_ios_xcodeproj_file(export_config *conf, char *dir) {
char *launchscreen_children = get_ios_launchscreen_children(conf);
const char *luavm = platform_luavm("ios");
char *launch_img_name = am_format("launchimg_%u.png", conf->launch_image_id);
char *capabilities = am_format(
"{\n"
" com.apple.GameCenter = {\n"
" enabled = %d;\n"
" };\n"
" com.apple.GameCenter.iOS = {\n"
" enabled = %d;\n"
" };\n"
" com.apple.iCloud = {\n"
" enabled = %d;\n"
" };\n"
"}\n",
am_conf_game_center_enabled ? 1 : 0, am_conf_game_center_enabled ? 1 : 0, am_conf_icloud_enabled ? 1 : 0);
const char *subs[] = {
"AM_APPNAME", conf->shortname,
"AM_APPID", am_conf_app_id_ios,
"AM_AUTHOR", am_conf_app_author,
"AM_CERT_ID", am_conf_ios_cert_identity,
"AM_DEV_CERT_ID", am_conf_ios_dev_cert_identity,
"AM_APPSTORE_CERT_ID", am_conf_ios_appstore_cert_identity,
"AM_CODE_SIGN_IDENTITY", am_conf_ios_code_sign_identity,
"AM_DEV_PROV_PROFILE_NAME", am_conf_ios_dev_prov_profile_name,
"AM_DIST_PROV_PROFILE_NAME", am_conf_ios_dist_prov_profile_name,
"AM_LANG_LIST", lang_list,
Expand All @@ -491,6 +506,7 @@ static bool copy_ios_xcodeproj_file(export_config *conf, char *dir) {
"AM_LAUNCHSCREEN_STORYBOARD_CHILDREN", launchscreen_children,
"AM_LUAVM", luavm,
"AM_LAUNCH_IMG", launch_img_name,
"AM_SYSTEM_CAPABILITIES", capabilities,
NULL
};
bool ok = copy_text_file(src_path, dest_path, (char**)subs);
Expand All @@ -500,6 +516,8 @@ static bool copy_ios_xcodeproj_file(export_config *conf, char *dir) {
free(lang_list);
free(launchscreen_entries);
free(launchscreen_children);
free(launch_img_name);
free(capabilities);
return ok;
}

Expand Down Expand Up @@ -579,6 +597,27 @@ static bool copy_ios_xcode_info_plist(export_config *conf, char *dir) {
return ok;
}

static bool copy_ios_entitlements(export_config *conf, char *dir) {
char *template_dir = get_template_path(conf);
if (template_dir == NULL) return false;
char *src_path = am_format("%sios/app.entitlements", template_dir);
char *dest_path = am_format("%s/%s.entitlements", dir, conf->shortname);
const char *icloud_xml = am_conf_icloud_enabled ?
" <key>com.apple.developer.icloud-container-identifiers</key>\n"
" <array/>\n"
" <key>com.apple.developer.ubiquity-kvstore-identifier</key>\n"
" <string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>\n" : "";
const char *subs[] = {
"AM_ICLOUD_ENTITLEMENT", icloud_xml,
NULL,
};
bool ok = copy_text_file(src_path, dest_path, (char**)subs);
free(template_dir);
free(src_path);
free(dest_path);
return ok;
}

static char *get_default_ios_launch_image_filename(export_config *conf) {
char *templates_dir = get_template_path(conf);
if (templates_dir == NULL) return NULL;
Expand Down Expand Up @@ -737,8 +776,6 @@ static bool gen_ios_xcode_proj(export_config *conf) {
char *appicon_assets_dir = am_format("%s/AppIcon.appiconset", assets_dir);
char *appicon_contents_src_path = am_format("%sios/AppIconContents.json", templates_dir);
char *appicon_contents_dest_path = am_format("%s/Contents.json", appicon_assets_dir);
char *entitlements_src_path = am_format("%sios/app.entitlements", templates_dir);
char *entitlements_dest_path = am_format("%s/%s.entitlements", projbase_dir, conf->shortname);
const char *lua_a_file = am_format("%s.a", platform_luavm("ios"));
am_make_dir(projbase_dir);
am_make_dir(xcodeproj_dir);
Expand All @@ -747,10 +784,10 @@ static bool gen_ios_xcode_proj(export_config *conf) {
bool ok =
copy_ios_xcodeproj_file(conf, xcodeproj_dir) &&
copy_ios_xcode_info_plist(conf, projbase_dir) &&
copy_ios_entitlements(conf, projbase_dir) &&
create_ios_xcode_lproj_dirs(projbase_dir, conf) &&
create_ios_xcode_icon_files(appicon_assets_dir, conf) &&
copy_text_file(appicon_contents_src_path, appicon_contents_dest_path, NULL) &&
copy_text_file(entitlements_src_path, entitlements_dest_path, NULL) &&
copy_ios_launchscreen_storyboard(projbase_dir, conf) &&
copy_ios_xcode_bin_file(projbase_dir, conf, "amulet.a") &&
copy_ios_xcode_bin_file(projbase_dir, conf, "glslopt.a") &&
Expand All @@ -771,8 +808,6 @@ static bool gen_ios_xcode_proj(export_config *conf) {
free(appicon_assets_dir);
free(appicon_contents_src_path);
free(appicon_contents_dest_path);
free(entitlements_src_path);
free(entitlements_dest_path);
return ok;
}

Expand Down
20 changes: 18 additions & 2 deletions src/am_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ static void create_framebuffer_msaa_texture(metal_framebuffer *fb) {
static void create_new_metal_encoder(bool clear_color_buf, bool clear_depth_buf, bool clear_stencil_buf) {
assert(metal_encoder == nil);

bool metal_command_buffer_was_nil = (metal_command_buffer == nil);
if (metal_command_buffer == nil) {
assert(default_metal_framebuffer.color_texture == nil);
assert(metal_active_drawable == nil);
Expand Down Expand Up @@ -754,11 +755,12 @@ static void create_new_metal_encoder(bool clear_color_buf, bool clear_depth_buf,
#endif

metal_command_buffer = [metal_queue commandBuffer];
[metal_command_buffer retain];
}

MTLRenderPassDescriptor *renderdesc = make_bound_framebuffer_render_desc(clear_color_buf, clear_depth_buf, clear_stencil_buf);
if (renderdesc == NULL) {
am_log1("%s", "error: attempt to use incomplete framebuffer");
am_log1("%s %i", "error: attempt to use incomplete framebuffer", (int)metal_command_buffer_was_nil);
return;
}
metal_encoder = [metal_command_buffer renderCommandEncoderWithDescriptor:renderdesc];
Expand Down Expand Up @@ -805,6 +807,7 @@ static void set_framebuffer_msaa_samples(metal_framebuffer *fb, int samples) {
void am_init_gl() {
#if defined (AM_OSX)
metal_device = MTLCreateSystemDefaultDevice();
[metal_device retain];
if (metal_device == nil) {
am_log0("%s", "unable to create metal device");
return;
Expand All @@ -825,11 +828,14 @@ void am_init_gl() {
metal_active_drawable = [metal_layer nextDrawable];
#elif defined(AM_IOS)
metal_device = am_metal_ios_view.device;
[metal_device retain];
metal_active_drawable = [am_metal_ios_view currentDrawable];
#endif

metal_queue = [metal_device newCommandQueue];
[metal_queue retain];
metal_command_buffer = [metal_queue commandBuffer];
[metal_command_buffer retain];

#if defined(AM_OSX)
default_metal_framebuffer.width = metal_layer.drawableSize.width;
Expand Down Expand Up @@ -943,7 +949,10 @@ void am_close_gllog() {
}

void am_destroy_gl() {
metal_command_buffer = nil;
if (metal_command_buffer != nil) {
[metal_command_buffer release];
metal_command_buffer = nil;
}
metal_encoder = nil;
metal_bound_framebuffer = 0;
#if defined (AM_OSX)
Expand Down Expand Up @@ -2029,6 +2038,7 @@ void am_read_pixels(int x, int y, int w, int h, void *data) {
bool was_command_buffer = true;
if (metal_command_buffer == nil) {
metal_command_buffer = [metal_queue commandBuffer];
[metal_command_buffer retain];
was_command_buffer = false;
}
// only needed if texture is MTLStorageModeManaged I think
Expand All @@ -2039,6 +2049,7 @@ void am_read_pixels(int x, int y, int w, int h, void *data) {
// #endif
[metal_command_buffer commit];
[metal_command_buffer waitUntilCompleted];
[metal_command_buffer release];
metal_command_buffer = nil;

MTLRegion region;
Expand All @@ -2052,6 +2063,7 @@ void am_read_pixels(int x, int y, int w, int h, void *data) {

if (was_command_buffer) {
metal_command_buffer = [metal_queue commandBuffer];
[metal_command_buffer retain];
}
}

Expand Down Expand Up @@ -2150,6 +2162,7 @@ void am_set_framebuffer_texture2d(am_framebuffer_attachment attachment, am_textu
bool was_command_buffer = true;
if (metal_command_buffer == nil) {
metal_command_buffer = [metal_queue commandBuffer];
[metal_command_buffer retain];
was_command_buffer = false;
}
id<MTLBlitCommandEncoder> blit_encoder = [metal_command_buffer blitCommandEncoder];
Expand All @@ -2165,9 +2178,11 @@ void am_set_framebuffer_texture2d(am_framebuffer_attachment attachment, am_textu
[blit_encoder endEncoding];
[metal_command_buffer commit];
[metal_command_buffer waitUntilCompleted];
[metal_command_buffer release];
metal_command_buffer = nil;
if (was_command_buffer) {
metal_command_buffer = [metal_queue commandBuffer];
[metal_command_buffer retain];
}
[old_tex release];
tex->writable = true;
Expand Down Expand Up @@ -2641,6 +2656,7 @@ void am_gl_end_frame(bool present) {
}
[metal_command_buffer commit];
[metal_command_buffer waitUntilCompleted];
[metal_command_buffer release];
metal_command_buffer = nil;
metal_active_drawable = nil;
default_metal_framebuffer.color_texture = nil;
Expand Down
5 changes: 1 addition & 4 deletions templates/ios/app.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.icloud-container-identifiers</key>
<array/>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
AM_ICLOUD_ENTITLEMENT
</dict>
</plist>
18 changes: 4 additions & 14 deletions templates/ios/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,7 @@
3C626A7C2023EA4A00FF5F20 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.GameCenter = {
enabled = 1;
};
com.apple.GameCenter.iOS = {
enabled = 1;
};
com.apple.iCloud = {
enabled = 1;
};
};
SystemCapabilities = AM_SYSTEM_CAPABILITIES;
};
};
};
Expand Down Expand Up @@ -395,7 +385,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AM_APPNAME.entitlements;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = AM_CERT_ID;
DEVELOPMENT_TEAM = AM_DEV_CERT_ID;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand All @@ -417,9 +407,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AM_APPNAME.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "AM_CODE_SIGN_IDENTITY";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = AM_CERT_ID;
DEVELOPMENT_TEAM = AM_APPSTORE_CERT_ID;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand Down

0 comments on commit 2dfcce0

Please sign in to comment.