天道酬勤,学无止境

Xcode -- groups and targets

Question

I have an Xcode project. The project currently has four targets, and I am about to add more. Within the project are about 150 png files. I have all of these in a tree of groups in the Xcode "groups and files" panel.

I want to include these png files in some of my targets, but not in others. The thing is, I will always want either all of them or none of them. I don't want to pick and choose.

Is there a way to manage this? Basically, I want some targets to use all of the files in the "png files" group, and others to use none of them. If there is a way to include an entire tree of groups in a target, and remove the same tree from another target, without having to do each file individually, that would be ideal.

EDIT: starting a bounty on this due to the lack of response. If it's not possible to do the above, I would be interested in other ways to accomplish more or less the same thing -- for example would it help to make all the png files a shared library? Or to make them a target in and of themselves, and have some of my other targets depend on that one? In either case, I would need to know how to set the thing up.

My bottom line is that I want to do the whole thing as simply as possible. For example, it should be easy to add a file to the 150 and tell my project that it should be included in all targets that use that group of files.

Answer1

I am using the Xcode 3.2.3 right now. I am able to right click on a group, select get info then jump over to the 'Targets' tab and select my targets I want those files to go into. It works for me, is this what you are looking for?

Answer2

Write a script and include it in the appropriate targets as Run Script Phases. Since it gets environment variables from Xcode it’s pretty easy for the script to copy files over to the right place. You can also pass more information to the script and maintain a clean, code-only Xcode project.

You’ll have a directory full of images, and every time the script runs (as you build the targets) it copies everything. To add an image, you add it to the directory without modifying the Xcode project.

标签

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

