Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25520] iOS: Add ability to set VALID_ARCHITECTURES to limit supported architectures

GitHub Issuen/a
TypeNew Feature
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsarchitecture, cb-tooling, ios, processor
ReporterZakhar Zhuravlev
AssigneeChris Barber
Created2017-11-16T10:26:52.000+0000
Updated2019-10-22T15:40:17.000+0000

Description

On android we can specify tag and exclude some abis. I need to compile iOS app only for arm64, as far as I understand now I don't have ability to exclude armv7 and armv7s. It would be great to have it for iOS as well.

Comments

  1. Hans Knöchel 2017-11-16

    Thanks for this feature request. It's not planned so far, but could likely be implemented as an external hook pretty easily, as it's just a build-setting in the .pbxproj file. See [this file](https://github.com/appcelerator-modules/hook-swift-frameworks/blob/master/ti.swiftsupport.js) for an example of changing the Swift version - it can be changed to specify any other value as well. And of course feel free to submit a pull-request if you feel it should be in the core.
  2. Zakhar Zhuravlev 2018-04-06

    Thank you, Hans. I found examples with native modules only, I want to set architectures for the whole app, should I create plugin for that?
  3. Hans Knöchel 2018-04-06

    Yes, a plugin look forcing the VALID_ARCHS will limit it.
  4. Zakhar Zhuravlev 2018-04-09

    1. create folder: /plugins/myplugin/hooks/myplugin.js 2. in titapp.xml add: myplugin 3. code:
       'use strict';
       
       exports.id = 'myplugin';
       exports.cliVersion = '>=3.2';
       exports.init = init;
       
       function init(logger, config, cli, appc) {
       	cli.on('build.ios.xcodeproject', {
       		pre: function(data) {
       			logger.log('Test plugin');
       		}
       	});
       }
       
       
    But I don't see this log message, even in trace mode. Have I missed something? Thank you in advance.
  5. Chris Barber 2018-04-09

    [~zozo4kin] You don't need to create a "plugin" in this case. You can simply create a "hooks" directory in the top-level of your project and put myplugin.js in there and the build script will automatically load it. No need to add the <plugin> to the tiapp.xml. If you are going to have more than one .js file, only put the main one in the "hooks" directory and put the rest in a subdirectory. The build will blindly require() every .js file in the "hooks" directory. If you want to continue doing this as a plugin, then you must have a package.json in the root of your "myplugin" folder and you must define all of the <plugin> tags in a <plugins> section in the tiapp.xml (just like <modules>).
  6. Zakhar Zhuravlev 2018-04-10

    Thank you very much. It works with "hooks" directory at the root. But it works only with cleaned project. On the second build I get error:
       [ERROR] An error occurred during build after 1m 6s 429ms
       [ERROR] Failed to install app on device (0xe8000067)
       [ERROR] For some reason the app failed to install on the device. Try reconnecting your device and check your provisioning profile and entitlements.
       
    after "appc ti clean" it works again, but build takes a lot of time with this hook. Approx 3-4 min.
  7. Chris Barber 2018-04-11

    Clean builds are pretty slow. If you change the VALID_ARCHS, then it's probably building each source file multiple times for the various architectures. We used to build for all architectures, but I changed it to ONLY_ACTIVE_ARCH=1 since it didn't make sense to compile for i386 and x64 for simulator builds. I'm not sure what your hook is changing since I haven't seen the code, but I don't understand why it would break subsequent builds. Maybe our differential build logic doesn't properly detect or handle the derived data when there are extra compiled architectures? Hard to say without testing it myself.
  8. Zakhar Zhuravlev 2018-04-11

    Thank you for help, Chris. my code:
       'use strict';
       
       exports.cliVersion = '>=3.2';
       exports.init = init;
       
       function init(logger, config, cli, appc) {
       	cli.on('build.ios.xcodeproject', {
       		pre: function(data) {
       
                   var xobjs = data.args[0].hash.project.objects;
       			Object.keys(xobjs.PBXNativeTarget).forEach(function (targetUuid) {
       				var target = xobjs.PBXNativeTarget[targetUuid];
       				if (target && typeof target === 'object') {
       					xobjs.XCConfigurationList[target.buildConfigurationList].buildConfigurations.forEach(function (buildConf) {
       						var buildSettings = xobjs.XCBuildConfiguration[buildConf.value].buildSettings;
                               buildSettings.VALID_ARCHS = "arm64";
       					});
       				}
       			});
       
       		}
       	});
       }
       
       

JSON Source