I currently try to exclude my In-App Purchase logic in an App of mine to make it reusable in other Apps of mine or even put it on a public git repository for others to use. For this purpose I follow this guide of creating a framework in XCode.
But in step 2 I have to set the Target Membership of my .h file to public. The problem is, that in my Xcode (v 4.5) I can't see any visibility when the .h file is clicked (and also not when I click other files like .m ones). It looks like that:
What am I doing wrong there?
I came across this same problem and found your question an hour after it was posted but here is what I have found. In Xcode 4.4 the ability to change the target membership, and visibility, for header files was removed so this tutorial will not work as written.
Instead of changing the target membership visibility you can add a "Copy Headers" build phase to the target you made in step 1 (Serenity in the example). This will have 3 sections for Public, Private, and Project headers. Just click the plus at the bottom and the headers you want to be public to this step. By default they are put in the Project section but you can click and drag them to the Public section.
The rest of the tutorial should work fine from there.
Edit: Just noticed that in my own project, after adding the copy headers build step, that the target membership can be selected for header files so the tutorial works as written. Though it seems to act a little strange with my framework header. In any case, changing the visibility in the build phase is reflected under target membership and vice versa
Build Phases -> Add Build Phase -> Copy Bundle Resources (in case you don't have it)
Then drag and drop your file there... Good luck ;)
Related
First off, I'm a Mac OSX newbie, both using and programming, but it's been thrust upon me. My project is moving along nicely, but I need to unzip a file, and it looks like SSZipArchive seems like the way to go. I want to manually add it to my project, so that it stays all together in my source code control system. Others, esp. the release engineer, shouldn't need to do anything, and we need to have all the source code local.
I've tried a million ways and back, only to keep getting the dreaded "No Such module" error. I've researched for a couple days now, and still no closer. So I'm starting from scratch in a new project to say what I'm doing and to plead for some help here. All this is being done on an El Capitan laptop, using Xcode 7.3.1, with Swift 2.2.
Create a Cocoa Application project, calling it 'ziptest', using Swift, nothing else checked. Build it just for fun.
Drag 'n' Drop the SSZipArchive folder found in the master.zip downloaded from the SSZipArchive GitHub site into my project. I'm not sure where it should go, or if it matters - top level, between ziptest project icon and the ziptest group or inside the ziptest group. But I'll put it inside the ziptest group. Now I'm faced with a new question - for the "Added folders", do I want to "Create groups" or "Create folder references". I do copy the items, because, as I said, I want to add them to SCCS later. I saw somewhere here on Stackexchange to make sure it is Group, so that's what I'll do. Build again and it still works.
I know I need a "bridging header" file, so I'll create it. I thought at some point, Xcode asked if I wanted to create it, but the above step doesn't do that. After much experimention, I found that if I d'n'd the SSZipArchive.m/.h files directly, it asks me. It doesn't put anything into it, but at least it creates it and updates the Build Settings. But I do this now manually by right clicking on the ziptest group folder, select New File... and create an empty Header File called "ziptest-Bridging-Header.h", following the pattern from the Xcode created one, being sure to check off the ziptest Target.
I add:
#import "SSZipArchive.h"
to that file. And building still works.
I added ziptest-Bridging-Header.h as the Objective-C Bridging Header in the Build Settings. And building still works.
Now comes the moment of truth. I add:
#import SSZipArchive
to AppDelegate.swift and I get the dreaded No such module 'SSZipArchive'
What am I doing wrong?
Edited to add: Oh, I also added libz.dylib to the Build Phases -> Link Binary With Libraries part. Doesn't help, of course, because we haven't even gotten to the link phase yet.
I have one functionality and it is depending on one static library. Actually, Apple is not allowing this static library because of few reasons. So, for now we have decided to add one Preprocessor macro and based on that functionality should be switch on/off.
I have switched my code to behave based on that Preprocessor macro. But I didn't find any to link or unlink the library based on preprocessor macro. I can not allow to link the library all times, as I have already told apple is not allowing it.
One solution that I already know : I can create the multiple target. But problem is that my app has already lots of targets. So, again to manage this I have to create one more target for each target those are already created.
Any help will be appreciated.
Edit:
I have created configuration like Francesco suggested. But One quick question I have let's say If I will remove the path of library from "Library Search Path" then that library will not be linked to app? Because that library is still in target of App.
Instead of targets you can create multiple configurations. And you can change the linker flags there.
I did this think for Sparkle framework (which is not allowed on App Store)
EDIT:
To create/manage the configurations click on the project in the sidebar. Then in the main window select again the project, not the targets, and select the "Info" tab.
Together with Deployment Target selection and Languages you will find a Configuration section.
You can add or remove configurations from there.
Then to launch it you have to go to Product -> Scheme -> Edit Scheme -> Build Configurations.
You can duplicate an existing scheme and choose the correct configuration from there.
You can remove the static library from the list of linked items by setting a (somewhat undocumented) Xcode build setting:
EXCLUDED_SOURCE_FILE_NAMES = libUnwanted.a
You can do this in an .xcconfig file or in the normal target build settings UI (by adding a custom build setting). If you for example set this in the "Release" configuration Xcode will include the library in the "Debug" build but omit if for the release build.
EXCLUDED_SOURCE_FILE_NAMES works with all kinds of files that can be added to a target: source files, resources, libraries, ...
Here's how to do this step by step:
Open the target build settings by clicking on the blue project icon in the Project Navigator and select the Build Settings tab.
Click the plus icon to add a "User-Defined Setting"
Name the setting "EXCLUDED_SOURCE_FILE_NAMES"
Expand the Configurations for the setting and set the "Release" value to the name of your unwanted library.
Credit of this answer goes to Nikolai Ruhe & Francesco
I have combined the answer of both and I got the solution.
Here are the steps that I followed.
Created new configuration. ( To know how to create configuration see
the answer of Francesco)
Added flag EXCLUDED_SOURCE_FILE_NAMES in user-defined setting of Build settings. (For steps see the answer of Nikolai Ruhe). And in this flag I have added the name of my static library under the my custom configuration.
Here is a good tutorial that will definitely help you : Remove tesflight from Distriubtion
This is possibly an extension of
How can I add an existing project as a working copy in XCode 4?
I have an existing iOS XCode project 'Project A' with one target, which is the app it builds.
Now I have another project 'Project B' I am currently working on and would like to add the 1st project as is to this one as and include it as a feature.
When I drag the .xcodeproj file of A, I can see the project come in, however, it brings in the target as well. When I look at the 'Target Membership' of any file in A, it has A's target and I don't see B's target.
What I would like to do is only have B's target and link all files in A to B.
I tried creating a lib out of A but that process is far more tedious. I would really like to proceed down the copy+link path. Can someone suggest what can be done?
Sounds like you might be more interested in an Xcode Workspace, unless you are truly interested in merging these two projects for good.
If you want to bring in all of the source files of the other project, you can right click the project in Xcode and choose "Add files to 'MyProject' ..." and in the interface that is presented you can choose target membership. I would go this route to "merge" the projects together rather than dragging in the full Xcode project.
There very well may be a way to do it how you are hoping, but this is the route I know and would take.
Basically I want to make an independent copy of my Xcode project and all of my files. How can I do this? I'm researching graphing frameworks and I want to use the same UI for each.
Seconding #zoul's comment, this can be accomplished in Xcode 4.5 with four steps.
In Finder, duplicate the project folder. Do not update the .xcodeproj file name.
In Xcode, rename the project. Accept the proposed changes.
Still in Xcode, rename the scheme in "Manage Schemes".
In Info.plist, rename your Bundle identifier.
Few months ago, I had the need to create a different applications with the same source code.
I didn't wanted to copy the full directory, so I came up with a procedure that allowed me to mantain the source code in one place and create many different apps based on the same source code.
My procedure is the following:
duplicate the target to make a new target and change the name to the new name
change the name of the product and info.plist in the build options (select the new target and click info button), make sure this is for All Configurations
rename the info.plist file created at the duplication to "newnameInfo".plist (click on the file and then info button and pick the target)
add icon.png to the resources for the specific target.
change the name of the icon
in the NewnameInfo.plist change the icon name to icon_xxx and the bundle identifier com.yourdomain.newname
in language/other flags you can have a flag to check at the code.
create a new APP_ID in the iOS Provisional Portal
if APN is used, configure the APN BEFORE creating the development profile
create a new development & distribution (ad-hoc or appstore)
in Target (info) choose the right profile for the code sign
I hope this helps.
--nnahum
Go to your project folder. Right click on it. Select "duplicate".
Is there something you want to achieve that this doesn't accomplish?
Copy and paste your project folder. Open the new folder and open the Xcode project file. Select the project name in the "Project Navigator" on the left side and then in "File Inspector" on the right hand side, change the name of the project under Identity and Type.
That way you will have a duplicate project with two different names.
Hope this helps!
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 included in the lite app and all FreeImages and ProImages to be in the paid app. I do not care that XCode considers these Groups to be Virtual Folders. I reversed the instructions to a point and have an environment flag (-D) set in XCode "PLUS_VERSION" I want XCode to basically do the following:
If (PLUS_VERSION)
{
copy contents of FreeImages *and* ProImages where normally they go
}
else
{
copy contents of FreeImages where they normally go.
}
Anyone know where to start to tell XCode to conditionally copy contents of groups into the target?
For each resource (or folder of resources) you want to direct to a specific target, you can click on the resource and inspect it (either via right-clicking and selecting Get Info or by clicking on the Inspect toolbar option). Within that info dialog will be a tab called Targets, where you can check the targets you want the resource (or even source code file) to be incorporated into, and uncheck the ones you don't.
Alternatively, I believe you can navigate to the target itself in Xcode, click on the triangle next to its name to expand the list of build phases, expand the Copy Bundle Resources build phase, and manually delete from the list there any resources you don't wish to have copied over into that target.