Xcode proj runs in simulator, but fails to archive "app_sign cannot resign <myapp>"

I’m at the point where I’m almost ready to build, but when I try to archive the project I get the following error in xcode:

app\_sign cannot resign /Users/me/Library/Developer/Xcode/DerivedData/My-App-bzgdaitstcabzpaiygqfnluetfhk/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/My-App.app/My App. Please remove and then build

Does anyone know why this is happening?

In build settings I’ve tried leaving the code signing identity blank, and tried it with the correct distribution profile.

I’ve tried with and without the provisioning profile specified. 

I’ve tried deleting the whole file in my DerivedData folder.

It would seem that this is the line in question that causes the problem:

"$TOOL\_PATH" app\_sign sign "$SHARED\_RESOURCE\_DIR/developerkey.cert" "$CORONA\_RESOURCE\_CAR\_PATH/resource.car" "$CORONA\_EXECUTABLE\_PATH" little

But I don’t know enough about what it’s doing here to think of the solution.

Can anyone from Corona help me out please?

Just thought I’d add that if I build the sample app that still builds fine, but my own app still fails.

Hmm, if it does not reproduce with the sample code, and only happens with your project, then we’ll need you to send us a project that we can reproduce the issue with.

You can send it by filing a bug: http://developer.coronalabs.com/content/bug-submission

@walter  

Thanks for replying.

The project is quite large (79.5mb when zipped). I’d strip stuff out, but since you hopefully won’t need to comb over the code in the project itself (since it seems to be an issue with how the xcode-corona signing process) I feel like it would be a better test to try it with the whole project.

If I attach a link to the zip file in dropbox to my bug submission, is the bug report content only visible to Corona employees (e.g. not open for anyone to download the zip file and get all of our projects content)? I can’t see anywhere where bug reports are visible, but just wanted to check.

I’ve just submitted a bug report this morning … and then got everything working about 10 mins later. Why is that always the way?

I was always pretty sure it wasn’t a corona problem per se (potentially the build script code), but had no idea what the cause was.  

Although I had tried making new projects, I was copying my code across from the ‘broken’ project because obviously I needed those files for my own project. I’m guessing that maybe I was copying the xcode.proj file or something else and that was the cause of the error. Perhaps keeping a reference to a build that no longer existed or something?

Apologies for adding an extra bug report to the list, hopefully someone can mark it as complete as soon as they get it.

Just thought I’d add that if I build the sample app that still builds fine, but my own app still fails.

Hmm, if it does not reproduce with the sample code, and only happens with your project, then we’ll need you to send us a project that we can reproduce the issue with.

You can send it by filing a bug: http://developer.coronalabs.com/content/bug-submission

@walter  

Thanks for replying.

The project is quite large (79.5mb when zipped). I’d strip stuff out, but since you hopefully won’t need to comb over the code in the project itself (since it seems to be an issue with how the xcode-corona signing process) I feel like it would be a better test to try it with the whole project.

If I attach a link to the zip file in dropbox to my bug submission, is the bug report content only visible to Corona employees (e.g. not open for anyone to download the zip file and get all of our projects content)? I can’t see anywhere where bug reports are visible, but just wanted to check.

I’ve just submitted a bug report this morning … and then got everything working about 10 mins later. Why is that always the way?

I was always pretty sure it wasn’t a corona problem per se (potentially the build script code), but had no idea what the cause was.  

Although I had tried making new projects, I was copying my code across from the ‘broken’ project because obviously I needed those files for my own project. I’m guessing that maybe I was copying the xcode.proj file or something else and that was the cause of the error. Perhaps keeping a reference to a build that no longer existed or something?

Apologies for adding an extra bug report to the list, hopefully someone can mark it as complete as soon as they get it.

Annoyingly, I’ve hit this bug again.  

This time I was preparing for our first update since the 64-bit requirement took affect (I was waiting for one ad provider to update their static lib to support 64 bit).  

Once that was done I changed the architecture from $(ARCHS_STANDARD_32_BIT) to just $(ARCHS_STANDARD). I also had to remove the -all_load linker flag, as 2 of the static libs had duplicate variables.

Then when I rebuilt, I got this error:

app\_sign cannot resign /Users/me/Library/Developer/Xcode/DerivedData/My-App-abcdefghijklmnop/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/My-App.app/My App. Please remove and then build

I’m not sure if changing the architecture is what causes the problem. Perhaps it keeps a record somewhere of the 32 bit version, and then there is a mismatch somewhere. I’ve tried deleting the app file (and also the entire DerivedData folder for that app) that the error message suggests, but no luck. I’ve also removed the archives from Xcode, still no joy.

Does anyone have any ideas about other things I could try?

I’ve tried “fixing” this the same way that I did previously, which was to grab a new xcode proj file from the Enterprise/samples folder, and then to make the project anew by dragging in my existing lua files and linking all the necessary libs. 

I’m still getting the same problem, and I’ve narrowed it down to a single line in Corona’s CertifyBuild.sh script:

 echo "the next line will work successfully" "$TOOL\_PATH" app\_sign sign "$SHARED\_RESOURCE\_DIR/developerkey.cert" "$CORONA\_RESOURCE\_CAR\_PATH/resource.car" "$CORONA\_EXECUTABLE\_PATH" little checkError # If more than one architecture, repeat app\_sign for each \*additional\* architecture (hence $count \> 1) count=`echo $ARCHS | wc -w | tr -d ' '` #$count is 2 echo "start count = $count" while (( $count \> 1 )) do echo "THE NEXT LINE WILL CAUSE AN ERROR!" "$TOOL\_PATH" app\_sign sign "$SHARED\_RESOURCE\_DIR/developerkey.cert" "$CORONA\_RESOURCE\_CAR\_PATH/resource.car" "$CORONA\_EXECUTABLE\_PATH" little checkError ((count--)) done

It’s the same line that I identified back last September, but I’ve downloaded a new version of Corona Enterprise and I can see that the script is the same, so this can’t be affecting other users. What I don’t understand is why it IS happening to me.  

Is there anyone out there (Corona staff or otherwise) who has run in to this before or has an idea of what the cause could be?

Edit:

It seems to me that the while loop doesn’t seem to instruct it to sign anything different to the line before the loop. I don’t see anything that instructs it to sign a certain arch or anything like that, although I don’t know what the “little” command at the end does, so perhaps that’s what is supposed to do it.

Hi Alan, did you upgrade your xcode recently? You might try doing a full clean build (“Clean build folder” via Option-Shift-Command-K)

Also, removing “-all_load” may cause you problems. In particular, it’s possible you’ll get a “require” Lua error that the corresponding Lua library for the plugin cannot be found.

No I haven’t upgraded Xcode for at least a few months, I’m using Version 6.1. 

I had only tried the regular Clean (Command-Shift-K), but I’ve just tried Clean Build Folder and there is no change - I still get exactly the same error.  

I’ve also noticed there is another forum post from a few days ago where someone is getting the same error message, but for seemingly different reasons:

https://forums.coronalabs.com/topic/57443-dead-code-stripping-parameter-error/

As for removing the -all_load flag, if I want to use 2 unrelated 3rd party libs and they have duplicate symbols, is it just “tough luck pick your favourite one”? 

I can’t be 100% sure I’ve fixed it (because I had this once in the past and it reappeared) but I have managed to build.  

I took out one of the libs that had duplicate symbols, and then replaced the all_load flag, and it seems to have built ok. 

I’ll need to get in touch with the lib providers to see what can be done - one of the libs is the AdRally plugin, but it’s possible I have an old beta version so I’ll get more info and send them - the other is an ad network called MediaBrix.

Here are some of the symbols in question, they are all to do with LiveRail which I believe is a Facebook ad thing:

duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentAdCandidate in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentEnvironmentData in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentSelectedAdLinearAsset in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_avPlayer in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_touchView in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_streamStartTimer in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentDuration in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentTime in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentRemainingTime in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentAdSkippableRemainingTime in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_boundaryTimeObserver in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_active in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_stalled in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o)

Here is a txt file with all of the errors:

https://www.dropbox.com/s/1lshd5z92up319v/duplicateSymbols.txt?dl=0

If there is somewhere better to send them, then please let me know and I’ll pass them on (I’ve also sent them to a contact at Fuse).

As for removing the -all_load flag, if I want to use 2 unrelated 3rd party libs and they have duplicate symbols, is it just “tough luck pick your favourite one”? 

Yea, it is unfortunately due to static linking on iOS.

If you have source, then you can manually rename classes so there is no namespace collision, but since it’s Facebook, that doesn’t sound like an option.

Annoyingly, I’ve hit this bug again.  

This time I was preparing for our first update since the 64-bit requirement took affect (I was waiting for one ad provider to update their static lib to support 64 bit).  

Once that was done I changed the architecture from $(ARCHS_STANDARD_32_BIT) to just $(ARCHS_STANDARD). I also had to remove the -all_load linker flag, as 2 of the static libs had duplicate variables.

Then when I rebuilt, I got this error:

app\_sign cannot resign /Users/me/Library/Developer/Xcode/DerivedData/My-App-abcdefghijklmnop/Build/Intermediates/ArchiveIntermediates/App/InstallationBuildProductsLocation/Applications/My-App.app/My App. Please remove and then build

I’m not sure if changing the architecture is what causes the problem. Perhaps it keeps a record somewhere of the 32 bit version, and then there is a mismatch somewhere. I’ve tried deleting the app file (and also the entire DerivedData folder for that app) that the error message suggests, but no luck. I’ve also removed the archives from Xcode, still no joy.

Does anyone have any ideas about other things I could try?

I’ve tried “fixing” this the same way that I did previously, which was to grab a new xcode proj file from the Enterprise/samples folder, and then to make the project anew by dragging in my existing lua files and linking all the necessary libs. 

I’m still getting the same problem, and I’ve narrowed it down to a single line in Corona’s CertifyBuild.sh script:

 echo "the next line will work successfully" "$TOOL\_PATH" app\_sign sign "$SHARED\_RESOURCE\_DIR/developerkey.cert" "$CORONA\_RESOURCE\_CAR\_PATH/resource.car" "$CORONA\_EXECUTABLE\_PATH" little checkError # If more than one architecture, repeat app\_sign for each \*additional\* architecture (hence $count \> 1) count=`echo $ARCHS | wc -w | tr -d ' '` #$count is 2 echo "start count = $count" while (( $count \> 1 )) do echo "THE NEXT LINE WILL CAUSE AN ERROR!" "$TOOL\_PATH" app\_sign sign "$SHARED\_RESOURCE\_DIR/developerkey.cert" "$CORONA\_RESOURCE\_CAR\_PATH/resource.car" "$CORONA\_EXECUTABLE\_PATH" little checkError ((count--)) done

It’s the same line that I identified back last September, but I’ve downloaded a new version of Corona Enterprise and I can see that the script is the same, so this can’t be affecting other users. What I don’t understand is why it IS happening to me.  

Is there anyone out there (Corona staff or otherwise) who has run in to this before or has an idea of what the cause could be?

Edit:

It seems to me that the while loop doesn’t seem to instruct it to sign anything different to the line before the loop. I don’t see anything that instructs it to sign a certain arch or anything like that, although I don’t know what the “little” command at the end does, so perhaps that’s what is supposed to do it.

Hi Alan, did you upgrade your xcode recently? You might try doing a full clean build (“Clean build folder” via Option-Shift-Command-K)

Also, removing “-all_load” may cause you problems. In particular, it’s possible you’ll get a “require” Lua error that the corresponding Lua library for the plugin cannot be found.

No I haven’t upgraded Xcode for at least a few months, I’m using Version 6.1. 

I had only tried the regular Clean (Command-Shift-K), but I’ve just tried Clean Build Folder and there is no change - I still get exactly the same error.  

I’ve also noticed there is another forum post from a few days ago where someone is getting the same error message, but for seemingly different reasons:

https://forums.coronalabs.com/topic/57443-dead-code-stripping-parameter-error/

As for removing the -all_load flag, if I want to use 2 unrelated 3rd party libs and they have duplicate symbols, is it just “tough luck pick your favourite one”? 

I can’t be 100% sure I’ve fixed it (because I had this once in the past and it reappeared) but I have managed to build.  

I took out one of the libs that had duplicate symbols, and then replaced the all_load flag, and it seems to have built ok. 

I’ll need to get in touch with the lib providers to see what can be done - one of the libs is the AdRally plugin, but it’s possible I have an old beta version so I’ll get more info and send them - the other is an ad network called MediaBrix.

Here are some of the symbols in question, they are all to do with LiveRail which I believe is a Facebook ad thing:

duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentAdCandidate in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentEnvironmentData in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentSelectedAdLinearAsset in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_avPlayer in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_touchView in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_streamStartTimer in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentDuration in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentTime in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentRemainingTime in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_currentAdSkippableRemainingTime in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_boundaryTimeObserver in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_active in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o) duplicate symbol \_OBJC\_IVAR\_$\_LiveRailLRAdapter.\_stalled in: &nbsp; &nbsp; myProject/ios/libMediaBrix.a(LiveRailLRAdapter.o) &nbsp; &nbsp; myProject/ios/libplugin\_adrally.a(LiveRailLRAdapter.o)

Here is a txt file with all of the errors:

https://www.dropbox.com/s/1lshd5z92up319v/duplicateSymbols.txt?dl=0

If there is somewhere better to send them, then please let me know and I’ll pass them on (I’ve also sent them to a contact at Fuse).