Cannot export unsigned IPA from Xcode 5 - ios

Under Xcode 4 I was able to export an unsigned IPA in order to send that to clients with Enterprise accounts for resigning. With the upgrade to Xcode 5 this option has been removed. I found a similar question that found a work around for Cocoa apps, but this won't work for iOS apps as it yields a .app file.
Does anyone know how an unsigned IPA can be generated from Xcode 5, or know of another way to give something to my client for resigning that doesn't involve trading certificates or the project itself?

We had the exact same problem. We used this process for a year to deliver an unsigned IPA to our client, who would then sign it when their Enterprise Profile to release it to all their employee's. The work around turned out to be pretty straight forward. We just signed the IPA with one of our Distribution Profiles, and the customer, in turn, was able to take that signed IPA and resign it with their Enterprise Distribution Profile. It turns out, having the "Don't Resign" option in the drop down was not needed.

You can run this in your *.xcodeproj directory:
xcodebuild -project YOUR_PROJECT.xcodeproj -exportArchive -exportFormat ipa -archivePath $(pwd)/YOUR_PROJECT.xcarchive -exportPath $(pwd)/YOUR_PROJECT.ipa CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -alltargets -configuration Release
You can create .xcarchive by running:
xcodebuild -scheme YOUR_PROJECT_SCHEME archive CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -archivePath $(pwd)/YOUR_PROJECT.xcarchive
You can create scheme by using xcodeproj and this ruby(.rb) script:
require 'xcodeproj'
xcproj = Xcodeproj::Project.open("YOUR_PROJECT.xcodeproj")
xcproj.recreate_user_schemes
xcproj.save
You can install xcodeproj by running:
sudo gem install xcodeproj :)

Related

xcode 7: Building for enterprise and adhoc with the same archive

Currently using the xcode 6 build process, we first create the xcarchive with the following command
xcodebuild -workspace OurApp.xcworkspace -scheme MainScheme \
clean archive -archivePath OurApp.xcarchive -sdk "iphoneos" \
-configuration "Release" CODE_SIGNING_REQUIRED="NO" \
CODE_SIGN_IDENTITY="" PROVISIONING_PROFILE=""
By not doing any code signing and provisioning, we then use the exportArchive command to generate the respective enterprise and adhoc ipas using the same archive like this.
xcodebuild -exportArchive -archivePath OurApp.xcarchive \
-exportPath OurApp-adhoc.ipa -exportFormat "ipa" \
-exportProvisioningProfile "Our Adhoc Provisioning Profile"
and
xcodebuild -exportArchive -archivePath OurApp.xcarchive \
-exportPath OurApp-enterprise.ipa -exportFormat "ipa" \
-exportProvisioningProfile "Our Enterprise Provisioning Profile"
Note that we would have our servers set the appropriate code sign identity before running these exportArchive commands. This worked really well for us since we could use the same xcarchive(takes 8 minutes to compile) and create multiple variants with it(exportArchive step doesn't take more than 30 seconds).
In Xcode7, Apple Introduced exportOptionsPlist. Xcode 7 also saw the introduction of features such as Swift Support and Universal Links, both of which we deploy. These two features require you to use exportOptionsPList it seems. The only way I was able to get exportOptionsPlist is that I could no longer set CODE_SIGN_IDENTITY and PROVISIONING_PROFILE to "" when generating IPA. As a result, our build times will double since we now have to build the xcarchive twice
I was wondering if anyone knows a way to create an enterprise IPA and an adhoc ipa using the same xcarchive.
Hi its not possible because whenever you create an iPA from Archive it create each iPA separately for Adhoc or Enterprise or else.

iOS : Issue in submitting app to appStore / adhoc deployment

i am trying to submit app to appStore and also alternatively trying to create ipa for adhoc deployment. i have already tried many solutions but nothing changed. I have already generated new certificates and provisioning profiles but it always shows me this error message:
You already has a valid iOS Distribution certificate
You have a valid iOS Distribution certificate in the Member Center, but it is not installed locally. if uour sigining identity is installed on another Mac, You can export on that Mac and import it on this Mac.
Please help me out to get rid of this issue
you are missing your Distribution Certificates Private key on this computer. If you have another machine that can codesign distribution builds, then transfer the certificates and profiles from that machine using the workflow discussed in the "Transferring iOS Certificates and Profiles to another Machine (Exporting and Importing Certificates and Profiles)" section above, otherwise follow the instructions below (as appropriate for the type of app you are creating).
if you revoke your iOS Distribution certificate, then Xcode will recreate your private key and request a new Distribution Certificate for you. See the steps in the Revoking Certificates section of the App Distribution.
use this link
If you need to make an .ipa without valid Developer's account, please follow the next steps:
1) xcodebuild clean -workspace /Users/JohnDoe/Projects/TheApp/TheApp.xcworkspace -configuration Release -scheme TheApp
2) xcodebuild archive -workspace /Users/JohnDoe/Projects/TheApp/TheApp.xcworkspace -scheme TheApp -archivePath ~/TheApp.xcarchive CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
3) cd ~
4) xcodebuild -exportArchive -exportFormat ipa -archivePath TheApp.xcarchive -exportPath ~/TheApp.ipa
After the final step the .ipa is waiting for you in your home directory!

