Can't create Archive with Static Library - ios

I'm trying to create a archive for a app linking to a static library but with no luck.
I can built the app in both release and debug mode just fine. I can even built it for Archive (product->built for->archiving) but it fails miserably when I try to create the archive (products->Archive)
XCode can't seem to find the headers for the Static lib:
In file included from /Data/Code/iPhoneDev/ArchiveTest/ArchiveTestApp/ArchiveTestApp/ArchiveTestAppAppDelegate.m:9:
/Data/Code/iPhoneDev/ArchiveTest/ArchiveTestApp/ArchiveTestApp/ArchiveTestAppAppDelegate.h:10:24: error: DataFetcher.h: No such file or directory
In file included from /Data/Code/iPhoneDev/ArchiveTest/ArchiveTestApp/ArchiveTestApp/ArchiveTestAppAppDelegate.m:9:
/Data/Code/iPhoneDev/ArchiveTest/ArchiveTestApp/ArchiveTestApp/ArchiveTestAppAppDelegate.h:13: error: cannot find protocol declaration for 'DataFetcherDelegate'
Any ideas or suggestions on what I'm missing here?

I ended up roughly following the suggestions in this Questions:
Compile, Build or Archive problems with Xcode 4 (and dependencies)
Create a group call "Indexing headers" in your project
and drag the headers to this group, DO NOT add to any targets when
prompted. This includes any headers inside your dependency
For all dependancies set "Skip Install" build setting to "Yes"
Moving any "Public" headers in Build Phases to "Project" for dependency
Set the Build Setting "Installation Directory" on your Target to
$(LOCAL_APPS_DIR)
The archive was created with no errors with step 1-3, but for it to become a valid app step 4) was needed.
Amazing how half baked XCode4 seems

Related

React Native xcode project "Header Search Path"

