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

Create IPA from CLI #13065

Open
passsy opened this Issue Nov 17, 2017 · 16 comments

Comments

@passsy
Copy link
Contributor

passsy commented Nov 17, 2017

Flutter doesn't allow me to build an .ipa which can be published to hockeyapp/fabric or the app store.

# creates an .app not an .ipa 
flutter build ios --release

Manual bundling is required:

xcodebuild -exportArchive -archivePath build/ios/iphoneos/Runner.app -exportPath build/ios/iphoneos/ -exportOptionsPlist ci/enterprise-options.plist

Flutter includes tools such as measuring the ipa size #4609, but I can't find a way to create an .ipa.

A followup issue for Generate a production-ready IPA from a single command is still missing

@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

eseidelGoogle commented Nov 17, 2017

I don't know the details, but if it's really a simple as just one command we could certainly wrap that in flutter build ipa or similar. :) I had previously been under the impression that the XCode GUI had to be involved with .ipa generation (e.g. it wasn't possible from the command line). @cbracken or @xster would know more.

@sethladd

This comment has been minimized.

Copy link
Contributor

sethladd commented Nov 17, 2017

cc @mit-mit @devoncarew for CLI

@passsy

This comment has been minimized.

Copy link
Contributor

passsy commented Nov 17, 2017

Also running xcodebuild -exportArchive currently fails with xcode8 and xcode9

12:50:17 + xcodebuild -exportArchive -archivePath build/ios/iphoneos/Runner.app -exportPath build/ios/iphoneos/ -exportOptionsPlist ci/enterprise-options.plist
12:50:17 2017-11-17 13:50:17.672 xcodebuild[55483:4933639] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/nl/b7mbgsx16_g8zpdvhg37hm0h0000gn/T/Unnamed archive_2017-11-17_13-50-17.671.xcdistributionlogs'.
12:50:17 error: exportArchive: exportOptionsPlist error for key 'method': expected one of {}, but found enterprise
12:50:17 
12:50:17 Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'method': expected one of {}, but found enterprise" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'method': expected one of {}, but found enterprise}
12:50:17 

with enterprise-options.plist

<?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>enterprise</string>
	<key>teamID</key>
	<string>OUR_ID</string>
	<key>provisioningProfiles</key>
	<dict>
		<key>com.example.fluttertest</key>
		<string>comExample Enterprise Wildcard Distribution</string>
	</dict>
</dict>
</plist>
@xster

This comment has been minimized.

Copy link
Contributor

xster commented Nov 17, 2017

@mit-mit

This comment has been minimized.

Copy link
Member

mit-mit commented Jan 8, 2018

@cbracken can you elaborate?

@cbracken

This comment has been minimized.

Copy link
Member

cbracken commented Jan 8, 2018

Thanks for filing this issue!

Our currently supported iOS releasing process is described in Releasing for iOS and as noted, makes use of the Xcode UI. We don’t yet support a pure command-line mechanism for releasing to the App Store, and it’s not something we currently have prioritised but I’d certainly be more than happy to review pull requests.

@oemera

This comment has been minimized.

Copy link

oemera commented Jan 10, 2018

@cbracken thanks for your response. The error also happens when archiving within the Xcode UI. Please look into my issue: #13070. Based on the reactions I guess there are a couple of others who have this issue and can't release their app with the new version of Xcode.

If you have any questions please let me know.

@cbracken

This comment has been minimized.

Copy link
Member

cbracken commented Jan 10, 2018

Thanks for pointing to #13070, I'll take a look at that today.

@alibitek

This comment has been minimized.

Copy link
Contributor

alibitek commented Jan 10, 2018

xcodebuild: Deploy iOS app from Command Line
A really good summary of xcodebuild command line capabilities.
It even includes an example of how you can submit the .ipa to iTunes Connect from the command line.

@peace2knowledge

This comment has been minimized.

Copy link

peace2knowledge commented Jan 13, 2018

change to project ios directory,excute following command:

xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphoneos -configuration Release archive -archivePath $PWD/build/Runner.xcarchive
xcodebuild -exportArchive -archivePath $PWD/build/Runner.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build/Runner.ipa

exportOptions.plist is on ios directory.
file content 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>compileBitcode</key>
    <true/>
    <key>method</key>
    <string>enterprise</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.company.appname</key>
        <string>provisioningProfiles name </string>
    </dict>
    <key>signingCertificate</key>
    <string>iOS Distribution</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>xxxxxx</string>
    <key>thinning</key>
    <string>&lt;none&gt;</string>
</dict>
</plist>

@oemera

@xster

This comment has been minimized.

Copy link
Contributor

xster commented Jan 27, 2018

This is theoretically possible. I got it to work using Fastlane (which really just invokes xcodebuild archive).

We can document the flow more or possibly integrate Fastlane into flutter tools, though there are no immediate plans yet.

In the meantime, you can flutter build ios --release --no-codesign first and then use build_ios_app(export_method: "app-store", ...) in Fastlane with whichever signing method you prefer.

@csga5000

This comment has been minimized.

Copy link

csga5000 commented May 22, 2018

+1 on this. I think building iPa's would be great. During beta phase of apps I sometimes have to release new versions every couple days, and it takes forever when I have to test the app by running it on a device, then do flutter build --release, and then open xcode, and do product archive, and then in organizer upload to app store, and finally wait for apple to process my app.

I think this could be streamlined to just: flutter build ipa --release and then open application loader and deliver my app, (and then still wait for apple to process the app). It's still a bit slow, but at least I don't have to wait forever for flutter to build my app so I can wait another forever for xcode to archive my app. Admittedly it may be so slow partially cause my mac (not my main machine) is a mac mini and runs like a slug.

If you're not aware of application loader, you can open it through xcode XCode > Open Developer Tool > Application Loader, but you can also pin it to your task bar to open it without opening xcode (or install it separately, though that generally is very out of date).

@fuzzybinary

This comment has been minimized.

Copy link

fuzzybinary commented May 29, 2018

I would also appreciate this since we want to build ipas for distrubution through CI.

One (fairly crazy) issue I'm having with the current build system is that changing between flutter build ios --debug and flutter build ios --release actually modifies the Podfile.lock, and requires a fresh pod install, which is overriding a change I need to make in one of our Pods to avoid grpc/grpc#7406

Also because of this, we have to run flutter build ios --release followed by xcodebuild archive followed by xcodebuild exportArchive to build an ipa. This causes the app to be built twice (kind of a waste of time).

It seams like a lot of the build system could use refactoring. In general:

  • You should be able to generate ipas for a given flavor from the command line
  • flavors should be supported more directly from flutter cli (see #14648)
  • switching flavors shouldn't modify the Podfile.lock. This may require modifying Debug/Release.xcconfig to not rely as much on the Generated.xcconfig (or at least removing the location of the Flutter SDK from Generated and putting it in Debug/Release.xcconfig

I'm actually more than willing to help with this with some direction from the flutter team on what they think the best approach would be.

@eseidelGoogle

This comment has been minimized.

Copy link
Contributor

eseidelGoogle commented May 29, 2018

@xster xster added this to Tooling in iOS Framework Oct 23, 2018

@xster xster moved this from Tooling to Publishing in iOS Framework Oct 23, 2018

@MisterJimson

This comment has been minimized.

Copy link

MisterJimson commented Nov 26, 2018

This is what I ended up using as a complete release script, ready for uploading to the Play Store/App Store.

flutter build apk
cp build/app/outputs/apk/release/app-release.apk buildOutput/
flutter build ios
cd ios
xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphoneos -configuration Release archive -archivePath $PWD/build/Runner.xcarchive
xcodebuild -exportArchive -archivePath $PWD/build/Runner.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build/Runner.ipa
cd ..
cp ios/build/Runner.ipa/Runner.ipa buildOutput/
@zoechi

This comment has been minimized.

Copy link
Contributor

zoechi commented Dec 11, 2018

Might be related to #24641, #13070, #12774

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment