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

Update iOS codesign options #1307

Merged
merged 1 commit into from
Mar 19, 2021
Merged

Update iOS codesign options #1307

merged 1 commit into from
Mar 19, 2021

Conversation

syrykh
Copy link
Contributor

@syrykh syrykh commented Mar 17, 2021

During testing of iOS codesign a few issues were found:

  • missing ability to specify development team, which is required;
  • missing allowProvisioningUpdates option;
  • exportFormat option was still used, despite the fact that it was removed in Xcode 8.3.

This PR addresses these issues.

As a result, I was able to get properly signed IPA:

Exported testapp to: /Users/jenkins/Jenkins/workspace/testapp/ios-debug/.buildozer/ios/platform/kivy-ios/testapp-0.1.7.intermediates/testapp-0.1.7.ipa
** EXPORT SUCCEEDED **

# Moving IPA to bin...
# Rename /Users/jenkins/Jenkins/workspace/testapp/ios-debug/.buildozer/ios/platform/kivy-ios/testapp-0.1.7.intermediates/testapp-0.1.7.ipa to /Users/jenkins/Jenkins/workspace/testapp/ios-debug/bin/testapp-0.1.7.ipa
# iOS packaging done!
# IPA testapp-0.1.7.ipa available in the bin directory

@@ -115,15 +115,20 @@ def toolchain(self, cmd, **kwargs):
kwargs.setdefault('cwd', self.ios_dir)
return self.buildozer.cmd(self._toolchain_cmd + cmd, **kwargs)

def xcodebuild(self, cmd='', **kwargs):
return self.buildozer.cmd(self._xcodebuild_cmd + cmd, **kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach allows easily omit unspecified (None) arguments, which makes later invocation cleaner.

'-allowProvisioningUpdates',
'ENABLE_BITCODE=NO',
self.code_signing_allowed,
self.code_signing_development_team,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without setting DEVELOPMENT_TEAM option here clean build command was failing with error
error: Signing for "testapp" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'testapp' from project 'testapp')

@@ -216,7 +221,12 @@ def build_package(self):

mode = self.build_mode.capitalize()
self.xcodebuild(
f"-configuration {mode} ENABLE_BITCODE=NO {self.code_signing_allowed} clean build",
f'-configuration {mode}',
'-allowProvisioningUpdates',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without -allowProvisioningUpdates option here clean build command was failing with error
error: No profiles for 'com.test.testapp' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.test.testapp'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'testapp' from project 'testapp')

f'-archivePath "{xcarchive}"',
'archive',
'ENABLE_BITCODE=NO',
self.code_signing_development_team,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without setting DEVELOPMENT_TEAM here archive command was failing with error
error: Signing for "testapp" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'testapp' from project 'testapp')

cwd=build_dir)

self.buildozer.info('Creating IPA...')
self.xcodebuild((
' -exportArchive'
' -exportFormat IPA'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With -exportFormat IPA the commad was failing with error xcodebuild: error: invalid option '-exportFormat'. This option was removed in Xcode 8.3.

self.xcodebuild(
'-exportArchive',
f'-archivePath "{xcarchive}"',
f'-exportOptionsPlist "{plist_rfn}"',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removal of exportFormat option and without exportOptionsPlist option the command was failing with error xcodebuild: error: The flag -exportOptionsPlist is required when specifying -exportArchive.

@@ -196,13 +195,6 @@ def test_build_package_no_signature(self):
'You must fill the "ios.codesign.debug" token.'
)
]
assert m_xcodebuild.call_args_list == [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because xcodebuild function signature has changed, instead of writing

assert m_xcodebuild.call_args_list == [
    mock.call(
        "-configuration Debug",
        "-allowProvisioningUpdates",
        "ENABLE_BITCODE=NO",
        "CODE_SIGNING_ALLOWED=NO",
        None,
        "clean build",
        cwd="/ios/dir/myapp-ios",
    )
]

... I've moved the expectations to the m_cmd mock.

@syrykh syrykh marked this pull request as ready for review March 17, 2021 20:09
Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that very well documented PR.
buildozer iOS definitely needed some love, so thanks for that

@AndreMiras AndreMiras merged commit 82ab5b3 into kivy:master Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants