Carthage: How to use Carthage with iMessage or Sticker Pack Applications?

Created on 14 Sep 2016  Ā·  13Comments  Ā·  Source: Carthage/Carthage

  • carthage version: 0.17.2
  • xcodebuild -version: Xcode 8.0 Build Version 8A218a (GM Seed)
  • Are you using --no-build? No
  • Are you using --no-use-binaries? No
  • Are you using --use-submodules? No

Create a vanilla iMessage Application. Note that these are different than just extensions for existing apps. This creates two targets by default, one is an app which houses the extension (really just a shell and not a normal app), and the message extension itself, which has normal build configuration elements like Build Phases where we add our Carthage copy-frameworks stuff. This works great for all our builds except for when it comes time to validate to the App Store, and we get this error:

iTunes Store operation failed.
Invalid Bundle. The bundle at '***.app/PlugIns/MessagesExtension.appex' contains disallowed file 'Frameworks'.

The copy-frameworks call works by copying our frameworks into the frameworks directory of the extension, when it really needs to be in the frameworks directory of the shell app, under: ***.app/Frameworks (we tested moving them manually and testing to see the app still runs). Unfortunately there's not an obvious way to get these copied to the right location. Possible solutions are: setting up our Carthage dependencies to work with Cocoapods, linking to the source directly (http://www.mokacoding.com/blog/carthage-no-build/) or create a secondary target that moves the frameworks into the correct folder which seems hacky.

question

Most helpful comment

@sprint84 Sure!

  1. Create the copy-frameworks phase as normal in the extension target.

  1. Open MyApp.xcodeproj/project.pbxproj in your editor of choice. (I used Atom, but that's not important.)
  2. Search in The Messā„¢ for "Run Script" or even copy-frameworks.

  1. Find the "id" of that build phase.
  2. Search the pbxproj for that id. You'll find it in a list of other build phases for your extension target.

  1. Move that line from into the containing app target.

Hope this helps!

All 13 comments

This sounds like something that Carthage should handle.

Would you be interested in opening a PR to fix this? The code for this is pretty self-contained. It's harder for me to fix it because I don't have an iMessage or Sticker Pack application to test/submit.

In the meantime, it sounds like moving the frameworks manually will enable you to submit?

Why not out the copy-frameworks phase in the app target then, if it's needed there?

@NachoSoto You can't put the copy-frameworks phase in the app target because Xcode doesn't show the Build Phrases tab for iMessage app containers.

Edit: We had to do some pbxproj surgery to make it work, but it does work.

@a2 Can you share the solution of how to make it work for iMessage app extensions?

@sprint84 Sure!

  1. Create the copy-frameworks phase as normal in the extension target.

  1. Open MyApp.xcodeproj/project.pbxproj in your editor of choice. (I used Atom, but that's not important.)
  2. Search in The Messā„¢ for "Run Script" or even copy-frameworks.

  1. Find the "id" of that build phase.
  2. Search the pbxproj for that id. You'll find it in a list of other build phases for your extension target.

  1. Move that line from into the containing app target.

Hope this helps!

No, no need for screenshots.
I was able to follow your steps.

I submitted to the store and it was validated. Let's see how the other steps go!

Thanks.

@a2 can you add screenshots, I actually tried but it failed again.

@otymartin Sure! I added screenshots (marked up with Preview.app šŸ˜‚) to my post above.

@a2 THANKS so much for taking the time. Much appreciated :)

We should check the document for correct understanding (and also https://github.com/CocoaPods/CocoaPods/issues/5860, https://github.com/CocoaPods/CocoaPods/pull/5953).

You can't put the copy-frameworks phase in the app target because Xcode doesn't show the Build Phrases tab for iMessage app containers.

Looks like the issue will be fixed in a future Xcode version.

So a possible solution is adding FRAMEWORKS_FOLDER_PATH user-defined build setting in your iMessage Extension target, then setting the value to ***.app/Frameworks (*** is your iMessage app product name). The value of the build setting will be normally ***.appex/Frameworks and that is used in copy-frameworks command. Overriding the setting should work around the problem.

Looks like Xcode 8.1 beta has added the 'Build Phases' tab to the containing app target. Adding the copy-frameworks build phase to this app target instead of the extension target seems to work.

Xcode 8.1 is officially released so this should be closed now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yonaskolb picture yonaskolb  Ā·  3Comments

josercc picture josercc  Ā·  3Comments

rogernolan picture rogernolan  Ā·  3Comments

itinance picture itinance  Ā·  3Comments

mdiep picture mdiep  Ā·  3Comments