Export .ipa file from Xcode project without ever opening Xcode

We have an API that users can call to create Cordova apps/projects, upload their www directory, and then start compilation and download the executable binary file. This binary file will then go into a private app store.
I'm having trouble with the compile step for iOS. The Cordova build step is no problem, but it doesn't output a binary file, like it does for Android. After reading everything I found on Stackoverflow and elsewhere, the plan was this:
xcodebuild clean -configuration Release -alltargets
xcodebuild -scheme MyApp archive -archivePath build/MyApp
xcodebuild -exportArchive -exportFormat ipa -archivePath "build/MyApp.xcarchive" -exportPath "MyApp.ipa" -exportProvisioningProfile "My Prov Profile"
Given that the signing identity and everything is set up correctly, it almost works. The first command executes fine. The second command just hangs.
However, if I open the project in Xcode, and then execute the commands, it compiles and exports, and I'm left with an .ipa file, which is what I wanted. It seems that Xcode sets up a workspace and some scheme-related things when the project is first opened.
Is there any way I can get xcodebuild (or xcrun, or anything, for that matter) to create this workspace file for me?
Or is there another way to approach this?
Right now, I have a solution where I actually open the Xcode project, wait 15 seconds, and then proceed. But I can think of a thousand ways that will fail at some point, so I would like to change it to something a little more elegant.
I currently have Xcode 6.3 installed, if that is relevant.
Update: Opal's answer below set me on the right path (I think). What I ended up doing, was exporting a shared scheme as per Opal's link, and using that as a template for future apps. The solutions was something like this:
# Copy shared scheme file into directory
mkdir /path/to/project/dir/MyApp.xcodeproj/xcshareddata
mkdir /path/to/project/dir/MyApp.xcodeproj/xcshareddata/xcschemes
cp data/MyScheme.xcscheme /path/to/project/dir/MyApp.xcodeproj/xcshareddata/xcschemes/.
# Use sed to replace app name in scheme file
sed -i '' "s/%app_name%/MyApp/g" MyApp.xcodeproj/xcshareddata/xcschemes/MyScheme.xcscheme
# CD into directory
cd /path/to/project/dir
# Move files from Cordova to our build directory
cp -r CordovaLib/build/* build/.
# Build and export
xcodebuild clean -configuration Release -alltargets
xcodebuild -scheme MyScheme archive -archivePath build/MyApp
xcodebuild -exportArchive -exportFormat ipa -archivePath "build/MyApp.xcarchive" -exportPath "MyApp.ipa" -exportProvisioningProfile "MyProvProfile"
It seems that the application you try to build has no shared schemes. Schemes if not shared, are created when project is loaded to xcode. To create shared schemes see this site.
These are the steps I used to automate ipa generation without opening xcode in my cordova environment. (xcode version: 6.0.1 cordova version: 3.6.0)
Change in cordova/build.xcconfig: CODE_SIGN_IDENTITY=iPhone Distribution (change "Developer" to "Distribution". )
run cordova build ios --device in cordova workspace that generates .app file
Sign using : xcrun -sdk iphoneos PackageApplication -v ${WORKSPACE}/platforms/ios/build/device/${application.name}.app -o ${WORKSPACE}/platforms/ios/build/${application.name}.ipa --embed ${ios.distribution.provisionfile}.mobileprovision --sign ${code.signing.identity}

xctool build with today extension

we have an app integrated with today extension, we use xctool and Jenkins to do continuous build and in-house distribution.
In command line, before we use
xctool -workspace our_workspace.xcworkspace -scheme app_schme -xcconfig path_to_xcconfig -configuration Release build archive -archivePath path_to_archive
to generate archive and then export to .ipa, it works fine.
But right now with today extension, we have to build it with another scheme and xcconfig, we put certificate and provisioning profile in xcconfig, as today extension is a new target and should built with its own certificate and provisioning profile, I'm wondering how to achieve using xctool.
Any help is appreciated.
I finally managed to export ipa files via xcodebuild. Since the xctool is built upon xcodebuild, this answer might help.
First of all, when you create an extension, the extension's target will be embedded into your main app's scheme.
So, there is no need to use two schemes.
Then, in your project settings page, create a new configuration, say AdHoc. And then you can set a new Provisioning Profile in both of your target's build settings.
(project settings)
(the build settings of one target)
Then set the right provisioning profiles for your targets (And you'd better set the code sign identity to automatic, so that Xcode can determine which code sign identity is to be used).
Next step, you can archive your app using xcodebuild with the new configuration you just created above:
xcodebuild -project Extension\ Demo.xcodeproj -scheme Extension\ Demo -sdk iphoneos -archivePath ./Build/extension-demo.xcarchive -configuration AdHoc archive
In this step, the codesign will sign two of your targets separately by the provisioning profiles you specified.
Finally, export the .xcarchive file to ipa, again using xcodebuild;
xcodebuild -exportArchive -archivePath ./Build/extension-demo.xcarchive -exportPath ./Build/extension-demo.ipa -exportWithOriginalSigningIdentity
Notice that -exportWithOriginalSigningIdentity is set, so that xcodebuild will not re-sign your ipa, and the code signature in the xcarchive file is preserved.

xcodebuild not copying file from .app

I've created a signed .xcarchive file using the xcodebuild command.
Inside the .xcarchive is a .app file. Inside the .app is a file called archived-expanded-entitlements.xcent. This file is the key to my problem.
I run a different xcodebuild command that creates an .IPA file from the .xcarchive.
Creating the IPA fails because the archived-expanded-entitlements.xcent file is missing. The thing is, xcodebuild is creating a temporary directory where it copies over my .app file, and inside THAT .app file, there is no archived-expanded-entitlements.xcent file.
All the other files are in there except this one.
The commands I run are below:
This creates the xcarchive:
xcodebuild -project diplomat.xcodeproj -scheme schemeName archive -archivePath /Path/To/Archive/name.xcarchive -configuration AppStore CODE_SIGN_IDENTITY="identity" PROVISIONING_PROFILE=provProfile
This creates the IPA:
xcodebuild -exportArchive -exportFormat IPA -archivePath /Path/To/Archive/name.xcarchive -exportPath /Path/To/Archive/name.ipa
Despite specifying the location of the .xcarchive, it creates a temporary directory and doesn't include the important file.
Please note, the archived-expanded-entitlements.xcent file is created during the .xcarchive process (the first command that's run) and fails to copy into the temp directory during the second command run.
This is the exact error. Google and StackOverflow have yielded similar errors, but nothing with this actual problem.
Checking original app
+ /usr/bin/codesign --verify -vvvv /var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541- 42128-00007ED35037747A/name.app
Program /usr/bin/codesign returned 1 :
[/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app: a sealed resource is missing or invalid
file missing:
/private/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app/archived-expanded-entitlements.xcent
]
Codesign check fails :
/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app: a sealed resource is missing or invalid
file missing:
/private/var/folders/sl/_wdkd56d5pb05snr559cmcww0000gn/T/D2133E2C-DC66-427C-A3C5-903A88DD0541-42128-00007ED35037747A/name.app/archived-expanded-entitlements.xcent
Done checking the original app
This is indeed a weird behaviour of xcodebuild, but you can still use the exportArchive command and specify the provisioning profile using exportProvisioningProfile:
xcodebuild -exportArchive -exportFormat IPA \
-archivePath /Path/To/Archive/name.xcarchive \
-exportPath /Path/To/Archive/name.ipa \
-exportProvisioningProfile 'PROVISIONING_PROFILE_NAME'
This will reembed the provisioning profile within the app and you won't actually need to speciify the code signing identity again, because the archive should already be signed during the archive process.
My answer would be considered a workaround, but it solved the problem. I do not know why the one file was not being copied over, but I found a way so it wasn't important.
Replace the 2nd xcodebuild command with this, which utilizes xcrun:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v /Path/To/Archive/name.xcarchive/Products/Applications/name.app -o /Path/To/Archive/DiplomatStaples.ipa --sign "identity" - -embed "provProfile"
This creates an IPA using the xcarchive and then re-embeds the identity and the provisioning profile, so even though the same error as above still occurs and is printed out,the "double dip" with the code signing identity and provisioning profile makes it meaningless. I can now install the app on devices.
For inquiring minds: The reason I'm not just using xcrun in the first place is because even if I specify a prov profile and signing identity, xcrun will use the embedded profile and signing identity in the project based on the configuration (Debug, AppStore, Release, etc) that I specify. xcodebuild will actually sign with the certs I provide it.
The goal of this operation was to remove the need for provisioning profile certs that the CI system required from developer machines, enabling testing the "AppStore" configuration to be signed with AdHoc distribution certs, and enabling re-signing of the xcarchive later on with the actual App Store distribution certs.

Resources