fastlane: xcode 9 beta export options not working

New Issue Checklist

Issue Description

Extension of #9458 Project builds but come export for ad-hoc or release. I get the following output

Same error on xcode 9 beta 2.

Complete output when running fastlane, including the stack trace and command used

Run locally and pretending I am Jenkins to run match. JENKINS_HOME=a fastlane beta

Fastlane failed to capture output, below output is enough, imho.

[14:22:08]: ▸ Archive Succeeded
[14:22:08]: Generated plist file with the following values:
[14:22:08]: ▸ -----------------------------------------
[14:22:08]: ▸ {
[14:22:08]: ▸   "provisioningProfiles": {
[14:22:08]: ▸     "[\"com.widex.app\", \"com.widex.app.watchkitapp\", \"com.widex.app.watchkitapp.watchkitextension\"]": null
[14:22:08]: ▸   },
[14:22:08]: ▸   "method": "ad-hoc"
[14:22:08]: ▸ }
[14:22:08]: ▸ -----------------------------------------
/usr/local/lib/ruby/gems/2.4.0/gems/plist-3.2.0/lib/plist/generator.rb:97: warning: constant ::Fixnum is deprecated
/usr/local/lib/ruby/gems/2.4.0/gems/plist-3.2.0/lib/plist/generator.rb:97: warning: constant ::Bignum is deprecated
[14:22:08]: $ /usr/bin/xcrun /usr/local/lib/ruby/gems/2.4.0/gems/fastlane-2.41.0/gym/lib/assets/wrap_xcodebuild/xcbuild-safe.sh -exportArchive -exportOptionsPlist '/var/folders/gj/99cx5fcd3tv6wv16lb88pys9y555lm/T/gym_config20170627-58865-13cmzw6.plist' -archivePath /Users/bob/bitbucket/beyond/ios/output/AppNative\ 2017-06-27\ 14.20.56.xcarchive -exportPath '/var/folders/gj/99cx5fcd3tv6wv16lb88pys9y555lm/T/gym_output20170627-58865-1gnfxve'
+ xcodebuild -exportArchive -exportOptionsPlist /var/folders/gj/99cx5fcd3tv6wv16lb88pys9y555lm/T/gym_config20170627-58865-13cmzw6.plist -archivePath '/Users/bob/bitbucket/beyond/ios/output/AppNative 2017-06-27 14.20.56.xcarchive' -exportPath /var/folders/gj/99cx5fcd3tv6wv16lb88pys9y555lm/T/gym_output20170627-58865-1gnfxve
2017-06-27 14:22:08.997 xcodebuild[59928:11499459] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/gj/99cx5fcd3tv6wv16lb88pys9y555lm/T/AppNative_2017-06-27_14-22-08.996.xcdistributionlogs'.
2017-06-27 14:22:09.862 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:09.873 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.212 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.212 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.213 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.278 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.279 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.280 xcodebuild[59928:11499459] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-13152.18/DVTFoundation/DeveloperStructure/DVTPlatformFamily.m:192
Details:  Error Domain=DVTMachOErrorDomain Code=1 "Reached end of file while looking for: Mach-O slice." UserInfo={NSLocalizedDescription=Reached end of file while looking for: Mach-O slice., NSLocalizedRecoverySuggestion=}
Object:   <NSBundle>
Method:   +dvt_platformFamilyForBundleAtPath:error:
Thread:   <NSThread: 0x7fa034c16360>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
2017-06-27 14:22:10.554 xcodebuild[59928:11499459] [MT] IDEDistribution: Step failed: <IDEDistributionSigningAssetsStep: 0x7fa0376f4140>: Error Domain=IDEDistributionSigningAssetStepErrorDomain Code=0 "Locating signing assets failed." UserInfo={NSLocalizedDescription=Locating signing assets failed., IDEDistributionSigningAssetStepUnderlyingErrors=(
"Error Domain=IDEProfileLocatorErrorDomain Code=1 \"No profiles for 'com.widex.app.watchkitapp.watchkitextension' were found\" UserInfo={NSLocalizedDescription=No profiles for 'com.widex.app.watchkitapp.watchkitextension' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.widex.app.watchkitapp.watchkitextension'.}",
"Error Domain=IDEProfileLocatorErrorDomain Code=1 \"No profiles for 'com.widex.app.watchkitapp' were found\" UserInfo={NSLocalizedDescription=No profiles for 'com.widex.app.watchkitapp' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.widex.app.watchkitapp'.}",
"Error Domain=IDEProfileLocatorErrorDomain Code=1 \"No profiles for 'com.widex.app' were found\" UserInfo={NSLocalizedDescription=No profiles for 'com.widex.app' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.widex.app'.}"
)}
error: exportArchive: No profiles for 'com.widex.app.watchkitapp.watchkitextension' were found

Error Domain=IDEProfileLocatorErrorDomain Code=1 "No profiles for 'com.widex.app.watchkitapp.watchkitextension' were found" UserInfo={NSLocalizedDescription=No profiles for 'com.widex.app.watchkitapp.watchkitextension' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.widex.app.watchkitapp.watchkitextension'.}

error: exportArchive: No profiles for 'com.widex.app.watchkitapp' were found

Error Domain=IDEProfileLocatorErrorDomain Code=1 "No profiles for 'com.widex.app.watchkitapp' were found" UserInfo={NSLocalizedDescription=No profiles for 'com.widex.app.watchkitapp' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.widex.app.watchkitapp'.}

error: exportArchive: No profiles for 'com.widex.app' were found

Error Domain=IDEProfileLocatorErrorDomain Code=1 "No profiles for 'com.widex.app' were found" UserInfo={NSLocalizedDescription=No profiles for 'com.widex.app' were found, NSLocalizedRecoverySuggestion=Xcode couldn't find any iOS Ad Hoc provisioning profiles matching 'com.widex.app'.}

** EXPORT FAILED **
[14:22:10]: Exit status: 70
[14:22:10]: 📋  For a more detailed error log, check the full log at:
[14:22:10]: 📋  /Users/bob/bitbucket/beyond/ios/fastlane/logs/gym/AppNative-AppNative.log
+------------------------------------+---------------------------------------------------------------------------------------------------------------+
|                                                                    Lane Context                                                                    |
+------------------------------------+---------------------------------------------------------------------------------------------------------------+
| DEFAULT_PLATFORM                   | ios                                                                                                           |
| PLATFORM_NAME                      | ios                                                                                                           |
| LANE_NAME                          | ios beta                                                                                                      |
| ORIGINAL_DEFAULT_KEYCHAIN          | "/Users/bob/Library/Keychains/login.keychain-db"                                                              |
| BUILD_NUMBER                       | 7                                                                                                             |
| SIGH_PROFILE_TYPE                  | ad-hoc                                                                                                        |
| MATCH_PROVISIONING_PROFILE_MAPPING | {["com.widex.app", "com.widex.app.watchkitapp", "com.widex.app.watchkitapp.watchkitextension"]=>nil}          |
+------------------------------------+---------------------------------------------------------------------------------------------------------------+

Environment

🚫 fastlane environment 🚫

Stack

Key Value
OS 10.12.5
Ruby 2.4.1
Bundler? false
Git git version 2.13.2
Installation Source /usr/local/bin/fastlane
Host Mac OS X 10.12.5 (16F73)
Ruby Lib Dir /usr/local/Cellar/ruby/2.4.1_1/lib
OpenSSL Version OpenSSL 1.0.2k 26 Jan 2017
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 8.3.3

System Locale

Error
No Locale with UTF8 found �

fastlane files:

`./fastlane/Fastfile`
fastlane_version '2.39.2'
xcversion version: '~> 9'

default_platform :ios

is_jenkins = (true == is_ci?)

platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    ENV['swiftlint'] = 'fastlane/.swiftlint.yml'
    ENV['scheme'] = 'AppNative'
    ENV['APP_IDENTIFIER'] = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
    setup_jenkins(keychain_path: 'jenkins') if is_jenkins
  end

  desc 'Runs build/gym'
  lane :build do |options|
    if is_jenkins
      FileUtils.rm_rf('../output')
      ENV['FL_BUILDLOG_PATH'] = 'fastlane/logs'
      increment_build_number build_number: ENV['BUILD_NUMBER']
      type = options[:type] || 'development'
      match(
        type: type,
        readonly: true,
        app_identifier: [
          ENV['APP_IDENTIFIER'],
          "#{ENV['APP_IDENTIFIER']}.watchkitapp",
          "#{ENV['APP_IDENTIFIER']}.watchkitapp.watchkitextension"
        ]
      )
    end
    gym(
      configuration: options[:configuration] || 'Debug',
      export_method: options[:export_method] || 'development',
      xcargs: "APP_IDENTIFIER=#{ENV['APP_IDENTIFIER']}"
    )
  end

  lane :alpha do
    build(
      type: 'development',
      configuration: 'Release'
    )
  end

  desc 'Submit a new Beta Build to Apple TestFlight'
  lane :beta do
    build(
      type: 'adhoc',
      configuration: 'Release',
    )
  end

  desc 'Deploy a new version to the App Store, meant for Jenkins'
  lane :release do
    build(
      type: 'appstore',
      configuration: 'Release'
    )
  end

  desc "Upload metadata"
  lane :metadata do |options|
    Dir.glob("metadata/**/*.txt") do |filename|
      text = File.read(filename)
      normalized = text.unicode_normalize(:nfc)
      File.open(filename, "w") { |file| file.puts normalized }
    end
    deliver(
      username: options[:username],
      skip_binary_upload: true,
      skip_screenshots: true,
      app_rating_config_path: 'fastlane/rating_config.json',
      force: is_jenkins
    )
  end

  # You can define as many lanes as you want

  after_all do |lane|
  end

  error do |lane, exception|
  end
end
`./fastlane/Appfile`
app_identifier "com.widex.apptwo" # The bundle identifier of your app

for_platform :ios do
  for_lane :beta do
    app_identifier "com.widex.app"
  end
  for_lane :release do
    app_identifier "com.widex.app"
  end
end

fastlane gems

Gem Version Update-Status
fastlane 2.41.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.1.0
slack-notifier 1.5.1
CFPropertyList 2.3.5
claide 1.0.1
colored2 3.1.2
nanaimo 0.2.3
xcodeproj 1.4.4
rouge 1.11.1
xcpretty 0.2.4
terminal-notifier 1.7.1
unicode-display_width 1.1.3
terminal-table 1.7.3
plist 3.2.0
public_suffix 2.0.5
addressable 2.5.1
multipart-post 2.0.0
word_wrap 1.0.0
tty-screen 0.5.0
babosa 1.0.2
colored 1.2
highline 1.7.8
commander-fastlane 4.4.4
excon 0.55.0
faraday 0.11.0
unf_ext 0.0.7.2
unf 0.1.4
domain_name 0.5.20170223
http-cookie 1.0.3
faraday-cookie_jar 0.0.6
fastimage 2.1.0
gh_inspector 1.0.3
uber 0.0.15
declarative 0.0.9
declarative-option 0.1.0
representable 3.0.4
retriable 2.1.0
mime-types-data 3.2016.0521
mime-types 3.1
little-plugger 1.1.4
multi_json 1.12.1
logging 2.2.0
jwt 1.5.6
memoist 0.15.0
os 0.9.6
signet 0.7.3
googleauth 0.5.1
httpclient 2.8.3
google-api-client 0.12.0
json 2.0.2
mini_magick 4.5.1
multi_xml 0.6.0
rubyzip 1.2.1
security 0.1.3
xcpretty-travis-formatter 0.0.4
dotenv 2.2.0
bundler 1.14.6
faraday_middleware 0.11.0.1
io-console 0.4.6
openssl 2.0.3

generated on: 2017-06-27

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 66 (29 by maintainers)

Commits related to this issue

Most upvoted comments

@Reedyuk Instead of xcargs use export_xcargs. I tried the following with success export_xcargs: "-allowProvisioningUpdates"

Hey @KrauseFx I have a definitive fix for people experiencing this issue since Xcode 9. We actually stopped using fastlane because of this bug, and can now use it again 🎉. Clearly it’s not just us. The problem: Starting with Xcode 9, gym can no longer export an ipa, as it was able to do before. Error thrown: Exporting simply fails The fix starts with what was suggested above . Summary: Create a plist with export options, and pass it to gym. The good part: You don’t need to enable the allowProvisioningUpdates flag to make it work and you can still use automatic codesigning for development, which fastlane encourages.

Long version: Starting with Xcode 9 if your build fails, you need to create an exportOptions.plist file in your fastlane folder (for example) and the pass it as a parameter to gym. Pay attention to how you specify the path, it’s important for fastlane to find the plist.
gym(scheme: "YourSchema",export_options: "./fastlane/exportOptions.plist")

This allows gym to export ipa’s, even on build machines with no internet access, where -allowProvisioningUpdates would not always, reliably work. Now what this export options file contains is also really important.

Here is an example exportOptions.plist file for an app with multiple targets. Replace with your own data as needed:

<?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>method</key>
	<string>app-store</string>
	<key>provisioningProfiles</key>
	<dict>
		<key>your.app.domain</key>
		<string>AppStore Profile Name</string>
		<key>your.app.domain.imessage</key>
		<string>AppStore iMessageExtension profile name</string>
		<key>your.app.domain.SiriExtention</key>
		<string>AppStore SiriExtention profile name</string>
		<key>your.app.domain.SiriExtentionUI</key>
		<string>AppStore SiriExtentionUI profile name</string>
		<key>your.app.domain.TodayWidget</key>
		<string>AppStore Today Widget profile name</string>
		<key>your.app.domain.watchkitapp</key>
		<string>AppStore Watch App profile name</string>
		<key>your.app.domain.watchkitapp.watchkitextension</key>
		<string> AppStore WatchOS3 Extension profile name</string>
	</dict>
	<key>signingCertificate</key>
	<string>iPhone Distribution</string>
	<key>signingStyle</key>
	<string>manual</string>
	<key>stripSwiftSymbols</key>
	<true/>
	<key>teamID</key>
	<string>YOUR_TEAM_ID</string>
	<key>uploadBitcode</key>
	<false/>
	<key>uploadSymbols</key>
	<true/>
</dict>
</plist>

Thanks to this article for helping dig deeper and this solution https://blog.bitrise.io/new-export-options-plist-in-xcode-9

export_xcargs: "-allowProvisioningUpdates" works for me!

Had the same issue, adding export_xcargs "-allowProvisioningUpdates" to Gymfile fixed it.

where do i use export_xcargs? Would it be like this? gym(scheme: "purple-monkey-dishwasher", export_xcargs: "-allowProvisioningUpdates")

Actually, i can confirm that has done the trick. Thanks @mooshee

I have the exact same issue. Xcode 9 beta, automatic signing. Feels like this is quite urgent as XCode 9 is about to go public.

Alright, thanks everybody, this is super useful, I prepared this little PR https://github.com/fastlane/fastlane/pull/10345 which will enable -allowProvisioningUpdates by default for all Xcode 9 gym builds. I really appreciate everybody helping on this - this will be on by default with the next fastlane release 🚀

Thanks ❤️

@fastlane-bot NO, I DO NOT.

The issue here with Xcode 9 and export_xcargs "-allowProvisioningUpdates" works for me too.

It turns out that Xcode 9 will not prompt you to allow keychains access until you set “allowProvisioningUpdates”. After doing that, the prompt shows up and everything goes fine by allowing the access.

Strange, as i managed to get the app to upload via Xcode from the same machine and it worked. I then ran the fast lane failing command from the terminal but with -allowProvisioningUpdates and it succeeded.

Yeah, let’s continue the conversation over at https://github.com/fastlane/fastlane/pull/10345 👍

@thebugcode Not sure if this applies to your setup, but in my case I only needed to add signingStyle manual to my export options. It’s not very well documented (AFAIK), but you can actually pass a hash as export_options that gym will add to the generated exportOptions.plist, so in my case I just had to add it like this:

gym(
  ...
  export_options: {'signingStyle' => 'manual'}
)

@casz yea, I can push to test flight now, thanks!

with -allowProvisioningUpdates you need to open Xcode and add your apple account.

I wonder if anybody here has figured out how to do this programmatically?