相关推荐
  • Including/excluding entire groups from targets
    Question My project has a group with a few hundred files (organized into a couple dozen subgroups two levels deep). The files in that group are themselves being changed reasonably often. I want those files to be included in some targets, but not others. In Xcode 3.x, after each change to the group, I would just Get Info on the group itself, go to the Targets tab, and (re-)select the targets I wanted. (This was, in fact, the answer to a nearly-identical question from 2010, Xcode — groups and targets.) In Xcode 5, the equivalent File Inspector panel doesn't have a Target Membership section if
  • Xcode 8: different entitlements for each scheme causing errors
    Question I found an issue with XCode 8 where .entitlements files are not being referenced properly for each scheme. Basically, my Debug .entitlements file is being referenced for my Release scheme. This is causing an issue because we implemented the new Rich push notification logic and that requires the use of App groups. I am using two different teams (Development and Production), so there will be two specific App Groups. Anyone know how to resolve this issue? Thank you Answer1 I found a solution. Make one .entitlements file add this: <key>aps-environment</key> <string>$(APS_ENVIRONMENT)<
  • Xcode Different Resources For Different Targets
    Question I am developing an iPhone app and there will be a Full as well as a Lite version of that app. In order get both bundles from the same source code and Xcode project I added another target to the Xcode project. Now, I want to have the Lite target copy only a subset of the resource files to the bundle. But, Xcode won't simply let me delete individual files from the "Copy Files to Bundle" build step, since I imported all my resources as folder references. I need this in order to maintain a directory structure in the resources directory. How do I solve this problem? Any suggestions or
  • When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target
    Question I searched for a long time on stackoverflow using every keyword I could think of to solve this. I am programming for iphone and I have a lite and paid version of my app. I followed the instructions here Creating Lite Versions of iPhone Games / Apps for duplicating the target. This works and now I am working on slimming down the lite version. Main problem? Images. The lite version needs to have several hundred less images than the paid version. So, I made 2 groups in XCode. One "Folder Group" in Xcode - named "FreeImages" and another "ProImages". I want all FreeImages only to be
  • XCode - Multiple targets, Multiple *internationalized* names?
    Question I've got an internationalized iPhone project. In the various ${lang}.lproj/InfoPlist.strings files I've got a single key, CFBundleName = "My App Name". That's working fine for a single target, but I can't make it work for multiple targets. I'd like to have several translated InfoPlistMyApp.strings files for the main target, plus several InfoPlistMyAppLite.strings files for the lite version. But I can't figure out how to set it up. The InfoPlist.strings name seems to be set in stone, so I can't replace it dynamically. Any ideas? Answer1 Turns out this is quite easy, if laborious. You
  • Xcode Project vs. Xcode Workspace - Differences
    Question I am trying to understand how the whole ecosystem of iOS works. Until now, I could find an answer for most of my question (and trust me, there have been a lots of them), but for this one, there seems to be no clear answer yet. What is the difference between XcodeProject and XcodeWorkspace files? What is the difference between the two of them? What are they responsible for? Which one of them should I work with when I'm developing my Apps in team/alone? Is there anything else I should be aware of in matter of these two files? Answer1 I think there are three key items you need to
  • containerURLForSecurityApplicationGroupIdentifier returns nil on iOS Simulator
    Question Context With iOS8 and extensions Apple introduced the App group containers (more info here). Problem We use it through NSFileManager's containerURLForSecurityApplicationGroupIdentifier: method. It works well in production on AppStore (with both iOS8 and iOS7). Problem is since our team updated to Xcode 6.1 (6A1052d), the method returns nil on Simulators. We searched a lot but we didn't manage to find any clues. Even this question or this one are not applicable here. TLDR: Question Does NSFileManager's containerURLForSecurityApplicationGroupIdentifier: method works on your simulators
  • Share data between targets in xcode project [duplicate]
    Question This question already has answers here: Share datas between two apps with iOS 8 App Groups (using NSUserDefaults) (2 answers) Closed 6 years ago. I have a project with two different targets (a free and a paid version of the same app) and I have a list with items that I save to NSUserDefaults. My question is, is there any way to share this list between the two version of the app, without using KeyChain or something similar ? Answer1 Your can use App Group and save items in it. Project -> Capabilities -> App Groups Add App Group in your targets Using NSUserDefaults ex: NSUserDefaults
  • Xcode warning: “Multiple build commands for output file”
    Question I am getting an error like this: [WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/no.png [WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/d.png [WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/n.png But I have checked Xcode and I don't see any duplicates of such files at all. As this post in the Apple Mailing Lists say, there are no duplicates. Answer1 In the Project Navigator, select your Xcode Project file
  • Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements
    Question This post relates to a rapidly changing event. I've tried all the other questions and searched everything on this that I could already, a lot of the other questions involved existing apps that were being updated or people with developer accounts but this is like my second time using Xcode and it has worked before. This just happened out of nowhere. I keep getting these two errors and it allows me to run simulators but not build onto my iPhone: Automatic signing is unable to resolve an issue with the "LearningSpriteKit" target's entitlements. Automatic signing can't add the application
  • What's the Xcode “no such file or directory error”?
    Question Xcode keeps prompting telling me I don't have a certain image in the project and it errors when I try to build. If I deleted the .png Xcode is complaining about from the project, why does Xcode error out when I try to build? [Edited by Rhubarb (got too big for the comments)] I'm getting the same thing with these details. The copy command looks like this CpResource MyIcons/../13-bicycle.png /Users/Me/Library/Developer/Xcode/DerivedData/MyProject-cxsohyxdecdbptgrrtaixbhhixrj/Build/Products/Debug-iphonesimulator/MyProject.app/13-bicycle.png then there's a bunch of setenv and the command
  • Can an Xcode project with multiple targets have different Settings.bundle's for each target?
    Question I have a settings bundle in an iPhone app which has several subtle variant targets. The problem is I need to customise some strings in each settings bundle to make them appropriate for each target. It appears that if the Settings bundle is named anything other than Settings.bundle it won't pick up the bundle (understandable, can I specify in a plist somewhere the alternate name?). If I try and put them in different folders and call them the same thing Xcode gets horribly confused and lets you edit "2 files" that are actually the same single source. Answer1 I see no problem. For every
  • Xcode shows warning after adding App Groups (Add the “App Groups” entitlement to your App ID) [closed]
    Question Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago. Improve this question After I added an App Group in Xcode it shows a warning: Add the "App Groups" entitlement to your App ID Add the "App Groups containers" entitlement to your App ID Before the warning there was a loading spinner like this: after it finished the loading I got the following warnings: What can I do to correct the two wrong steps? If I'm right it is already added
  • How do I create a bundle of reusable code in Xcode?
    Question I am developing an iPhone app and have to parse xml files in order to put them into a database. I will also be using those same xml parsers in my app so users can import their own data. I was wondering how I can extract those xml parsers into a bundle or a library so I can use them both in my iPhone app and in a command line app where I just populate a sqlite3 database. Thanks in advance! Answer1 Create a static library project, then use the interproject dependency feature of Xcode to build them in the correct order and link the app with the static library. You'll need to have a
  • Getting dyld_fatal_error after updating to Xcode 6 beta 4 using swift
    Question I just recently downloaded Xcode 6 beta 4, and my swift project compiles with no errors but before it gets to my code I get a dyld_fatal_error just above start in the call stack. and a breakpoint in some assembly code with a nop instruction The console error I get is dyld: lazy symbol binding failed: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__ Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku Expected in: /Users/username/Library/Developer/Xcode/DerivedData
  • cannot upgrade current target for ipad
    Question i try to upgrade my old existing app to make it a universal application for iphone and ipad. i clicked on my target and tryed to select "upgrade current target for ipad", but i cannot click it, because its not clickable. alt text http://dl.dropbox.com/u/80699/Bildschirmfoto%202010-05-05%20um%2018.21.30.png my project settings are: The Base SDK is set to iPhone Device 3.2 The iPhone OS Deployment Target is set to iPhone OS 3.1 The Targeted Device Family is set to iPhone/iPad are there any other things i have to pay attention? please help, to get my application upgraded. Answer1
  • There is no SDK with the name or path “iphoneos4.0”
    Question I download a sample of UICatalog and run it.When I compile it ,it shows the failed message:There is no SDK with the name or path "iphoneos4.0".I find the "Base SDK" of UICatalog's Targets is iphone Device 4.0(missing).How can I solve this question and run it. Thank you! Answer1 Select the root level of the project, in "Groups & Files". It's blue. Then hit command-I to get its Info. Pick "Build" from the segmented controller at the top of the info window. In the first section of that panel you'll see Base SDK as one of the first few lines of options. Select the latest version of the
  • Installing Core-Plot in Xcode 4.2 for iOS project
    Question I am trying to install Core Plot into my iOS app. I have followed the instructions on the Core Plot website but they are very brief and have no screenshots. I have pasted the instructions below and explained where I am stuck... First, drag the CorePlot-CocoaTouch.xcodeproj file into your iPhone application's Xcode project. Show the project navigator in the left-hand list and click on your project. Select your application target from under the "Targets" source list that appears. Click on the "Build Phases" tab and expand the "Target Dependencies" group. Click on the plus button, select
  • Google Maps SDK for iOS requires GoogleMaps.bundle to be part of your target under 'Copy Bundle Resources
    Question When I build a GoogleMaps SDK for iOS,these error occurred. *** Terminating app due to uncaught exception 'GMSException', reason: 'Google Maps SDK for iOS requires GoogleMaps.bundle to be part of your target under 'Copy Bundle Resources'' but,GoogleMaps.framework is in copy bundle resources.so,I'm confused.please tell me cause of this problem. Answer1 The instructions are kinda lacking. I hope this helps... Launch Xcode (easy) Drag the GoogleMaps.framework bundle to the Frameworks group of your project. When prompted, select Copy items into destination group's folder. Right-click
  • Xcode workspaces with sub-projects and project dependencies triggering builds
    Question I wish there was better documentation for this for Xcode 5 but I couldn't find anything decent describing best practices for working with workspaces, so.. In a workspace with several projects (couple frameworks, 1 app) is it possible to have Xcode build all dependent projects only when required (i.e. changes found) w/o having to include all projects in all dependent projects? I'd rather like to just have the frameworks in the project depending on it instead of having 5-6 sub projects in it as this is just a mess in the Navigation View - files inside sub-projects show up in search