Following the steps from React Native official tutorial, the xcode project created by "react-native init MyFirstRNProject" won't compile. It complains "React/xxxxx.h" can't be found.
After further investigation of this xcode project, I figured the "React" target contains a build phase "Copy Headers" which copies all exposed headers into a weird location:
"MyFirstRNProject/node_modules/react-native/React/build/Debug-iphonesimulator/include/React"
OK, cool, at least we got the header location. We can change the copied location to somewhere else that better than this. So whichever the project that do "#import < React/xxxxx.h >" should have above path in "Header Search Path" in build settings. Unfortunately, all projects have "Header Search Path" empty. And that's why I'm getting tons of header not found error.
OK, let's add it. Now it finds headers, but compilation still failed, see reference below:
https://github.com/facebook/react-native/issues/21482
The discussion above saying that removing the "Header Search Path" of the projects will solve the problem. But we know that without header search path, it again can't find React headers.
Just curious now, I don't think my setup is wrong, does anyone has the same issue?
I had the same problem on fresh install of Xcode 10.1
There are few steps to follow to compile the new project after react-native init appName
In Xcode, Select File -> Project/Workspace Settings. You will see a Build System option to select the Legacy Build System as shown below
Change Advanced settings, and set Build Location to Custom and change paths to Relative to Workspace and Build/ to build/Build/ as showed.
3. User Debug for command-line builds(for react-native run-ios to work properly)
Clear your project
After this manipulations(don't need set header search paths) you'll be able to build and run empty project via Xcode or CLI

Validation Error: The bundle contains disallowed file 'Frameworks'

I'm having the same issue as this guy, this guy, and this guy (nota bene, I'm actually not sure if they're all guys, per se).
They all ended up finding their own solutions, but none of them apply to my issue. I'm using Xcode 6.1 in my iOS 8 app with an included extension. The app and the extension both rely on an included framework. When I try to submit the app to the Store, the validation warning I get is "ERROR ITMS-9000: Invalid bundle. The bundle at 'xxxxx.appex' contains disallowed file 'Frameworks'".
I can't even find a file called Frameworks. The shared framework is supposed to be saved at /Library/Frameworks, which is Apple's recommended save location. The project also uses Cocoapods, which strikes me as the only other possible culprit, since it has references in its configuration files to $FRAMEWORK_PATH (though the build folder doesn't include a file or folder with that name).
OK for future viewers here's the fix:
When you create your own iOS framework (I'm using Xcode 6.1) when you build it the final product contains a 'Frameworks' folder in the framework bundle itself. i.e. MyFramework.framework/Frameworks. This happens even if you don't specify a copy files/embed frameworks build phase.
What you have to do is to go into you framework bundle, find the empty frameworks folder and delete it. This should not affect your app's functionality in any way. Then build your app and check that the embedded framework doesn't have a Frameworks folder as planned.
Your archive should now not contain the offending folder and the error should be gone!
I changed build settings > Packaging > Define modules set to YES in my extension and watch app target. Works fine for me.
In my case the solution was the following :
Try to create the script there 'problematic target' -> Build Phases' then click on + and select New Run Script Phase, the run script should go after all others. Insert there :
cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi
Then clean the project and try to create an archive once again. These answer was provided in the following issue :
https://github.com/CocoaPods/CocoaPods/issues/4203
I hope this help you.
Continuing to work with this, I noted that my Share Extension had an "Embed Frameworks" Build Phase, with the Destination set to the "Frameworks" directory. I changed it to "Shared Frameworks" and the error has gone away.
However, another error remains: "... contains disallowed nested bundles". I thought this was a sort of umbrella error warning as a result of the original. I'll open another question for that one.

Static Library public headers are not copied to Build/Products folder

I have 2 projects, which build one static library each, as well as another project which uses both static libraries.
One of the two static libraries builds fine. The other one does not and the reason for that is that its public headers are not copied to the build folder before the custom shell script runs.
Here is a demonstration of what happens:
SampleA (the one that works)
Compile MyClass1.cpp ...
Compile MyClass2.cpp ...
Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
Create universal binary libSampleA.a ...
Copy SampleA.h ...in /Users/user/....
Copy MyClass1.h ...in /Users/user/....
Copy MyClass2.h ...in /Users/user/....
Run custom shell script 'Prepare Framework'
Stripping libSampleA.a
--- Build complete
SampleB (the one that does NOT work)
Compile OtherClass1.cpp ...
Compile OtherClass2.cpp ...
Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
Libtool /Users/user/Library/Developer/XCode/DerivedData/.....
Create universal binary libSampleB.a ...
// >>>>> NO HEADER FILES ARE COPIED <<<<<<
Run custom shell script 'Prepare Framework'
--- Build fails (header folder does not exist)
My current setup is a workspace that includes all 3 projects, but I used to have 1 project with one nested project for each static library as well. The issue I have remains the same in both setups.
More info
I have tried virtually every instruction, tip and advice I found online for making this work.
The settings on both projects, as far as I can tell, are identical. Comparing the two project files wasn't very effective. I also haven't compared all the settings of both projects one by one to make sure they are the same (yet).
The problem is the same in both Debug and Archive builds (I know that archiving behaves differently)
I have added "$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include" and/or "$(PROJECT_TEMP_DIR)/../UninstalledProducts/include"
I have added the headers to the "Build Phases > Copy Headers > Public" section - didn't work
I have deleted the "Build Phases > Copy Headers" phase completely, as Apple suggest and added the headers to the Copy Files phase - didn't work
I have added a new group in the static lib project and added all its headers, setting no target to "Add to Targets" - didn't work
I have quit XCode and tried again, or even restart the mac - didn't work
One difference between the two libraries is that SampleB (the one that does not build) includes various headers from SampleA. There are no compiler or linker errors, just the error at the end of the build that I describe.
Sources
Some of the sources I have used for the creation of the library, as well as for trying to solve the issue:
https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/creating.html
Xcode 4 can't locate public header files from static library dependency
Compile, Build or Archive problems with Xcode 4 (and dependencies)
http://www.blog.montgomerie.net/easy-xcode-static-library-subprojects-and-submodules
So, do you know what triggers the headers to be copied or not be copied, during the build?
I would suspect that even if one header file is added to the Copy Headers phase or the Copy Files phase, at least this should be copied. But as it turns out, this is not what happens, at least in my case.
Following Apple's instructions, and just creating a CocoaTouch static library project from the template:
Ensure you have placed your custom "Run Script" phase after the "Copy Files" phase:
Then, when building, the transcript will look as this:
In my setup I have a parent project with a nested project, which emits a static library.
I tried with a Headers phase, I couldn't get Xcode to copy the headers in the right spot when archiving. Plus the headers and the static library were copied into the archive, which you don't want. So I ended up using a Copy Files phase and setting Skip Install to YES while pointing the Header Search Paths in tha parent project to BUILT_PRODUCTS_DIR.

Archiving xcode project that contains static library

I created a project with static library.
When I tried to archive, It fails and library Headers are missing.
But when I build the app, it works fine.
And in build folder headers, bundle resources and library are created outside app file.
Is it possible to create these file in app file and archive
or any other process available for archiving?
Thanks in advance.
If you are able to build the app but not archive then it seems that the build settings that you are using for archive build configuration (probably Release) is not correct. Quick test will be to change the build configuration for archive to same as build, most probably Debug (you can do that in Product->Scheme->Edit Scheme).
To fix this you can open the Build Settings for your target, search for "Header Search Path", click the ">" to open this setting and fix it for the build configuration that is used by archive (i.e. make it same as the build configuration used by Build)

Xcode Archive linker error. Static libs created in Debug-iphonos directory

I'm using Xcode 4.3.3 to create an archive for iTunes submission and I get a linker error. I discovered that the reason behind it is that the static libraries created by my sub-projects are created in the build\Debug-iphoneos directory rather than Release-iphoneos. In the Product->Edit Scheme dialog I confirmed that the sub-projects Archive schemes all have the "Release" build configuration set and have "Reveal Archive in Organizer" checked. Also, my main project has Skip Install set to YES and the Target Skip Install is set to NO. All sub projects have Skip Install to YES. So I conclude that the Archive scheme for the sub projects are likely not being invoked by the main project when I Product->Archive it. I have looked at many settings and don't have a clue?
Thanks....

Resources