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

[WIP] GH-407: supports autormatic provisioning in Xcode 10 #504

Conversation

knight9999
Copy link
Contributor

@knight9999 knight9999 commented Jan 25, 2019

Platforms affected

cordova-ios

What does this PR do?

To fix the issue #407 in case the automatic provisioning is specified. This PR is according to the comment #407 (comment) .

What testing has been done on this change?

In xcode 10, exporting archives from xcarchive with automatic provisioning has an issue. As a result, ios-deploy debugging does not work correctly. (after launching, it stops soon).
Therefore this PR finds an appropriate provisioning file registered in local mac and uses that file to export an archive (.ipa file) in cordova/lib/build.js.

How to find appropriate provisioing file logic is followings.

1. get all provisioing files under 'Library/MobileDevice/Provisioning Profiles'.
2. get all valid certificates by using the command `security find-identity -v -p codesigning`.
3. select provisioning files associated with one of valid certificates.
4  sort provisioning files by app id (bundle id) length desc 
(e.g.
xxx.yyy.zzz takes priority over xxx.yyy.*. 
xxx.yyy.* takes priority over *.
)
5  sort provisioing files by created date desc.
(newly create provisioing takes priority)
6. drop provisioning files where IsXcodeManaged = true 
7. drop provisioning files where invalid build type. (selecting development for development,  release for release)
8. drop provisioning files with invalid team ID
9. If there is a USB connected iPhone/iPad, drop provisioning files which does not support the USB connected iPhone/iPad's device ID. (If two or more iPhone/iPad are connected, only first one is checked) 
10. drop provisioning files whose bundle id does not match the one in the project.
11. choose a first provisioning file of resulting provisiong files.

Checklist

  • Reported an issue in the JIRA database
  • Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
  • Added automated test coverage as appropriate for this change.

@dpogue
Copy link
Member

dpogue commented Jan 25, 2019

I believe all automatic provisioning profiles have IsXcodeManaged = true because they are automatically generated by Xcode rather than through the provisioning portal

@codecov-io
Copy link

codecov-io commented Jan 25, 2019

Codecov Report

Merging #504 into master will decrease coverage by 6.53%.
The diff coverage is 7.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #504      +/-   ##
==========================================
- Coverage   74.75%   68.21%   -6.54%     
==========================================
  Files          11       12       +1     
  Lines        1822     2020     +198     
==========================================
+ Hits         1362     1378      +16     
- Misses        460      642     +182
Impacted Files Coverage Δ
bin/templates/scripts/cordova/lib/build.js 43.03% <1.53%> (-8.76%) ⬇️
bin/templates/scripts/cordova/lib/provisioning.js 9.61% <9.61%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31ef0cd...1f4d579. Read the comment docs.

@knight9999
Copy link
Contributor Author

@dpogue Thanks for the advice.
Hm....
But I can not export achive with provisioning profile with IsXcodeManaged = true. I found the following error.

<DVTPlatform:0x7f84ce63a870:'com.apple.platform.watchos':<DVTFilePath:0x7f84ce63a7f0:'/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform'>>,
    <DVTPlatform:0x7f84ce637df0:'com.apple.platform.iphoneos':<DVTFilePath:0x7f84ce637e60:'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform'>>
)}, filePath: <DVTFilePath:0x7f84d0c9d730:'/Users/knaito/Library/MobileDevice/Provisioning Profiles/9aa6a9e3-52ff-422b-b75d-3319d66e432c.mobileprovision'>>, NSLocalizedDescription=Provisioning profile "iOS Team Provisioning Profile: *" is Xcode managed, but signing settings require a manually managed profile.}

@knight9999 knight9999 changed the title GH-407: supports autormatic provisioning in Xcode 10 [WIP] GH-407: supports autormatic provisioning in Xcode 10 Jan 26, 2019
@knight9999
Copy link
Contributor Author

knight9999 commented Jan 26, 2019

@dpogue Just as you mentioned, all automatic provisionings file are xcode managed.
and I can not export .ipa file from .xcarchive by using xcode managed provisioning file.( The error is Xcode managed, but signing settings require a manually managed profile. happens)

Now I am looking for the solution.

Is there any way to export a correct .ipa file from .xcarchive when the automatic provisioning is used? (Wrong .ipa file does not work in ios-deploy debugging)

@knight9999
Copy link
Contributor Author

knight9999 commented Jan 28, 2019

As far as I know, the only way to ios-deploy debugging with automatic provisioining is that using xcodebuild build command to get .app package, instead of using xcodebuild archive, xcodebuild -exportArchive and unzipping .ipa file.

I am now looking for another solution.

@knight9999
Copy link
Contributor Author

I found that removing following lines

shell.rm('-rf', path.join(dstDir, '_CodeSignature'));
shell.rm('-rf', path.join(dstDir, 'PkgInfo'));
shell.rm('-rf', path.join(dstDir, 'embedded.mobileprovision'));

in cordova/lib/copy-www-build-step.js may resolve this issue.
I am still investigating. I will close this PR and will create new PR.

@knight9999
Copy link
Contributor Author

Now my new PR is #508 .
This PR is closed.

@knight9999 knight9999 closed this Jan 30, 2019
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.

4 participants