xcodebuild using wrong provisioning profile - ios

I have a bash script where I am trying to automate pushing an IPA to TestFlight. Currently this script is successfully uploading to the app-store with an ad-hoc provisioning profile and not my distribution profile as such I am unable to push the build to TestFlight as it does not have the beta-reports-active key. This is easily fixable from within XCode but I have had no luck using command line which is integral to what I want to do. This is my current command trying to use manual signing:
xcodebuild archive -workspace $NAME.xcworkspace -allowProvisioningUpdates -scheme $NAME -configuration Release -archivePath ../builds/$NAME.xcarchive DEVELOPMENT_TEAM=$TEAM_ID CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="iOS Distribution: MY_NAME" PROVISIONING_STYLE=Manual PROVISIONING_PROFILE_SPECIFIER="PROVISIONING PROFILE "
Is there a way of getting the correct provisioning profile through command line
EDIT
Examples of what I have tried:
Downloading and inserting the provisoning profile int0 ~/Library/MobileDevice/Provisioning\ profiles and then using PROVSIONING_PROFILE_SPECIFIER to point to the profile
Inserting the app-store method into the export options plist file
Creating new ExportOptions file that specifies manual signing as well as the provision profile being used - so far getting a signing error due to no provisioning profile being found
Hope this ^ is clear

I had a similar problem, I was using fastlane to push to testflight and it automatically kept pulling the wrong provisioning profile..
When I dug deeper by running
xcodebuild -showBuildSettings -workspace Freshdesk.xcworkspace -scheme <My Build scheme>
I realised that no matter what scheme I picked I kept getting the same provisioning profile in the command line.
I then dug into xcode and chanced on this parameter
This was set to staging and I could never sign my app for the app store build, I changed it to production and it fixed my problems
You can find this under "configurations" in the info tab of your project and not the target
I hope this helps!

Related

xcodebuild provisioning profiles not found?

I'll try to be polite talking about xCode.
Issue:
we updated provisioning profiles because prev ones are expired.
Now I can archive/build from xCode but can't using xcodebuild (which must be the same)
I did everything:
removing, adding profiles, recreating ...
reinstalling ... restarting...
removing account, adding back and a lot more
sudo xcodebuild -scheme nl.xxx.demo.iphone -workspace xxx.xcworkspace clean build
error:
=== BUILD TARGET xxxWatchAppDemo Extension OF PROJECT xxx WITH CONFIGURATION Debug ===
Check dependencies
Code Sign error: No provisioning profiles found: No non–expired provisioning profiles were found.
But when I'm archiving or building through xCode everything is just fine, and inside ipa, embedded.mobileprovision is actually our new mobileprovision with UUID d9179316-6950-4369-94dc-b7d71bba25a1
And if I explicitly set provisioning profile - it doesn't work out:
sudo xcodebuild -scheme nl.xxx.demo.iphone -workspace xxx.xcworkspace archive PROVISIONING_PROFILE=d9179316-6950-4369-94dc-b7d71bba25a1
error
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “d9179316-6950-4369-94dc-b7d71bba25a1”, however, no such provisioning profile was found.
Not found??? Really?
I checked /Users/xxx/Library/.../Provisioning Profiles/... and it's there.
I deleted it, added, repeated it 10 times, no result.
What kind of magic it is?
Any help appreciated.
Thanks
So Jenkins has been running under buildagent user, however provisioning profiles weren't found.
I created symbolic link to my
/buildagent/Library/MobileDevice/ProvisioningProfiles/ in very root folder - /Library/.
That solved my issue

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!

Code Sign error in xcodebuild archive

I am trying to generate a .ipa file only through command line,
xcodebuild archive -project someproject.xcodeproj -scheme somescheme -
archivePath /somepath/someproject.xcarchive
This command still depends on the provisioning profile I have selected in xcode, and fails if a wrong profile is chosen.
The error generated is :
Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “some UUID”, however, no such provisioning profile was found.
Is there a way I can make archive command independent of provisioning profile chosen in Xcode ? Or can this be a configurable parameter in the command. Do we have a file where this value is mentioned, in that case I can overwrite it.
It looks like you should be able to use an additional parameter on the xcodebuild command you mentioned above.
There is an additional option called exportProvisioningProfile that allows you to specify the provisioning profile to use.
From Apple Docs:
-exportProvisioningProfile profilename
Specifies the provisioning profile that should be used when exporting the archive.
Link to documentation:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html

Build iOS App Extension through command line

I'm trying to build an iOS app containing an app extension from the command line. However when I use the following xcodebuild command to build:
xcodebuild -sdk iphoneos -configuration "Debug" -workspace "/Users/user/build/app_extension_demo/app_extension_demo.xcworkspace" -scheme "AppExtensionDemo" -CODE_SIGN_IDENTITY="iPhone Developer: ios developer" PROVISIONING_PROFILE=34070551-ebe8-412a-b57c-9fbdf9a42ed4 derivedDataPath "/Users/user/build/app_extension_demo/Build/Products/Debug-iphoneos" OBJROOT="/Users/user/build/app_extension_demo/Build/" SYMROOT="/Users/user/build/app_extension_demo/Build/Products" CONFIGURATION_BUILD_DIR=/Users/user/build/app_extension_demo/Build/Products/Debug-iphoneos
I get the following error:
ERROR: Code Sign error: Provisioning profile does not match bundle identifier: The provisioning profile specified in your build settings ("XC Ad Hoc: com.mycompany.AppExtensionDemo") has an AppID of "com.mycompany.AppExtensionDemo" which does not match your bundle identifier "com.mycompany.AppExtensionDemo.NumberWidget".
I'm using a provisioning profile (XC Ad Hoc: com.mycompany.AppExtensionDemo) with AppID of com.mycompany.AppExtensionDemo, but the app extension is expecting a different AppID (com.mycompany.AppExtensionDemo.NumberWidget). Everything builds fine when done through the Xcode app. I noticed that Xcode automagically created the provisioning profile for "com.mycompany.AppExtensionDemo.NumberWidget" for the app extension target. However when building through the command line, I'm not sure how to associate app extension profile to the app extension target. Any help would be appreciated!
So I've just figured this out and posted my answer here: https://stackoverflow.com/a/29605731/1153630
Basically you can set an $ENVIRONMENT_VARIABLE into the Provisioning Profile field in your targets's Build Settings and assign it from the command line instead of using PROVISIONING_PROFILE=... - have a look at my other answer for more detail.

building xcode project from jenkins fails. when building in command line runs just fine. why?

building xcode project from jenkins fails.
when building in command line runs just fine.
why?
this is is the error I get:
[BEROR]Code Sign error: No matching provisioning profile found: Your build settings specify a provisioning profile with the UUID “_UUID_”, however, no such provisioning profile was found.
[BEROR]CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.1'
this is the command line used:
xcodebuild -project PROJECTNAME.xcodeproj/ -target TARGETNAME -configuration Release -sdk iphoneos7.1 clean build
ps: anything with OBJECT was censored so this question can appear online, there was real data there before.
Are you using the login key-chain or did you create a different key-chain for jenkins builds app signing?
If you are just using the login key-chain make sure you unlock the key-chain during the build.
If you are using a different key-chain make sure you swap key-chains and then unlock it.
Jenkins - Xcode build works codesign fails - this thread is quite informative.
Also adding these 2 commands to your build can help you debug it:
/usr/bin/security list-keychains
/usr/bin/security find-identity

Resources