59

I'd like to upload an app written in swift. Application loader delivers the app successfully, but after a few minutes I get a reply by apple telling:

Invalid Swift Support - The bundle contains an invalid implementation of Swift. The app may have been built or signed with non-compliant or pre-release tools. Visit developer.apple.com for more information.

I use xCode Version 6.0.1 (6A317), Swift iOS SDK 8.0 and just build the app with xcode.

Where can I find any information on how to get a valid implementation of swift? Apple does not say anything concrete.

Thx

pnuts
  • 58,317
  • 11
  • 87
  • 139
Simon Meyborg
  • 727
  • 1
  • 6
  • 7
  • 1
    i have got the same problem have find a solution ? – YanSte Jan 18 '15 at 17:31
  • Any solution? I am creating ipa file via xcodebuild command and getting the same error. I am using Xcode 8.1 and my app is built in Objective-C and some swift library. – aareeph Nov 18 '16 at 06:44
  • @aareeph did you find a solution to this? I'm also having the same problem. Thanks! – user805981 Dec 31 '16 at 04:27
  • @user805981 Yes I was able to resolve the issue with the Kamilton's response in this thread. – aareeph Jan 02 '17 at 05:20

23 Answers23

35

I had a similar problem. To fix it and be able to push a build to iTunesConnect I had to do the following:

  • Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to YES in the target settings
  • Be sure that Build Phases did not include any other weird targets
  • Logout all Apple Developper accounts from Xcode and login with just the one you want to push the app with.
  • Archive and submit the app with Xcode and NOT with Application Loader.

Why did I need to logout from all of my Apple Developper accounts?

Because Xcode does not know which account to use to upload the binary. Application Loader ask you in the beginning but then, the uploaded build isn't valid...

UPDATE:

Since Xcode 7.1 and the new versions of Swift I got the error again. The current workaround is to do the following:

  • Create an archive locally on Xcode (does not work on my CI)
  • On Organizer, export it as an AppStore build.
  • Use Application Loader to upload the binary.

After few minutes (~10) the build should be available on iTunesConnect.

Kevin Delord
  • 2,498
  • 24
  • 22
  • 1
    ur right man, it should uploaded using xcode archiver...thanks – mohammad alabid Nov 30 '14 at 09:21
  • 8
    The problem seems to appear when you had a Swift file in the project but removed it. This makes Xcode set `EMBEDDED_CONTENT_CONTAINS_SWIFT` to `YES`. If you remove the last Swift file just set `EMBEDDED_CONTENT_CONTAINS_SWIFT` back to `NO`. – toto Jan 16 '15 at 09:00
  • I have tried full reinstall of XCode along with recreation of my project (apart from the solutions presented here) and the error still remains. Is there anything I could possibly do to fix this issue? – driver733 Aug 07 '15 at 13:47
17

The problem might come from cocoapods if you are using Swift pods. To fix it, use the branch xcode7-invalid-swift-support-fix (usage). Or do it manually by editing Pods/Target Support Files/Pods/Pods-frameworks.sh and commenting the block after

 # Embed linked Swift runtime libraries

More info:

Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213
cl3m
  • 170
  • 1
  • 6
  • 2
    This change is not necessary with latest cocoapods version 0.39.0. However, my app is still rejected due to "Invalid implementation of swift" – Lars Blumberg Oct 19 '15 at 11:06
14

