Lipo error with additional schemes in XCode - ios

I want to create additional build configurations and schemes in my XCode project in order to build sepcific archives for TestFlight. One connected to our DEV environment for internal testers, and one connected to our PROD environment for external beta testers.
So I was following this excellent blog post and I created 2 additional build configurations by duplicating the Release one. Then I created 2 additional schemes based on the default one, by changing the build configuration of the Archive build operation to the proper build configuration. Finally I set some user-defined settings in each build configuration to point to the right server URL depending on whether we are in a DEV build or a PROD build.
But now when I archive my project using one of these two additional schemes, I get the following Lipo error:
/fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can’t open input file: /Users/sarbogast/Library/Developer/Xcode/DerivedData/Build/Intermediates/ArchiveIntermediates/MyAppTestFlightPROD/IntermediateBuildFilesPath/MyApp.build/TestFlight PROD-iphoneos/MyApp.build/Objects-normal/armv7/MyApp (No such file or directory)
And indeed when I go to /Users/sarbogast/Library/Developer/Xcode/DerivedData/Build/Intermediates/ArchiveIntermediates/MyAppTestFlightPROD/IntermediateBuildFilesPath/MyApp.build/TestFlight PROD-iphoneos/MyApp.build/Objects-normal/armv7 directory, there is no MyApp file or directory in there.
I read here and there that setting 'Build Active Architecture only' to YES might solve the problem, but I don't want to do that as these are release builds for TestFlight and I want them to work on all architectures.
Any idea what might be wrong in my set up?

I am using CocoaPods and I had log messages saying that the linker could not find Pods for my new scheme. So I added my new scheme to link_with in my podfile and now it works perfectly.
I still don't understand why, because I thought link_with was only to list targets and this is not a target, this is a scheme. But it works.

Related

How to address this warning generated by crashlytics / fabric?

Here is what I know/do:
I am importing Fabric via a pod.
The build script for Fabric is the last one
It is set to generate a dsysm
DEBUG_INFORMATION_FORMAT should be set to dwarf-with-dsym for all configurations.
This could also be a timing issue, make sure the Fabric run script build phase is the last build phase and no other scripts have moved the dSYM from the location Xcode generated it. Unable to process myapp.app.dSYM at path /Users/no-one/Library/Developer/Xcode/DerivedData/myapp-ahatoktzxteqbcaohqnktdtfczxr/Build/Products/Debug-appletvos/myapp.app.dSYM
Make sure your project build settings are generating a dSYM file.
Go into your target's Build Settings and then type in DEBUG_INFORMATION_FORMAT into the Search Bar that appears in the top right.
It looks like this:
And you can choose "Dwarf With Dsym" from the pop-up menu.

Specify individual target build settings with xcodebuild

I have an iOS app that uses Cocoapods, and has a local cocoa touch framework target, and I'm running into an issue with specifying build settings in the command line using xcodebuild.
I understand that you can specify build settings like PROVISIONING_PROFILE, CODE_SIGN_IDENTITY, and DEVELOPMENT_TEAM by appending their key=value pair to the end of the command.
However those setting appear to be applied to the entire project, but I only need them to apply to the app target since touch frameworks cannot be signed.
How do I specify build settings for an individual target using xcodebuild? If it cannot be done using xcodebuild, could this be accomplished using fastlane?
Use schemes. You can set the scheme to build/archive with a particular build configuration and executable.

Created new XCode Configuration and Scheme - linker is suddenly failing

A new XCode project has Debug and Release Configurations. I've added a new one under "ProjectName > Info" called "development", which is for now a duplicate of "debug".
I wanted to create a new scheme for building the app in development mode, so I duplicated the "Projectname" scheme and named it "DevelopmentScheme".
I set the build configuration for "run" and "archive" to the new "development" configuration that I created.
I'm still able to build the original Scheme.
I'm also able to build all of the required libraries when the project is configured with the development scheme, but when I get to the linking phase, I get the error:
ld: library not found for -lRNCookieManagerIOS
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Being relatively new to iOS development, I'm not really sure what the issue could be. Since I duplicated everything, shouldn't that mean they behave in the same way? Thoughts on what might be different between the original and new schemes?
The problem is that Xcode will expect to find the libraries inside a folder named after your custom configuration. You can add the custom configuration to each library you use, or better follow the steps below to make it use the libraries built via the Release configuration.
Steps:
Select your target
Open Build Settings tab
Search for 'Library Search Paths'
You'll see your new configuration name alongside Debug and Release
Double-click the space next to your new configuration name
Enter "$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)"
Set recursive to true.
Exit the dialog and you should see:
(inspired by this post)
Xcode 8.3.2 needs a bit different changes.
To make it work, you need to change the Per-configuration Build Products Path for your custom build config. For example, I have an Internal build config. In that field, instead of $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME), I put $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME), and now it works :).

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)

Target Properties changes by xcodebuild command

How can i manipulate my iOS Target Properties by xcodebuild command tool ?
In example, i have one project with one target and with Facebook SDK Key in Target Properties in Info tab
FacebookAppID: 01234567891234
And with console command xcodebuild i'm compiling two Apps with Developer and Production provisions with two console commands:
For Developer:
xcodebuild -project Projectname.xcodeproj clean install OBJROOT=ObjRoot ... CODE_SIGN_IDENTITY={iPhoneDeveloper} PROVISIONING_PROFILE="Dev.mobileprovision"
For Distribution:
xcodebuild -project Projectname.xcodeproj clean install OBJROOT=ObjRoot ... CODE_SIGN_IDENTITY={iPhoneProduction} PROVISIONING_PROFILE="Prod.mobileprovision"
And i need use in Developer one FacebookAppID, and in Production a other FacebookAppID, and how i can change my command lines for realize this?
Thanks
Arguments to xcodebuild are best used for values that change every time they're invoked, like a destination directory that includes a build number.
For data as foundational as a Facebook app ID, I'd recommend using your build configurations, e.g. "Debug" and "Release". Create a user-defined build setting (in Xcode 5.0.2, Editor -> Add Build Setting -> Add User-Defined Setting) named something like "FACEBOOK_ID", and in your Info.plist, set your desired key's value to ${FACEBOOK_ID}. In your target's build settings, define FACEBOOK_ID differently for your Debug and Release configurations. Your code then now has to pull the current value out of Info.plist at runtime.
If you really want to override build settings as arguments to xcodebuild, you can do so, just by adding "FACEBOOK_ID=12341234" to the end of the command, but this only works if you've done the work I just described to make FACEBOOK_ID into a configuration-specific build setting. I can't think of any sound reasons to keep this kind of app data outside of a build configuration.
If build configurations are new to you, I'd suggest starting with WWDC 2012 session 408, "Working with Schemes and Projects in Xcode".

Resources