Post not yet marked as solved
I have progress to report, and partial answers.The root cause of the problem with Settings / Preferences localization had to do with my Settings.bundle Root.plist specifying "Root.strings" as the Strings Filename, instead of simply "Root". I figured this out by looking at a new project with a Settings bundle, and diffing. I think my Settings.bundle was initially created in 2008. So, wow. OK.Regarding the other problem, with the ALL-CAPS menu items, I noticed the following runtime logging output repeated a dozen or so times at startup, varying the "<numbers-and-letters>.title" part:[-snipped-] [strings] ERROR: 0fi-6W-Mns.title not found in table MainMenu of bundle CFBundle 0x1024136d0 </System/Library/PrivateFrameworks/UIKitMacHelper.framework> (not loaded)I have no idea what this means, or how to resolve it.
Post not yet marked as solved
OK, I filed Apple Problem 41497418, "Presence of a URL property in a Swift class causes Bundle(for: <class>.self) to return wrong path"This is kind of wild, to me. It had nothing to do with the xcassets, it instead had to do with how I am specifying the bundle containing the assets. I was using Bundle(for: MyClass.self), and if MyClass contained a let or var URL property, the path for the bundle was inside Xcode beta.app, which is wildly incorrect, instead of inside the framework bundle (in Derived), which would be correct.After filing the bug report, I further simplified the steps:1. Create an Xcode project, select iOS, Cocoa Touch Framework, Swift, Include Unit Tests, name it BundleMadness.2. Create a Swift source file, name it Madness.swift, with the following:import UIKit
public class Madness {
// Comment out this line, and notice the test passes.
internal var randomlyNamedURL: URL? // <== THIS causes Bundle(for: Madness.self) to return the wrong path
internal var somePathToFrameworkBundle: String = ""
public init() {
let bundle = Bundle(for: Madness.self)
self.somePathToFrameworkBundle = bundle.bundlePath
}
}3. Replace the guts of the XCTest in BundleMadnessTests.swift with the following: func testTheMadness() {
let madness = Madness()
print("path = \(madness.somePathToFrameworkBundle)")
XCTAssertFalse(madness.somePathToFrameworkBundle.contains("Xcode-beta"), "Yo, what?")
}4. Build and run the unit test. Notice it fails. Comment out the line containing the URL property declaration. Build and run again. Notice it passes.
Post not yet marked as solved
Fair enough. I'm working on isolating the relevant code in the real framework project, while also trying to build up a standalone test case from an empty framework project, but this takes a great deal of time to do right... "Bisect, bisect, bisect..." Currently, the standlone test case passes (with copies of all of the assets), but the real framework target project is still failing (with 95% of unrelated code removed). I haven't pruned enough from the real code yet, to identify what's different from the test case.One thing I noticed while adding print statements in both:* When I call Bundle(for: MyClass.self) in a hacked-and-slashed version of MyClass in the standalone test case, the path of it is under Derived. I checked, and MyClass.swift is only included in the framework target, not the unit test target. This is expected.* When I call Bundle(for: MyClass.self) in the real code (with or without 95% of unrelated code removed), the path of it is under Xcode beta.app, specifically: /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Agents. This is very unexpected, and is why the assets aren't being found. I don't know why this is happening. I checked, and MyClass.swift is only included in the framework target, not the unit test target. Under Xcode 9.4.1, the path is under Derived, as expeced.I am passing Bundle(for: MyClass.self) as the bundle to load the UIImage from, in both the standalone framework test case and the real framework project, because it's a framework asset. In both cases, the bundle is being created inside a call in the framework.If I use the Bundle(identifier:) with the bundle identifier instead of Bundle(for:) with the class.self, I can force it to work in the real code.Puzzle: why isn't Bundle(for: MyClass.self) working in the real code, and why is it working in the standalone test case?
Post not yet marked as solved
Bumping this. Beta 2 continues to exhibit the same problem: successful build, and missing assets. The same project targets and unit tests run and pass under Xcode 9.4.1, but fail under Xcode 10 beta or beta 2.