Solution for xcodebuild

  • create a temp folder

  • unzip ipa file to temp folder

  • create SwiftSupport folder inside temp folder
  • copy swift libs from Payload/*app/framworks to SwiftSupport folder
  • package ipa file from contains inside temp folder (we have Payload and SwiftSupport folders).

Here my shell script for add Swift libs to ipa

https://github.com/huhuvipi/VH_ipa_packger

If you existing ipa file , you just:

path/to/package_ipa.sh /path/to/ipafile

Vinh Huynh
  • 151
  • 1
  • 5
  • 1
    You say - 'copy swift libs from Payload/*app/framworks to SwiftSupport folder'. Hmmmm...I unzipped the distribution folder and I actually have nothing in Payload other than the .app itself. Thoughts? Tried everything else other than switching to Android :) – zevij Oct 07 '15 at 01:54
  • goggelj: you have to unzip the .app file - take a look at the script provided by @Vinh (line 16/17). – seafoxx Oct 19 '15 at 11:11
  • After unzipping the ipa and copying the files from the *app/framework to the new swiftsupport folderapple complains when uploading to itunes. Invalid Swift Support - The file libswiftAVFoundation.dylib doesn’t have the correct code signature. Make sure you’re using the correct signature, rebuild your app using the current public (GM) version of Xcode, and resubmit it. Don’t just modify the code signature of libswiftAVFoundation.dylib. – tech-e Mar 30 '17 at 16:17
12

Do you build with command line (xcodebuild)?

If so: I encountered the same problem. The problem is that the generated ipa file is invalid. It is missing the SwiftSupport folder. The folder is added by XCode when a project with Swift is built with the Xcode Gui.

The problem is described in this apple developer forum thread with a reference to an open radar ticket: https://devforums.apple.com/message/1042117#1042117

savage7
  • 121
  • 2
  • Posed in the Dev forums too, but I'm currently experiencing the same issue - regardless of whether we submit through Application Loader or Xcode. And regardless of if we build using command line or the IDE. Any more revelations around this? – nomad00 Oct 23 '14 at 12:33
  • 2
    This was my problem. Another build tool that creates the `SwiftSupport` folder is `Shenzhen`. It's a drop-in replacement for xcodebuild / xcrun, similar to xctool. Note xcodebuil / xcrun does NOT create the required folder (it's a bug). – bobics Jun 29 '15 at 17:36
6

Do you have any other version of Xcode installed?

Open your latest Xcode, then go to preferences (Xcode menu -> Preferences), switch to the Locations tab and verify that the Command Line Tools matches your Xcode version.

Antonio
  • 71,651
  • 11
  • 148
  • 165
  • Good point but along with flag changes "Embedded Content Contains Swift Code" to YES and uploading your build via Archiving it on XCode – Rein rPavi Dec 08 '15 at 10:38
  • Thanks! This worked for me in 2020. Only had the latest version installed though. – Zee Apr 08 '21 at 06:32
3

If you're building via xcodebuild or Xcode Server (or anything other than the Organizer window in Xcode), the IPA is missing SwiftSupport. See this discussion of the problem.

The solution is essentially to export the IPA yourself. CaveJohnson has a command to export an IPA with the correct SwiftSupport, so you can build an IPA like so:

cavejohnson xcodeGUITricks --archive-path my.xcarchive --new-ipa-path myapp.ipa
Drew
  • 8,675
  • 6
  • 43
  • 41
  • I can found the swift support folder, but still get the error from iTunes connct – crazy_phage May 08 '15 at 02:11
  • This was my problem. Another build tool that creates the `SwiftSupport` folder is `Shenzhen`. It's a drop-in replacement for xcodebuild / xcrun, similar to xctool. Note xcodebuil / xcrun does NOT create the required folder (it's a bug). – bobics Jun 29 '15 at 17:34
  • `shenzhen` is a great tool, but it is just a wrapper around `xcodebuild`. It's easy to see in the implementation "https://github.com/nomad/shenzhen/blob/master/lib/shenzhen/commands/build.rb". There's no magic involved. If `shenzhen` can build the IPA properly, so can `xcodebuild`. – i4niac Jul 02 '15 at 05:26
  • OK, I have to take that back! :) `shenzhen` does have additional smarts in it, including copying over `SwiftSupport` folder and other things. – i4niac Jul 02 '15 at 12:29
3

I was with the same problem and tried everything proposed, but always failed... My apps generates SwiftSupport Folders, I just solved with this solution:

Thank you for sending that .ipa file. The issue is caused by libswiftXCTest.dylib in the SwiftSupport directory. That dylib is used by testing targets and is normal for development builds to include, but an archive build for the App Store should not include this dylib.

In order to resolve this issue, please follow these steps:

  1. Open your Xcode project
  2. Select Product > Scheme > Edit Scheme
  3. Click Build in the left sidebar
  4. For your test target, uncheck the Archive checkbox
  5. Click the Close button
  6. Select Product > Archive
  7. Submit the latest archive to the App Store
  • This was exactly my problem. After trying everything above first to no avail, it was as simple as removing the test target from the build phase. Frustrating to be something so simple, but extremely grateful for Franklin's post. Thanks! – Justin Youens Aug 06 '15 at 15:10
  • This is not working for me.... After uncheck Archive checkbox, I am unable to Archive build again. Very strange – Bonnke Sep 09 '15 at 12:36
1

Check your code signing. I had this error while using automatic signing. I Put my dev profile for dev and production profile for release version and error is gone.

Abhijeet
  • 8,561
  • 5
  • 70
  • 76
jmcastel
  • 1,365
  • 7
  • 17
  • 34
1

Simple Solution :

Hi, I had same issue and below is the solution :

Just Set the flag EMBEDDED_CONTENT_CONTAINS_SWIFT to NO in the build setting of Target,Project and everywhere like testTarget as well.

RawMean
  • 8,374
  • 6
  • 55
  • 82
Hardik Shah
  • 1,683
  • 1
  • 11
  • 20
1

I had this problem too

I tried to set the flag of EMBEDDED_CONTENT_CONTAINS_SWIFT to YES and NO. Both were not working for me.

Eventually I tried it with CaveJohnson mentioned by Drew. But that didn't work either.

At last I created a new project and inserted my swift files and frameworks etc. That was it!

The solution in my case: Create a new project

Gerrit Post
  • 1,247
  • 13
  • 25
  • Exactly what happened to me. Creating a new project was the only solution that worked for me. Thank you! – Ernesto Fernandez Mar 28 '15 at 14:54
  • 1
    Still did not work for me. Even when coupled with full reinstall of XCode. Any other suggestions? – driver733 Aug 07 '15 at 13:56
  • @driver733 No, I think you should try to create a new app in itunesConnect (and xcode) and submit a simple hello world app. If that works, it is probably a problem in your code. – Gerrit Post Aug 24 '15 at 15:46
1

OK, I have been working on this for many hours now and finally found a solution.

To pre-frame the answer here is what I did: - tried everything in the previous answers - spent an hour on the phone with Apple Tech support. - read every Apple developer forum having to do with "invalid swift" in their developer network. Tried each of the proposed solutions.

I finally uninstalled and reinstalled Xcode and what do you know, it works now. Sometimes I don't know why this isn't my first idea for a solution.

Wade Anderson
  • 2,461
  • 1
  • 20
  • 22
1

I discovered that changing "Embedded Content Contains Swift Code" from YES to NO in the main app build settings (and leaving it set to YES in the extension) would run on the watch (and the phone). At the same time as I uploaded that binary, Apple must have made a change to the ITC backend as my other uploaded builds which had been marked "Invalid Binary" reverted to "Processing" and later passed the screen to "Inactive".

So I submitted the build with "Embedded Content Contains Swift Code" YES in the extension only for review.

Main app: Embedded Content Contains Swift Code = YES (if its a swift project. else NO)

WatchKit Extension: Embedded Content Contains Swift Code = YES (if its a swift project. else NO)

WatchKit App: Embedded Content Contains Swift Code = NO (In any case)

Charith Nidarsha
  • 4,195
  • 3
  • 28
  • 32
  • I came here to say something similar, but your answer basically sums it up. The reason is the WatchKitApp doesn't contain the actual source code, the Extension does. – Firo Jun 11 '16 at 15:12
1

Here's a solution when using command line http://www.matrixprojects.net/p/xcodebuild-export-options-plist/

Basicly all what needs to be done is to create xcodebuild exportOptions plist file which looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>teamID</key>
        <string>MYTEAMID123</string>
        <key>method</key>
        <string>app-store</string>
        <key>uploadSymbols</key>
        <true/>
</dict>
</plist>

Most important key here is method app-store

And then run xcode build with archive

xcodebuild -scheme MyApp -archivePath builds/MyApp.xcarchive archive

After that run xcrun with export archive

xcrun xcodebuild -exportArchive -exportOptionsPlist exportPlist.plist -archivePath builds/MyApp.xcarchive -exportPath builds
Kamilton
  • 696
  • 6
  • 12
0

I was facing same problem . The solution that worked for me was to update my xcode and then create new project and copy paste all my work to that project

0

seriously. I spent two days on this problem, and I tried all methods above. Nothing works!Finall. I used my friend's mac. And this time, it works. After that I realized that I downloaded the xcode from developer center not in mac app store. So I removed all xcode from my mac, and reinstall the xcode from app store, and it worked. And there is no difference between the two versions, which shared the exactly the same version number.

crazy_phage
  • 550
  • 9
  • 28
0

After Swift project update in new xcode was getting similar error and below is my solution.

Open project.pbxproj file and remove below line

EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;

and was able to submit app successfully.

Suresh
  • 1,131
  • 1
  • 15
  • 28
0

We had a similar problem after upgrading to Xcode 7. Had to add the -exportOptionsPlist option and supply method and teamID. Messed things up but works now.

epatel
  • 45,805
  • 17
  • 110
  • 144
0

Five Step Solution:

  1. Go to build settings and make flag Embedded Content Contains Swift Code -> YES, if your code contains partial swift code or entirely made in Swift
  2. Archive your build using Xcode->Product->Archive
  3. Export the Archive Build you will suddenly see the difference build size will be 40+ MBs this is because XCode has added SwiftSupport folder which was missing
  4. Now upload this build using Application loader
  5. If this does not work check that if you have multiple XCode on your system goto Xcode->Preferences->Location->Command Lines Tools has the same latest or the same Xcode from drop down selected on which you have done the coding & vola it's done.

This is slightly a drawback as swift carries the baggage and has to be compatible with earlier version and Objective C code.

My many hours were wasted hope you will find this helpful ;)

Rein rPavi
  • 3,368
  • 4
  • 22
  • 32
0

Thought I should share since I spent a few days trying to solve this problem.

Everyone keeps saying to set EMBEDDED_CONTENT_CONTAINS_SWIFT = NO or =YES

I had an iPhone app written entirely in Objective-C and a Watch Kit app written entirely in Swift.

I set EMBEDDED_CONTENT_CONTAINS_SWIFT = NO for everything (Project Target, iPhone app target, Tests, UITests, and WatchKit)

The place where I set EMBEDDED_CONTENT_CONTAINS_SWIFT = YES is in the WatchKit Extension. This solved my problem and I was able to upload to the App Store through Xcode.

Hope this can help somebody!

MSU_Bulldog
  • 3,501
  • 5
  • 37
  • 73
0

I was able to fix this by opening the archive, going into SwiftSupport and deleting the folder for WatchOS because it was empty. I guess my Watch target was set to embed Swift, so it included the folder but didn't generate anything inside it. So iTC saw an empty folder and errors out. By removing the empty folder it worked.

James Kuang
  • 10,710
  • 4
  • 28
  • 38
0

For me this is what worked for distribution.

Goto -> Xcode->product->Archive->Export

After this a folder will be created with current date. You can save it somewhere for later use. Then open Application loader and you can submit to the itunesConnect from here. Everything will be cleared. Make sure you create Build(.ipa) file by clicking on Export option in the organizer window. Then use Application loader to submit build to iTunesConnect.

I hope it helps. Let me know if you need more information.

Narasimha Nallamsetty
  • 1,215
  • 14
  • 16
0

If you have cocoapods, simply delete all of the pods and then reinstall pod install.

Very annoying since I have -22421 error when uploading directly from Xcode and Invalid Swift support when using Application Loader

keithics
  • 8,576
  • 2
  • 48
  • 35
-1

I actually just solved this with a completely different, unrelated and really weird fix. Had the above error, but did NOT change anything in the Project or build Environment.

After a lot of Rebuild and Upload Cycles, it turned out that it was an Ad-Hoc certificate that was causing this issue. Using fastlane and setting the gym flag ad_hoc to false as well as using a Release Config for the build (not sure which one fixed it) finally worked. Here is my gym line:

identifier = "de.xxx.yyy"
config = "Release"
ad_hoc = false
scheme = "Schema"
gym(verbose: false, scheme: scheme, codesigning_identity: "iPhone Distribution: YTB)", configuration: config)
Blitz
  • 5,521
  • 3
  • 35
  • 53