Xcode - Add a target app to main app - xcode

I have an application in Xcode which I can compile.
When I do a Product -> Archive I am getting a macOS App Archive which I can export and publish.
Now I created a 2nd target in my project which is also an .app and which I want to be added to the 1st .app.
So I added a "Copy Files" Build Phase to my 1st target, set the destination to "Resources" and added my 2nd target to the list.
When I now do a Product -> Archive I'm getting a Generic Xcode Archive which I cannot export as an .app.
Am I missing something here?
Thanks

Related

Xcode add reference to files instead of copy

I have created my framework that i want to add in my project. What i do is:
In my project i chose Xcode -> File -> Add Files to..
In prompt window i go for framework directory, chose .xcodeproj file
Check "Copy items if needed" and "Added folders - Create groups" radio button
What i expect - .xcodeproj that contain my framework is added and copied to my project
What i got - i can see file in Xcode, but not in folder when my app exist. So, when i try to Delete -> Move to trash my framework, it delete it in folder when it was created (not my project folder).
I can't figure out how to actually add and copy file instead of reference to it.

ibtool can't build - The file “Info.plist” couldn’t be opened because there is no such file

I get the following error when building my project in Xcode 7 beta 5:
Summary:
My project won't build, the following error is given:
LinkStoryboards
cd /Users/lewis/Projects/MyApp/code/ios9
export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export XCODE_DEVELOPER_USR_PATH=/Applications/Xcode-beta.app/Contents/Developer/usr/bin/..
/Applications/Xcode-beta.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --module MyApp --target-device iphone --minimum-deployment-target 8.0 --output-format human-readable-text --link /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Products/Debug-iphonesimulator/MyApp.app /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Storyboard\ ios7.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Settings.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/TrackIt.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/UserList.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Migration.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Intro.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/YourMyApp.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/AddMeasurements.storyboardc
/* com.apple.ibtool.errors */
: error: The file “Info.plist” couldn’t be opened because there is no such file.
Failure Reason: The file doesn’t exist.
Underlying Errors:
Description: The operation couldn’t be completed. No such file or directory
Failure Reason: No such file or directory
I've tried the following based on advice from other SO questions:
Clean build folder
Delete derived data
Checked the Info.plist exists in project folder
Checked file is expected in Build Settings > Packaging > Info.plist file
Copying Info.plist into the the folders mentioned in the ibtool command
Adding the Info.plist to the Copy Bundle Resources section of Build Phases
Opening all of the Storyboard files in Xcode and checking they open and don't show any errors
Reinstalling Xcode Beta
Restarting machine (Mac OS 10.10.5)
I've filed a radar (because the project builds fine on Xcode 6), but it feels like there's more I could do to diagnose this myself. Any help greatly appreciated.
The problem is, you have a storyboard that is targeted lower than the target. Set the target of the storyboard to be higher (or better, set it to be the same as deployment target), and it will compile.
Same issue on Xcode 7 Beta 5, I fixed this by creating a new storyboard, and copying all objects from old storyboard to new one.

xcodebuild cannot find header in embedded projects

I have a project embed another project, and the xcode GUI build was successful, but in command line xcodebuild failed as such.
fatal error: 'OHAttributedLabel/OHAttributedLabel.h' file not found
#import <OHAttributedLabel/OHAttributedLabel.h>
^
1 error generated.
but I had this in the project HEADER SEARCH PATH (where the h is located)
${PROJECT_DIR}/MyProject/Vendor/OHAttributedLabel/Source
the problem is the header is located in the "OHAttributedLabel/Source" folder, while the import statement is looking for header under OHAttributedLabel folder, I don't want to touch the embedded project directory structure, what can I do in this case?
The best way is to modify the embedded project to publish the header files:
Select the embedded project in xCode
Select the applicable target.
Click on the build phases
Expand "Copy Headers" section and add OHAttributedLabel.h file.
Select your main project
Select the applicable target.
Click on build phases.
Click on Target dependencies.
Make sure that the embedded project is added as a dependency.
Try to run the app
If the above doesn't work double-check the order of the build phases. E.g. make sure that the "Target Dependencies" build phase is before "Compile sources".

How to get Xcode to refresh folder references on device?

I created a folder reference by doing the following:
Created a folder on disk. Added whatever files are meant to be in it.
In Xcode
---> Add files to project
---> Clicked on folder
---> Unchecked copy files if necessary
--->Clicked create folder references for any added folders
The problem:
Whenever I make changes to files in the folder (add/delete) etc. The changes are picked up in Xcode. (You can see the changes in project navigator). These changes are not there when I run on the simulator. Deleting the application on the simulator does not help. Only when I click "Reset content and Settings" in the simulator, does it pick up the changes.
I already have added the following script to my build phases:
touch -cm "${BACKGROUND_TEXTURES}"
It is run after compiling, but before copying bundle resources. My bundle resources contain this folder.
I'm not sure whether the script matters, since Xcode picks up the changes with to without it. It's the simulator that doesn't get updated, unless I manually set "Reset content and settings".
What is the correct way to solve my problem?
EDIT: I have tried Clean, then Build, but that doesn't seem to make any difference.
Example:
I create "Images" folder at project folder, and I "create folder references for any added folders".
Next I add touch -cm ${SRCROOT}/../../Images to Run Script,And I drag "Run Script" before to "Compile Sources"
clean and build,it's ok.

Xcode - duplicate Target - new Target fails to build

using Xcode 3.2.5 on 10.6.6 (10J521) and now 10J537.
I have an Xcode project containing 1 Target: "MyApp". It builds and runs successfully.
As well as source and resource files, the Target contains a "Copy Files" build phase which copies "Sparkle.framework" in. The framework is in the same directory as the project.
I want to duplicate this Target. Steps taken:
Did "Clean all Targets".
Right-clicked on the "MyApp" Target within Xcode, and then chose "Duplicate".
Renamed the duplicated target to "MyAppTarget2".
Selected "MyAppTarget2" as the Active Target from the popup menu in the top-left.
Did "Build".
The problem:
error: Sparkle/Sparkle.h: No such file or directory
At the line:
#import <Sparkle/Sparkle.h> // In MyAppDelegate.mm
This is puzzling! Further info:
Each Build step appears to have been replicated in the duplicated Target, including the "Copy Files" phase.
The Sparkle.framework itself exists in the project's folder.
In the "Link Binaries with Library" phase of both "MyApp" and "MyAppTarget2", I am linking to the Sparkle.framework at the above location. A "Get Info" on the linked binary reports that it is a member of both Targets.
If I right-click on the Sparkle.framework file within the "Copy Files" build phase of the duplicated Target, and select "Reveal in Finder", then the correct Sparkle.framework file is shown. The required file exists at Sparkle.framework/Headers/Sparkle.h
If I switch back to the original "MyApp" target, it builds and runs successfully.
Am I doing something obviously wrong here? Thanks.
[EDIT - SOLVED]
I had a look at the Build settings for each supposedly-identical Target.
Under "Framework Search Paths", the first Target had this:
$(inherited) "$(SRCROOT)"
But the duplicated Target had this path:
$(inherited) \"$(SRCROOT)\"
It appears that Xcode incorrectly escaped the path during the duplication process. Ouch.
I know you have already solved this issue yourself, but I thought I'd share my fix for this issue (as it has happened to me several times). I've always been able to get rid of this error by deleting the file in question and just recreating it. I have no idea why this works... but, as is often the case with XCode, there seems to be some Voodoo at work.
Build Phase copy is still broken in 12.5! It does only copy a few of the source targets build phases. What a crap IDE.

Resources