Remove codesigning of .app - ios

I developed an iOS app for Cydia, but now I have the Problem, that none except me can run the .deb. I guess because the .app is code-signed. I made a shell script that automatically builds the .deb, I am copying the .app from its path to the debs file structure and then I have to run dpkg-deb -b /Users/David/Downloads/My_App. I already tryed to remove the code-signing with codesign --remove-signature in terminal, but I get unsupported type or version of signature back. Is there a semi-official way to remove the code-signing from an .app in Terminal or in Xcode?
Thanks!

Related

Is it possible to install a ".app" build file to an iPad from within Xcode, without loading the actual project file?

Without actually loading my .xcodeproj into Xcode, is it possible, from the Xcode app, to start an app install to my iPad using the .app file only, which was generated in an earlier build?
This is my last line of inquiry... I'm just looking at potential options because I don't have a paid developer account (yet) and might try to use Teamviewer to log into the remote client Mac to install via Xcode, but do not wish to reveal my project file/code on the remote machine. Installing from within Xcode purely using the .app file would solve my problem, if possible.
I managed to work out a way to do it using this, this, and this. You will need the XCode command line tools, which come as part of the App Store XCode install, or you can get the command line tools only from here.
First up, download and install npm. Then install ios-deploy from the terminal,
sudo npm install -g ios-deploy --unsafe-perm --allow-root
If you need to build from the command line, make sure you have a working XCode project which builds as you want, open a terminal and go to the directory with your .xcodeproj inside, then type:
xcodebuild -list -project <NAME>.xcodeproj/
xcodebuild -scheme <SCHEME NAME> build
Then, or if you've already built in XCode and just want to deploy your .app file to the iOS device, type:
ios-deploy debug --bundle <APP PATH>
You can change debug to release, or either way it will use whatever you set your XCode build configuration to be I think. The <APP PATH> location depends on your XCode install, but the most recent location (I think) is
~/Library/Developer/Xcode/DerivedData/{app name}/Build/Products/Deployment/
This will install your .app onto the iOS device from the command line, and you don't need to load XCode up, or expose your source files. Just requires the .app file. For me, this is a potentially useful way to install an app remotely on a client's device without the need for a paid developer account.

Build IPA from .APP bundle without xcworkspace

There used to be a way to build an IPA from an .APP bundle using xcrun but Apple, for some reason, has deprecated PackageApplication. I'm left only with xcodebuild, which requires an Xcode workspace file. My .APP wasn't created via xcode. It was made with Visual Studio for Mac with Xamarin. I can make an IPA by exporting an archive from the IDE but what I'm trying to do is build the IPA from the command line and sign it. The signing part is very straightforward but I don't know how to build the IPA without ZIPping it manually, adding in the embedded.mobileprovision, etc.
Is there an alternative to xcbuild PackageApplication that I can use?
I'm trying to do is build the IPA from the command line...
You can use msbuild to build/package an .ipa
/Library/Frameworks/Mono.framework/Commands/msbuild \
AStackOverflowSolution.sln \
/p:Configuration=Ad-Hoc \
/p:Platform=iPhone \
/p:BuildIpa=true
re: Building via the Command Line (On Mac)
For Windows, include the ServerAddress and ServerUser of your macOS build system
/p:ServerAddress="192.168.40.40"
/p:ServerUser="YourmacRemoteSSHuser"
re: IPA Support in Xamarin.iOS

Create .ipa using multiple targets

Currently I'm using a bash script to build and archive our iOS application. With the introduction of "Watch" I have found that my script is no longer able to create the necessary .ipa file as it once did.
The build would generate a single .app file which I would use XCRUN to invoke PackageApplication in order to create the .ipa. Now I'm looking to archive 2 .app files along with 1 .appex file.
Has anyone been able to successfully create an .ipa file via command line/script with multiple .app files?
Using Xcode 6.2
Update
Now using Xcode 7 GM along with OSX 10.10.4.
For "TEST" builds I had a difficult time with developers always changing the profiles so I made 2 builds; one from the command line and the other via the IDE (Xcode). I changed the .ipa extension to .zip and compared the 2.
The good build from the IDE had generated a file called "archived-expanded-entitlements.xcent" which had all the signing identities defined correctly.
I copied this file out to a different directory and use it to inject with all other subsequent builds. The builds now are able to be loaded on the phone & watch for testing.
Below is an example of how to do it. A bit of a hack but it works.
security -v unlock-keychain -p "password" "keychainPath"
xcodebuild -configuration Test -scheme YourAppName -archivePath somePath/YourAppName.xcarchive archive
xcodebuild -exportArchive -exportFormat IPA -archivePath somePath/YourAppName.xcarchive -exportPath somePath/YourAppName.ipa
unzip -o somePath/YourAppName.ipa -d somePath
cp somePath/archived-expanded-entitlements.xcent somePath/Payload/YourAppName.app
zip -qr somePath/YourAppName.ipa Payload
I find a solution which is working on the archive file of the project which has watch, app and extension.
xcodebuild -exportArchive -archivePath AppName.xcarchive/ -exportPath AppName.ipa -exportFormat ipa -exportWithOriginalSigningIdentity
This command basically uses same signing identify and provisioning profile to export the ipa from raw xcarchive file.
We have sort of work around to generate .ipa that contains iPhone app and apple watch app.
After the .app is generated using Xcodebuild, in the bash script we do the following
A)
Create Directory with Application Name
Inside Application directory create sub directory named Payload
Copy .app into Payload directory
B)
Inside Application directory create sub directory named WatchKitSupport as a sibling to Payload.
Copy a binary named "WK" from the iOS 8.2 SDK in Xcode to your new WatchKitSupport directory. This binary can be found at: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/Library/Application Support/WatchKit/
Make sure the "WK" binary is not touched/re-signed in any way. This is important for validation on device.
Zip the application folder
Rename .zip to .ipa
When expanded the IPA should contain (at least):
xxx.ipa
|________Payload/
|________WatchKitSupport/
|_____WK
This works for us.

how to call builtin-productPackagingUtility in command line

When you specify an entitlement and a code signing identity in build settings (Xcode 4.2.1), you have the following output when you build from Xcode:
ProcessProductPackaging "myAppName.entitlements" "/path/to/myAppName.xcent"
cd /path/to/myAppName/SourceCode
builtin-productPackagingUtility "/path/to/myAppName/SourceCode/myAppName.entitlements" -entitlements -format xml -o "/path/to/myAppName.xcent"
CodeSign "/path/to/Garfields Comic Boom 1.0.app"
cd /path/to/myAppName/SourceCode
setenv CODESIGN_ALLOCATE /Developer/usr/bin/codesign_allocate
/usr/bin/codesign --force --sign "myCertificate" --entitlements "/path/to/myAppName.xcent" "/path/to/myAppName.app"
I would like to sign my app folder at the end of the build, and not during the Xcode build.
My problem is I don't know how to generate the xcent file in the command line.
Question : How do you generate xcent files in command line? I did a find from the root, there is nothing called productPackagingUtility...
I would like to sign my app folder at the end of the build, not during the Xcode build.
IIRC recent versions of Xcode complain if you disable code signing for a device build.
The easiest way around this is to let Xcode sign it and then re-sign it later. Steps are approximately
Dump the original entitlements with codesign -d --entitlements=MyApp.xcent MyApp.app
If you're changing provisioning profiles, copy the new one to MyApp.app/embedded.mobileprovision and modify the entitlements accordingly (IIRC the file format has a 4-byte magic and a 4-byte length; remember to update the length!).
Re-sign with your desired certificate.
Using the codesign utility does not require an xcent file. You can simply create a plist file and use that for entitlements. Make sure it is an XML plist, not binary.
The format of the .entitlements and the ${APPNAME}.xcent is the same so it can just be copied across.

iOS Enterprise: Re-certify existing IPA with new certificate

We are enrolled in the iOS Enterprise Program. The provisioning profile used for our released apps is about to expire, so I got a new certificate and provisioning profile.
I need to re-distribute some of our apps with the new provisioning profile, without building them anew. How?
(I vaguely remember seeing a utility program that did exactly this: You choose an IPA and a provisioning profile, and it would create a new IPA using the new profile and certificate. What was the tool’s name, and where can I get it?)
In theory whoever built the last IPA in XCode should have used Archive - this creates a build you can sign to create an IPA (using XCode).
You could also try using the command line signing tool XCRun to re-sign the App bundled in your existing IPA:
http://skabber.com/package-your-ios-application-with-xcrun
OK, turns out when you know what term to google, there‘s lots of excellent resources…
They all point to xcrun. I made it work with this shell snippet, adapted from this promising build script:
APP_FILENAME=MyApp.app
BUILD_DIRECTORY=/Path/To/Target/Dir
IPA_FILENAME=MyApp.ipa
DISTRIBUTION_CERTIFICATE='iPhone Distribution'
PROVISIONING_PROFILE_PATH='/Path/To/Profile.mobileprovision'
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "$APP_FILENAME" -o "$BUILD_DIRECTORY/$IPA_FILENAME" --sign "$DISTRIBUTION_CERTIFICATE" --embed "$PROVISIONING_PROFILE_PATH"
The codesign command-line utility, included with the iOS SDK tools, will allow adding/changing the certificate and provision with which a developer built app is signed.
As hotpaw2's anwaswer states. You can also resign using the codesign tool.
The way I do it (this may not be the most efficient, but it works)
Rename the .ipa to a .zip and extract
Run The following:
/usr/bin/codesign -f -s "iPhone Distribution: Company Name" "Payload/MyApp.app"
Re-zip the Payload folder and rename to .ipa
Note: You can also use this method to edit the embedded.mobileprovisioning file! Just remember to remove the .DS_Store (rm Payload/.DS_Store) if you are using finder.
You can do manual way if you just resigning app from same account with following steps.
All this is using shell script and super easy provided you know how to use shell commands.
Rename IPA to zip
unzip this file to temp folder
Remove the old _CodeSignature folder from all targets (if you have multiple targets like main,watch, watch extn, siri, widget, message, etc)
bring all the targets prov-profiles in one folder and replace all the embedded.provisioningprofile files for each target with the new ones
remove the archived....xccent file as this is old one (optional)
code sign with the entitlements.plist created for all the entitlements if any used by the app.
Zip the folder back after code sign all okay with no errors
Rename the zip to IPA
Note: To validate the IPA before upload to apple you can just use the altool from inbuild XCode App Loader to check the new IPA.
Reference: The steps for commands is also explained here:
http://www.enterpriseios.com/forum/topic/Resigning_3rd_party_apps
If you want to get rid of manual sign use the fastlane tool as its quite simple and easy to configure.https://fastlane.tools/

Resources