Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Add support for building Swift apps #192

Merged
merged 1 commit into from Jan 29, 2015
Merged

Add support for building Swift apps #192

merged 1 commit into from Jan 29, 2015

Conversation

lvillani
Copy link
Contributor

The .ipa of a Swift application must contain a "SwiftSupport" directory
with all the runtime libraries required by Swift (even though they are
already included in the application bundle's "Frameworks" directory).

This step is NOT done by Xcode. The "Organizer" does that when someone
exports the application for distribution to iTunes Connect.

By inspecting the .ipa produced by the Organizer, we see that the SHA1
of all Swift runtime libraries in the "SwiftSupport" directory
are different from the ones inside the app bundle's "Frameworks"
directory. They seem to come from Xcode's toolchain directory instead.

This commit tries to match the behavior of the Organizer by doing the
following (after the PackageApplication step):

  • Inspect the "Frameworks" directory within the app bundle to determine
    which runtime libraries we need (if any)
  • Copy all Swift runtime libraries from Xcode's toolchain directory in
    a temporary directory with the required directory structure.
  • Append the temporary "SwiftSupport" directory to the .ipa file

end

# Add "SwiftSupport" to the .ipa archive
pwd = Dir.pwd
Copy link
Contributor

Choose a reason for hiding this comment

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

You could change it to make use of Ruby blocks:

Dir.chdir(tmpdir) do
   abort unless system %{zip --recurse-paths "#{@ipa_path}" "SwiftSupport" #{'> /dev/null' unless $verbose}}
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right! I didn't see that while looking up the docs. I know enough Ruby to be dangerous but it's not really my cup of tea :)

The .ipa of a Swift application must contain a "SwiftSupport" directory
with all the runtime libraries required by Swift (even though they are
already included in the application bundle's "Frameworks" directory).

This step is NOT done by Xcode. The "Organizer" does that when someone
exports the application for distribution to iTunes Connect.

By inspecting the .ipa produced by the Organizer, we see that the SHA1
of all Swift runtime libraries in the "SwiftSupport" directory
are different from the ones inside the app bundle's "Frameworks"
directory. They seem to come from Xcode's toolchain directory instead.

This commit tries to match the behavior of the Organizer by doing the
following (after the PackageApplication step):

- Inspect the "Frameworks" directory within the app bundle to determine
  which runtime libraries we need (if any)
- Copy all Swift runtime libraries from Xcode's toolchain directory in
  a temporary directory with the required directory structure.
- Append the temporary "SwiftSupport" directory to the .ipa file
@lvillani
Copy link
Contributor Author

I updated the pull request to include improvements reported by @KrauseFx

mattt added a commit that referenced this pull request Jan 29, 2015
Add support for building Swift apps
@mattt mattt merged commit 0ef30c6 into nomad-cli:master Jan 29, 2015
@mattt
Copy link
Contributor

mattt commented Jan 29, 2015

Amazing work, @lvillani. Thanks so much for your PR! Having Swift support is a huge deal to a lot of folks, myself included.

I'm cutting a new minor release now.

@KrauseFx
Copy link
Contributor

Thanks for merging @mattt, this is big! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants