简体   繁体   中英

iOS how to replace my app icon in .app file and resign?

Now, I have a project that has to distribute in 20 or more 'ipa' files according In-house distribution. However, these files are totally identical. They are divided into different 'ipa' files by different icons and different names. It is my question that I rename the icon file into same name with my icon file in Xcode project. And build it to be a .app file, resign it after I replaced different icons in this .app file. But it doesn't works. So what should I do? I don't want to archive it over 20 times to get the ipa files!!That's painful and boring.

detail: First, I use a command xcodebuild to get a .app file.
xcodebuild -workspace ${projectDir}/xxxxx.xcworkspace -scheme ${schemeName} -configuration Release clean -sdk iphoneos build CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${PROVISIONING_PROFILE}" SYMROOT="${projectDir}/build" Before I do this, I've set this in Xcode. Then, I open the app file and I found this .
So I decide to change the icon so that I don't have to re-archive many times. So I replace this by else icon . They have same names. After that, I resign this .app file according using this command
xattr -cr $ipaPath/Payload/myproject.app codesign -f -s "xxxxxx" --entitlements $Entitlements $ipaPath/Payload/myproject.app . And I upload to a platform and download from there. The icon was not changed(is the first one not second ). So why did it happen? and how could I solve it. By the way, I also re-write the plist file to change the DisplayName , it works.

You'll have to re-build the app to get the icons into the bundle; re-signing is not sufficient.

I would suggest the following:

  1. In the asset catalog, you create App Icon assets for each target and give them an individual name, eg AppIconTaget1 and so on
  2. In the build settings of each target, you create a variable named eg TargetAppIconName and assign it accordingly to AppIconTarget1 and so on (so in the second target, TargetAppIconName == AppIconTarget2 )
  3. In the Info.plist file, you assign the CFBundleIconName entry to the value of this variable, eg $(TargetAppIconName)

Then, without any pre/post copying and so on, you should get individual icons after building each and every target.

its seems must archive 20 times in your project => General => TARGETS, you can create 20 targets with , set target different icons and different names. then archive them with auto script(use xcodebuild)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM