35

I added a vanilla Today Application Extension and run with the new scheme created by XCode.
After it finishes building ("Build Succeeded" pops up), it failed straight away with this error:

Installation Failed
Invalid argument

I've been trying to find answers for 6 hours now, no luck so far. Please help!

rptwsthi
  • 10,094
  • 10
  • 68
  • 109
foct
  • 351
  • 1
  • 3
  • 3
  • possible duplicate of [Installation Failed: Invalid Argument -iOS Extension](http://stackoverflow.com/questions/27031746/installation-failed-invalid-argument-ios-extension) – GreenAsJade Jan 02 '15 at 11:10
  • @GreenAsJade. This was not a duplicate of the other issue, rather a referenced folder named "contents" I had included. – eric Jun 08 '15 at 19:36

11 Answers11

77

Check if the Bundle Identifier isn't empty in the Info.plist

AtzeAckermann
  • 914
  • 6
  • 3
  • 4
    I upgraded an old XCode project, and it had me replace a hard-coded string in my Info.plist with $(PRODUCT_BUNDLE_IDENTIFIER). I had to take that hard-coded string and put it into the project itself in the new "Product Bundle Identifier" section of the "Packaging" category. – esilver Aug 15 '15 at 20:51
  • Upgrade to recommendation settings, reset my plist to empty values ... had to revert! – karim Oct 07 '15 at 10:26
  • This does not work for me. The answer below does work – andrewmclean May 25 '16 at 23:24
  • If anyone else is killing themselves trying to find out why this error is being thrown and this answer didn't help, check to see if your actual bundle identifier is set in Targets->yourtarget->general->Bundle Identifier. Mine was empty. – Minimi Oct 07 '16 at 18:14
39

Try this:

  1. Quit Xcode
  2. Clean out ~/Library/Developer/Xcode/DerivedData manually
  3. rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
  4. iOS Simulator > Reset Content and Settings
user3719188
  • 590
  • 5
  • 7
18

Maybe you are bundling a conflicting "contents" referenced (blue) folder.

Hint: change the name of said "contents" folder :)

GiovaMaster
  • 340
  • 3
  • 12
  • 3
    HA! That was great! I was very baffled for a moment. Thanks for pointing this out. Additionally, a restart of Xcode is probably needed. I deleted the derived data, and restarted Xcode to make the issue go away (after renaming my folder) – eric Jun 08 '15 at 19:33
  • 5
    it's the same problem if the folder name is "resources". cleaning up DerivedData is needed also – amarkovits Aug 18 '15 at 21:23
  • @amarkovits +1, won't install if you have "Resources" referenced folder – derpoliuk Oct 10 '15 at 09:56
  • 1
    "Resources" is the demon. – J.Wang Mar 23 '16 at 01:58
8

This issue occurred in my case when the phone's memory was too low to install the app. I've cleaned up the phone and voila!

Another hint might be this post.

Community
  • 1
  • 1
lukas_o
  • 3,776
  • 4
  • 34
  • 50
8

This can also happen in Xcode 7 because "Upgrade to recommended settings" will change CFBundleIdentifier to point to $(PRODUCT_BUNDLE_IDENTIFIER) instead of the old $(BUNDLE_IDENTIFIER).

Apple says in the Xcode 7 release notes that PRODUCT_BUNDLE_IDENTIFIER is now "the recommended place to set the Bundle Identifier for a target." So if you're using BUNDLE_IDENTIFIER anyplace else in your project, be sure to change it to PRODUCT_BUNDLE_IDENTIFIER to keep things in sync.

jemmons
  • 18,605
  • 8
  • 55
  • 84
  • 1
    This recently happened to me. When I looked at the Bundle Identifier field of the target (under "General") it was empty even though the Info.plist had the correct identifier. There was also a warning that the provisioning profile bundle identifier didn't match. I entered the Bundle Identifier and the warning went away and I could then run normally. I guess this was the "Invalid argument". – QBit Sep 30 '15 at 19:12
3

I was getting the same error - although in different conditions - and it took me a while to realise that I had inadvertently messed with the Info.plist (thank you user2866588!) via a Search & Replace operation.

Once fixed that file, the error went away. It's a long shot, but you never know...

Paolo Marini
  • 323
  • 1
  • 3
  • 13
2

I got this error when my test phone had low memory (around 288MB free). After restart and clearing some cached data, I was able to install my app.

anoop4real
  • 7,598
  • 4
  • 53
  • 56
2

Image description here.!! I got this Error Just Enter Bundle Identifier. (You can get bundle identifier by right click on info.plist and go to Open as than Source Code here just find this CFBundleURLSchemes below this name a string tag contains your bundle identifier) Copy Bundle identifier and past it on TARGET select General now on Identity you will see Bundle Identifier paste there and enter. then just run the code. Happy Coding!!!

enter image description here

enter image description here

enter image description here

MRizwan33
  • 2,723
  • 6
  • 31
  • 42
1

What I found is that info.plist file should never been localized! I tried to localize my project and tried to tap Localization on all plist and string files. As a result, I could not install my app to Simulator, invalid argument error.

I spent 1.5 days trying to find out reason. I tried all the solutions as listed above, but with no luck. Finally, discard all my localization changes and redo it again. This time, I tried to localize one file first, and then compiled codes and trie to run my app on Simulator.

The issue is info.plist file. You could localize it. The result is that en version is moved en.lproj folder. That is to say, no more info.plist file in the project folder. As a result, Xcode could not find it and exception raised.

Another way to verify it is to check your project settings. Select your target and general tab. The Identity should be like:

enter image description here

If your project settings are something like this, you have to locate info.plist, that means info.plist is missing.

enter image description here

You just cannot locate localized info.plist in en.lproj folder from project settings.

enter image description here

Don't localize info.plist file directly. You can localize it by localizing infoplist.strings file.

This may be one of reasons to get invalid argument exception, as in my case.

I also wrote a blog on this.

David.Chu.ca
  • 37,408
  • 63
  • 148
  • 190
0

I got the same issue and it was because of low memory on phone. I deleted some apps and restarted the phone which brought by available storage.

palzarena
  • 1
  • 1
0

I got this error after installing new pods (AWS) to my project. Somehow the entry in the Build Settings for Info.plist file was cleared. Entering the correct filepath (find in finder) my project finally compiled again.

user3798780
  • 101
  • 8